/*
 * generated by Xtext 2.12.0
 */
grammar InternalMapping;

options {
	superClass=AbstractInternalAntlrParser;
}

@lexer::header {
package com.irtsaintexupery.xtext.pseim.parser.antlr.internal;

// Hack: Use our own Lexer superclass by means of import. 
// Currently there is no other way to specify the superclass for the lexer.
import org.eclipse.xtext.parser.antlr.Lexer;
}

@parser::header {
package com.irtsaintexupery.xtext.pseim.parser.antlr.internal;

import org.eclipse.xtext.*;
import org.eclipse.xtext.parser.*;
import org.eclipse.xtext.parser.impl.*;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser;
import org.eclipse.xtext.parser.antlr.XtextTokenStream;
import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens;
import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken;
import com.irtsaintexupery.xtext.pseim.services.MappingGrammarAccess;

}

@parser::members {

 	private MappingGrammarAccess grammarAccess;

    public InternalMappingParser(TokenStream input, MappingGrammarAccess grammarAccess) {
        this(input);
        this.grammarAccess = grammarAccess;
        registerRules(grammarAccess.getGrammar());
    }

    @Override
    protected String getFirstRuleName() {
    	return "PatternApplication";
   	}

   	@Override
   	protected MappingGrammarAccess getGrammarAccess() {
   		return grammarAccess;
   	}

}

@rulecatch {
    catch (RecognitionException re) {
        recover(input,re);
        appendSkippedTokens();
    }
}

// Entry rule entryRulePatternApplication
entryRulePatternApplication returns [EObject current=null]:
	{ newCompositeNode(grammarAccess.getPatternApplicationRule()); }
	iv_rulePatternApplication=rulePatternApplication
	{ $current=$iv_rulePatternApplication.current; }
	EOF;

// Rule PatternApplication
rulePatternApplication returns [EObject current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		otherlv_0='transform'
		{
			newLeafNode(otherlv_0, grammarAccess.getPatternApplicationAccess().getTransformKeyword_0());
		}
		(
			(
				{
					if ($current==null) {
						$current = createModelElement(grammarAccess.getPatternApplicationRule());
					}
				}
				otherlv_1=RULE_ID
				{
					newLeafNode(otherlv_1, grammarAccess.getPatternApplicationAccess().getModelModelCrossReference_1_0());
				}
			)
		)
		otherlv_2='using'
		{
			newLeafNode(otherlv_2, grammarAccess.getPatternApplicationAccess().getUsingKeyword_2());
		}
		(
			(
				{
					if ($current==null) {
						$current = createModelElement(grammarAccess.getPatternApplicationRule());
					}
				}
				otherlv_3=RULE_ID
				{
					newLeafNode(otherlv_3, grammarAccess.getPatternApplicationAccess().getPatternPatternCrossReference_3_0());
				}
			)
		)
		otherlv_4='{'
		{
			newLeafNode(otherlv_4, grammarAccess.getPatternApplicationAccess().getLeftCurlyBracketKeyword_4());
		}
		(
			otherlv_5='multiplicity'
			{
				newLeafNode(otherlv_5, grammarAccess.getPatternApplicationAccess().getMultiplicityKeyword_5_0());
			}
			(
				(
					{
						newCompositeNode(grammarAccess.getPatternApplicationAccess().getCardinalityValuesCardinalityValueParserRuleCall_5_1_0());
					}
					lv_cardinalityValues_6_0=ruleCardinalityValue
					{
						if ($current==null) {
							$current = createModelElementForParent(grammarAccess.getPatternApplicationRule());
						}
						add(
							$current,
							"cardinalityValues",
							lv_cardinalityValues_6_0,
							"com.irtsaintexupery.xtext.pseim.Mapping.CardinalityValue");
						afterParserOrEnumRuleCall();
					}
				)
			)
			(
				(
					{
						newCompositeNode(grammarAccess.getPatternApplicationAccess().getCardinalityValuesCardinalityValueParserRuleCall_5_2_0());
					}
					lv_cardinalityValues_7_0=ruleCardinalityValue
					{
						if ($current==null) {
							$current = createModelElementForParent(grammarAccess.getPatternApplicationRule());
						}
						add(
							$current,
							"cardinalityValues",
							lv_cardinalityValues_7_0,
							"com.irtsaintexupery.xtext.pseim.Mapping.CardinalityValue");
						afterParserOrEnumRuleCall();
					}
				)
			)*
		)?
		(
			otherlv_8='components'
			{
				newLeafNode(otherlv_8, grammarAccess.getPatternApplicationAccess().getComponentsKeyword_6_0());
			}
			(
				(
					{
						newCompositeNode(grammarAccess.getPatternApplicationAccess().getModelElementGraphElementMappingParserRuleCall_6_1_0());
					}
					lv_modelElement_9_0=ruleGraphElementMapping
					{
						if ($current==null) {
							$current = createModelElementForParent(grammarAccess.getPatternApplicationRule());
						}
						add(
							$current,
							"modelElement",
							lv_modelElement_9_0,
							"com.irtsaintexupery.xtext.pseim.Mapping.GraphElementMapping");
						afterParserOrEnumRuleCall();
					}
				)
			)
			(
				(
					{
						newCompositeNode(grammarAccess.getPatternApplicationAccess().getModelElementGraphElementMappingParserRuleCall_6_2_0());
					}
					lv_modelElement_10_0=ruleGraphElementMapping
					{
						if ($current==null) {
							$current = createModelElementForParent(grammarAccess.getPatternApplicationRule());
						}
						add(
							$current,
							"modelElement",
							lv_modelElement_10_0,
							"com.irtsaintexupery.xtext.pseim.Mapping.GraphElementMapping");
						afterParserOrEnumRuleCall();
					}
				)
			)*
		)?
		(
			otherlv_11='ports'
			{
				newLeafNode(otherlv_11, grammarAccess.getPatternApplicationAccess().getPortsKeyword_7_0());
			}
			(
				(
					{
						newCompositeNode(grammarAccess.getPatternApplicationAccess().getPortMappingPortMappingParserRuleCall_7_1_0());
					}
					lv_portMapping_12_0=rulePortMapping
					{
						if ($current==null) {
							$current = createModelElementForParent(grammarAccess.getPatternApplicationRule());
						}
						add(
							$current,
							"portMapping",
							lv_portMapping_12_0,
							"com.irtsaintexupery.xtext.pseim.Mapping.PortMapping");
						afterParserOrEnumRuleCall();
					}
				)
			)
			(
				(
					{
						newCompositeNode(grammarAccess.getPatternApplicationAccess().getPortMappingPortMappingParserRuleCall_7_2_0());
					}
					lv_portMapping_13_0=rulePortMapping
					{
						if ($current==null) {
							$current = createModelElementForParent(grammarAccess.getPatternApplicationRule());
						}
						add(
							$current,
							"portMapping",
							lv_portMapping_13_0,
							"com.irtsaintexupery.xtext.pseim.Mapping.PortMapping");
						afterParserOrEnumRuleCall();
					}
				)
			)*
		)?
		otherlv_14='}'
		{
			newLeafNode(otherlv_14, grammarAccess.getPatternApplicationAccess().getRightCurlyBracketKeyword_8());
		}
	)
;

// Entry rule entryRuleCardinalityValue
entryRuleCardinalityValue returns [EObject current=null]:
	{ newCompositeNode(grammarAccess.getCardinalityValueRule()); }
	iv_ruleCardinalityValue=ruleCardinalityValue
	{ $current=$iv_ruleCardinalityValue.current; }
	EOF;

// Rule CardinalityValue
ruleCardinalityValue returns [EObject current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		(
			(
				{
					if ($current==null) {
						$current = createModelElement(grammarAccess.getCardinalityValueRule());
					}
				}
				{
					newCompositeNode(grammarAccess.getCardinalityValueAccess().getCardinalityElementCardinalityElementCrossReference_0_0());
				}
				ruleQualifiedID
				{
					afterParserOrEnumRuleCall();
				}
			)
		)
		otherlv_1='->'
		{
			newLeafNode(otherlv_1, grammarAccess.getCardinalityValueAccess().getHyphenMinusGreaterThanSignKeyword_1());
		}
		(
			(
				{
					newCompositeNode(grammarAccess.getCardinalityValueAccess().getValueEIntParserRuleCall_2_0());
				}
				lv_value_2_0=ruleEInt
				{
					if ($current==null) {
						$current = createModelElementForParent(grammarAccess.getCardinalityValueRule());
					}
					set(
						$current,
						"value",
						lv_value_2_0,
						"com.irtsaintexupery.xtext.pseim.Mapping.EInt");
					afterParserOrEnumRuleCall();
				}
			)
		)
	)
;

// Entry rule entryRulePortMapping
entryRulePortMapping returns [EObject current=null]:
	{ newCompositeNode(grammarAccess.getPortMappingRule()); }
	iv_rulePortMapping=rulePortMapping
	{ $current=$iv_rulePortMapping.current; }
	EOF;

// Rule PortMapping
rulePortMapping returns [EObject current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		(
			(
				{
					if ($current==null) {
						$current = createModelElement(grammarAccess.getPortMappingRule());
					}
				}
				{
					newCompositeNode(grammarAccess.getPortMappingAccess().getModelPortBorderElementCrossReference_0_0());
				}
				ruleQualifiedID
				{
					afterParserOrEnumRuleCall();
				}
			)
		)
		(
			otherlv_1=','
			{
				newLeafNode(otherlv_1, grammarAccess.getPortMappingAccess().getCommaKeyword_1_0());
			}
			(
				(
					{
						if ($current==null) {
							$current = createModelElement(grammarAccess.getPortMappingRule());
						}
					}
					{
						newCompositeNode(grammarAccess.getPortMappingAccess().getModelPortBorderElementCrossReference_1_1_0());
					}
					ruleQualifiedID
					{
						afterParserOrEnumRuleCall();
					}
				)
			)
		)*
		otherlv_3='->'
		{
			newLeafNode(otherlv_3, grammarAccess.getPortMappingAccess().getHyphenMinusGreaterThanSignKeyword_2());
		}
		(
			(
				{
					if ($current==null) {
						$current = createModelElement(grammarAccess.getPortMappingRule());
					}
				}
				{
					newCompositeNode(grammarAccess.getPortMappingAccess().getPatternPortBorderElementCrossReference_3_0());
				}
				ruleQualifiedID
				{
					afterParserOrEnumRuleCall();
				}
			)
		)
	)
;

// Entry rule entryRuleGraphElementMapping
entryRuleGraphElementMapping returns [EObject current=null]:
	{ newCompositeNode(grammarAccess.getGraphElementMappingRule()); }
	iv_ruleGraphElementMapping=ruleGraphElementMapping
	{ $current=$iv_ruleGraphElementMapping.current; }
	EOF;

// Rule GraphElementMapping
ruleGraphElementMapping returns [EObject current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		(
			(
				{
					if ($current==null) {
						$current = createModelElement(grammarAccess.getGraphElementMappingRule());
					}
				}
				{
					newCompositeNode(grammarAccess.getGraphElementMappingAccess().getModelGraphElementGraphElementCrossReference_0_0());
				}
				ruleQualifiedID
				{
					afterParserOrEnumRuleCall();
				}
			)
		)
		(
			otherlv_1=','
			{
				newLeafNode(otherlv_1, grammarAccess.getGraphElementMappingAccess().getCommaKeyword_1_0());
			}
			(
				(
					{
						if ($current==null) {
							$current = createModelElement(grammarAccess.getGraphElementMappingRule());
						}
					}
					{
						newCompositeNode(grammarAccess.getGraphElementMappingAccess().getModelGraphElementGraphElementCrossReference_1_1_0());
					}
					ruleQualifiedID
					{
						afterParserOrEnumRuleCall();
					}
				)
			)
		)*
		otherlv_3='->'
		{
			newLeafNode(otherlv_3, grammarAccess.getGraphElementMappingAccess().getHyphenMinusGreaterThanSignKeyword_2());
		}
		(
			(
				{
					if ($current==null) {
						$current = createModelElement(grammarAccess.getGraphElementMappingRule());
					}
				}
				{
					newCompositeNode(grammarAccess.getGraphElementMappingAccess().getPatternGraphElementGraphElementCrossReference_3_0());
				}
				ruleQualifiedID
				{
					afterParserOrEnumRuleCall();
				}
			)
		)
	)
;

// Entry rule entryRuleEInt
entryRuleEInt returns [String current=null]:
	{ newCompositeNode(grammarAccess.getEIntRule()); }
	iv_ruleEInt=ruleEInt
	{ $current=$iv_ruleEInt.current.getText(); }
	EOF;

// Rule EInt
ruleEInt returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		(
			kw='-'
			{
				$current.merge(kw);
				newLeafNode(kw, grammarAccess.getEIntAccess().getHyphenMinusKeyword_0());
			}
		)?
		this_INT_1=RULE_INT
		{
			$current.merge(this_INT_1);
		}
		{
			newLeafNode(this_INT_1, grammarAccess.getEIntAccess().getINTTerminalRuleCall_1());
		}
	)
;

// Entry rule entryRuleQualifiedID
entryRuleQualifiedID returns [String current=null]:
	{ newCompositeNode(grammarAccess.getQualifiedIDRule()); }
	iv_ruleQualifiedID=ruleQualifiedID
	{ $current=$iv_ruleQualifiedID.current.getText(); }
	EOF;

// Rule QualifiedID
ruleQualifiedID returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		this_ID_0=RULE_ID
		{
			$current.merge(this_ID_0);
		}
		{
			newLeafNode(this_ID_0, grammarAccess.getQualifiedIDAccess().getIDTerminalRuleCall_0());
		}
		(
			kw='.'
			{
				$current.merge(kw);
				newLeafNode(kw, grammarAccess.getQualifiedIDAccess().getFullStopKeyword_1_0());
			}
			this_ID_2=RULE_ID
			{
				$current.merge(this_ID_2);
			}
			{
				newLeafNode(this_ID_2, grammarAccess.getQualifiedIDAccess().getIDTerminalRuleCall_1_1());
			}
		)*
	)
;

RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;

RULE_INT : ('0'..'9')+;

RULE_STRING : ('"' ('\\' .|~(('\\'|'"')))* '"'|'\'' ('\\' .|~(('\\'|'\'')))* '\'');

RULE_ML_COMMENT : '/*' ( options {greedy=false;} : . )*'*/';

RULE_SL_COMMENT : '//' ~(('\n'|'\r'))* ('\r'? '\n')?;

RULE_WS : (' '|'\t'|'\r'|'\n')+;

RULE_ANY_OTHER : .;
