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

options {
	superClass=AbstractInternalAntlrParser;
}

@lexer::header {
package com.irtsaintexupery.xtext.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.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.emf.common.util.Enumerator;
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.services.PseimGrammarAccess;

}

@parser::members {

 	private PseimGrammarAccess grammarAccess;

    public InternalPseimParser(TokenStream input, PseimGrammarAccess grammarAccess) {
        this(input);
        this.grammarAccess = grammarAccess;
        registerRules(grammarAccess.getGrammar());
    }

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

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

}

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

// Entry rule entryRuleModel
entryRuleModel returns [EObject current=null]:
	{ newCompositeNode(grammarAccess.getModelRule()); }
	iv_ruleModel=ruleModel
	{ $current=$iv_ruleModel.current; }
	EOF;

// Rule Model
ruleModel returns [EObject current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		otherlv_0='model'
		{
			newLeafNode(otherlv_0, grammarAccess.getModelAccess().getModelKeyword_0());
		}
		(
			(
				{
					newCompositeNode(grammarAccess.getModelAccess().getNameEStringParserRuleCall_1_0());
				}
				lv_name_1_0=ruleEString
				{
					if ($current==null) {
						$current = createModelElementForParent(grammarAccess.getModelRule());
					}
					set(
						$current,
						"name",
						lv_name_1_0,
						"com.irtsaintexupery.xtext.Pseim.EString");
					afterParserOrEnumRuleCall();
				}
			)
		)
		(
			otherlv_2='{'
			{
				newLeafNode(otherlv_2, grammarAccess.getModelAccess().getLeftCurlyBracketKeyword_2_0());
			}
			(
				(
					{
						newCompositeNode(grammarAccess.getModelAccess().getModelElementsGraphElementParserRuleCall_2_1_0());
					}
					lv_modelElements_3_0=ruleGraphElement
					{
						if ($current==null) {
							$current = createModelElementForParent(grammarAccess.getModelRule());
						}
						add(
							$current,
							"modelElements",
							lv_modelElements_3_0,
							"com.irtsaintexupery.xtext.Pseim.GraphElement");
						afterParserOrEnumRuleCall();
					}
				)
			)*
			otherlv_4='}'
			{
				newLeafNode(otherlv_4, grammarAccess.getModelAccess().getRightCurlyBracketKeyword_2_2());
			}
		)?
	)
;

// Entry rule entryRuleComponent
entryRuleComponent returns [EObject current=null]:
	{ newCompositeNode(grammarAccess.getComponentRule()); }
	iv_ruleComponent=ruleComponent
	{ $current=$iv_ruleComponent.current; }
	EOF;

// Rule Component
ruleComponent returns [EObject current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		otherlv_0='component'
		{
			newLeafNode(otherlv_0, grammarAccess.getComponentAccess().getComponentKeyword_0());
		}
		(
			(
				lv_name_1_0=RULE_ID
				{
					newLeafNode(lv_name_1_0, grammarAccess.getComponentAccess().getNameIDTerminalRuleCall_1_0());
				}
				{
					if ($current==null) {
						$current = createModelElement(grammarAccess.getComponentRule());
					}
					setWithLastConsumed(
						$current,
						"name",
						lv_name_1_0,
						"org.eclipse.xtext.common.Terminals.ID");
				}
			)
		)
		otherlv_2='('
		{
			newLeafNode(otherlv_2, grammarAccess.getComponentAccess().getLeftParenthesisKeyword_2());
		}
		(
			(
				(
					{
						newCompositeNode(grammarAccess.getComponentAccess().getContentPortParserRuleCall_3_0_0());
					}
					lv_content_3_0=rulePort
					{
						if ($current==null) {
							$current = createModelElementForParent(grammarAccess.getComponentRule());
						}
						add(
							$current,
							"content",
							lv_content_3_0,
							"com.irtsaintexupery.xtext.Pseim.Port");
						afterParserOrEnumRuleCall();
					}
				)
			)
			(
				otherlv_4=','
				{
					newLeafNode(otherlv_4, grammarAccess.getComponentAccess().getCommaKeyword_3_1_0());
				}
				(
					(
						{
							newCompositeNode(grammarAccess.getComponentAccess().getContentPortParserRuleCall_3_1_1_0());
						}
						lv_content_5_0=rulePort
						{
							if ($current==null) {
								$current = createModelElementForParent(grammarAccess.getComponentRule());
							}
							add(
								$current,
								"content",
								lv_content_5_0,
								"com.irtsaintexupery.xtext.Pseim.Port");
							afterParserOrEnumRuleCall();
						}
					)
				)
			)*
		)?
		otherlv_6=')'
		{
			newLeafNode(otherlv_6, grammarAccess.getComponentAccess().getRightParenthesisKeyword_4());
		}
		(
			otherlv_7='{'
			{
				newLeafNode(otherlv_7, grammarAccess.getComponentAccess().getLeftCurlyBracketKeyword_5_0());
			}
			(
				(
					{
						newCompositeNode(grammarAccess.getComponentAccess().getContentGraphElementParserRuleCall_5_1_0());
					}
					lv_content_8_0=ruleGraphElement
					{
						if ($current==null) {
							$current = createModelElementForParent(grammarAccess.getComponentRule());
						}
						add(
							$current,
							"content",
							lv_content_8_0,
							"com.irtsaintexupery.xtext.Pseim.GraphElement");
						afterParserOrEnumRuleCall();
					}
				)
			)*
			otherlv_9='}'
			{
				newLeafNode(otherlv_9, grammarAccess.getComponentAccess().getRightCurlyBracketKeyword_5_2());
			}
		)?
	)
;

// Entry rule entryRulePort
entryRulePort returns [EObject current=null]:
	{ newCompositeNode(grammarAccess.getPortRule()); }
	iv_rulePort=rulePort
	{ $current=$iv_rulePort.current; }
	EOF;

// Rule Port
rulePort returns [EObject current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		(
			(
				{
					newCompositeNode(grammarAccess.getPortAccess().getDirectionPortDirectionEnumRuleCall_0_0());
				}
				lv_direction_0_0=rulePortDirection
				{
					if ($current==null) {
						$current = createModelElementForParent(grammarAccess.getPortRule());
					}
					set(
						$current,
						"direction",
						lv_direction_0_0,
						"com.irtsaintexupery.xtext.Pseim.PortDirection");
					afterParserOrEnumRuleCall();
				}
			)
		)
		(
			(
				lv_name_1_0=RULE_ID
				{
					newLeafNode(lv_name_1_0, grammarAccess.getPortAccess().getNameIDTerminalRuleCall_1_0());
				}
				{
					if ($current==null) {
						$current = createModelElement(grammarAccess.getPortRule());
					}
					setWithLastConsumed(
						$current,
						"name",
						lv_name_1_0,
						"org.eclipse.xtext.common.Terminals.ID");
				}
			)
		)
	)
;

// Entry rule entryRuleLink
entryRuleLink returns [EObject current=null]:
	{ newCompositeNode(grammarAccess.getLinkRule()); }
	iv_ruleLink=ruleLink
	{ $current=$iv_ruleLink.current; }
	EOF;

// Rule Link
ruleLink returns [EObject current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		(
			(
				{
					if ($current==null) {
						$current = createModelElement(grammarAccess.getLinkRule());
					}
				}
				{
					newCompositeNode(grammarAccess.getLinkAccess().getSrcPortCrossReference_0_0());
				}
				ruleQualifiedID
				{
					afterParserOrEnumRuleCall();
				}
			)
		)
		otherlv_1='->'
		{
			newLeafNode(otherlv_1, grammarAccess.getLinkAccess().getHyphenMinusGreaterThanSignKeyword_1());
		}
		(
			(
				{
					if ($current==null) {
						$current = createModelElement(grammarAccess.getLinkRule());
					}
				}
				{
					newCompositeNode(grammarAccess.getLinkAccess().getDstPortCrossReference_2_0());
				}
				ruleQualifiedID
				{
					afterParserOrEnumRuleCall();
				}
			)
		)
	)
;

// Entry rule entryRuleGraphElement
entryRuleGraphElement returns [EObject current=null]:
	{ newCompositeNode(grammarAccess.getGraphElementRule()); }
	iv_ruleGraphElement=ruleGraphElement
	{ $current=$iv_ruleGraphElement.current; }
	EOF;

// Rule GraphElement
ruleGraphElement returns [EObject current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		{
			newCompositeNode(grammarAccess.getGraphElementAccess().getComponentParserRuleCall_0());
		}
		this_Component_0=ruleComponent
		{
			$current = $this_Component_0.current;
			afterParserOrEnumRuleCall();
		}
		    |
		{
			newCompositeNode(grammarAccess.getGraphElementAccess().getLinkParserRuleCall_1());
		}
		this_Link_1=ruleLink
		{
			$current = $this_Link_1.current;
			afterParserOrEnumRuleCall();
		}
	)
;

// 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());
			}
		)*
	)
;

// Entry rule entryRuleEString
entryRuleEString returns [String current=null]:
	{ newCompositeNode(grammarAccess.getEStringRule()); }
	iv_ruleEString=ruleEString
	{ $current=$iv_ruleEString.current.getText(); }
	EOF;

// Rule EString
ruleEString returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		this_STRING_0=RULE_STRING
		{
			$current.merge(this_STRING_0);
		}
		{
			newLeafNode(this_STRING_0, grammarAccess.getEStringAccess().getSTRINGTerminalRuleCall_0());
		}
		    |
		this_ID_1=RULE_ID
		{
			$current.merge(this_ID_1);
		}
		{
			newLeafNode(this_ID_1, grammarAccess.getEStringAccess().getIDTerminalRuleCall_1());
		}
	)
;

// Entry rule entryRuleIntegerProperty
entryRuleIntegerProperty returns [EObject current=null]:
	{ newCompositeNode(grammarAccess.getIntegerPropertyRule()); }
	iv_ruleIntegerProperty=ruleIntegerProperty
	{ $current=$iv_ruleIntegerProperty.current; }
	EOF;

// Rule IntegerProperty
ruleIntegerProperty returns [EObject current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		otherlv_0='IntegerProperty'
		{
			newLeafNode(otherlv_0, grammarAccess.getIntegerPropertyAccess().getIntegerPropertyKeyword_0());
		}
		otherlv_1='{'
		{
			newLeafNode(otherlv_1, grammarAccess.getIntegerPropertyAccess().getLeftCurlyBracketKeyword_1());
		}
		otherlv_2='key'
		{
			newLeafNode(otherlv_2, grammarAccess.getIntegerPropertyAccess().getKeyKeyword_2());
		}
		(
			(
				{
					newCompositeNode(grammarAccess.getIntegerPropertyAccess().getKeyEStringParserRuleCall_3_0());
				}
				lv_key_3_0=ruleEString
				{
					if ($current==null) {
						$current = createModelElementForParent(grammarAccess.getIntegerPropertyRule());
					}
					set(
						$current,
						"key",
						lv_key_3_0,
						"com.irtsaintexupery.xtext.Pseim.EString");
					afterParserOrEnumRuleCall();
				}
			)
		)
		otherlv_4='value'
		{
			newLeafNode(otherlv_4, grammarAccess.getIntegerPropertyAccess().getValueKeyword_4());
		}
		(
			(
				{
					newCompositeNode(grammarAccess.getIntegerPropertyAccess().getValueEIntParserRuleCall_5_0());
				}
				lv_value_5_0=ruleEInt
				{
					if ($current==null) {
						$current = createModelElementForParent(grammarAccess.getIntegerPropertyRule());
					}
					set(
						$current,
						"value",
						lv_value_5_0,
						"com.irtsaintexupery.xtext.Pseim.EInt");
					afterParserOrEnumRuleCall();
				}
			)
		)
		otherlv_6='}'
		{
			newLeafNode(otherlv_6, grammarAccess.getIntegerPropertyAccess().getRightCurlyBracketKeyword_6());
		}
	)
;

// Entry rule entryRuleStringProperty
entryRuleStringProperty returns [EObject current=null]:
	{ newCompositeNode(grammarAccess.getStringPropertyRule()); }
	iv_ruleStringProperty=ruleStringProperty
	{ $current=$iv_ruleStringProperty.current; }
	EOF;

// Rule StringProperty
ruleStringProperty returns [EObject current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		otherlv_0='StringProperty'
		{
			newLeafNode(otherlv_0, grammarAccess.getStringPropertyAccess().getStringPropertyKeyword_0());
		}
		otherlv_1='{'
		{
			newLeafNode(otherlv_1, grammarAccess.getStringPropertyAccess().getLeftCurlyBracketKeyword_1());
		}
		otherlv_2='key'
		{
			newLeafNode(otherlv_2, grammarAccess.getStringPropertyAccess().getKeyKeyword_2());
		}
		(
			(
				{
					newCompositeNode(grammarAccess.getStringPropertyAccess().getKeyEStringParserRuleCall_3_0());
				}
				lv_key_3_0=ruleEString
				{
					if ($current==null) {
						$current = createModelElementForParent(grammarAccess.getStringPropertyRule());
					}
					set(
						$current,
						"key",
						lv_key_3_0,
						"com.irtsaintexupery.xtext.Pseim.EString");
					afterParserOrEnumRuleCall();
				}
			)
		)
		otherlv_4='value'
		{
			newLeafNode(otherlv_4, grammarAccess.getStringPropertyAccess().getValueKeyword_4());
		}
		(
			(
				{
					newCompositeNode(grammarAccess.getStringPropertyAccess().getValueEStringParserRuleCall_5_0());
				}
				lv_value_5_0=ruleEString
				{
					if ($current==null) {
						$current = createModelElementForParent(grammarAccess.getStringPropertyRule());
					}
					set(
						$current,
						"value",
						lv_value_5_0,
						"com.irtsaintexupery.xtext.Pseim.EString");
					afterParserOrEnumRuleCall();
				}
			)
		)
		otherlv_6='}'
		{
			newLeafNode(otherlv_6, grammarAccess.getStringPropertyAccess().getRightCurlyBracketKeyword_6());
		}
	)
;

// Entry rule entryRuleBooleanProperty
entryRuleBooleanProperty returns [EObject current=null]:
	{ newCompositeNode(grammarAccess.getBooleanPropertyRule()); }
	iv_ruleBooleanProperty=ruleBooleanProperty
	{ $current=$iv_ruleBooleanProperty.current; }
	EOF;

// Rule BooleanProperty
ruleBooleanProperty returns [EObject current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		(
			(
				lv_value_0_0='value'
				{
					newLeafNode(lv_value_0_0, grammarAccess.getBooleanPropertyAccess().getValueValueKeyword_0_0());
				}
				{
					if ($current==null) {
						$current = createModelElement(grammarAccess.getBooleanPropertyRule());
					}
					setWithLastConsumed($current, "value", true, "value");
				}
			)
		)
		otherlv_1='BooleanProperty'
		{
			newLeafNode(otherlv_1, grammarAccess.getBooleanPropertyAccess().getBooleanPropertyKeyword_1());
		}
		otherlv_2='{'
		{
			newLeafNode(otherlv_2, grammarAccess.getBooleanPropertyAccess().getLeftCurlyBracketKeyword_2());
		}
		otherlv_3='key'
		{
			newLeafNode(otherlv_3, grammarAccess.getBooleanPropertyAccess().getKeyKeyword_3());
		}
		(
			(
				{
					newCompositeNode(grammarAccess.getBooleanPropertyAccess().getKeyEStringParserRuleCall_4_0());
				}
				lv_key_4_0=ruleEString
				{
					if ($current==null) {
						$current = createModelElementForParent(grammarAccess.getBooleanPropertyRule());
					}
					set(
						$current,
						"key",
						lv_key_4_0,
						"com.irtsaintexupery.xtext.Pseim.EString");
					afterParserOrEnumRuleCall();
				}
			)
		)
		otherlv_5='}'
		{
			newLeafNode(otherlv_5, grammarAccess.getBooleanPropertyAccess().getRightCurlyBracketKeyword_5());
		}
	)
;

// Entry rule entryRuleReferenceProperty
entryRuleReferenceProperty returns [EObject current=null]:
	{ newCompositeNode(grammarAccess.getReferencePropertyRule()); }
	iv_ruleReferenceProperty=ruleReferenceProperty
	{ $current=$iv_ruleReferenceProperty.current; }
	EOF;

// Rule ReferenceProperty
ruleReferenceProperty returns [EObject current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		otherlv_0='ReferenceProperty'
		{
			newLeafNode(otherlv_0, grammarAccess.getReferencePropertyAccess().getReferencePropertyKeyword_0());
		}
		otherlv_1='{'
		{
			newLeafNode(otherlv_1, grammarAccess.getReferencePropertyAccess().getLeftCurlyBracketKeyword_1());
		}
		otherlv_2='key'
		{
			newLeafNode(otherlv_2, grammarAccess.getReferencePropertyAccess().getKeyKeyword_2());
		}
		(
			(
				{
					newCompositeNode(grammarAccess.getReferencePropertyAccess().getKeyEStringParserRuleCall_3_0());
				}
				lv_key_3_0=ruleEString
				{
					if ($current==null) {
						$current = createModelElementForParent(grammarAccess.getReferencePropertyRule());
					}
					set(
						$current,
						"key",
						lv_key_3_0,
						"com.irtsaintexupery.xtext.Pseim.EString");
					afterParserOrEnumRuleCall();
				}
			)
		)
		otherlv_4='ref'
		{
			newLeafNode(otherlv_4, grammarAccess.getReferencePropertyAccess().getRefKeyword_4());
		}
		(
			(
				{
					if ($current==null) {
						$current = createModelElement(grammarAccess.getReferencePropertyRule());
					}
				}
				{
					newCompositeNode(grammarAccess.getReferencePropertyAccess().getRefPropertyHolderCrossReference_5_0());
				}
				ruleEString
				{
					afterParserOrEnumRuleCall();
				}
			)
		)
		otherlv_6='}'
		{
			newLeafNode(otherlv_6, grammarAccess.getReferencePropertyAccess().getRightCurlyBracketKeyword_6());
		}
	)
;

// 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());
		}
	)
;

// Rule PortDirection
rulePortDirection returns [Enumerator current=null]
@init {
	enterRule();
}
@after {
	leaveRule();
}:
	(
		(
			enumLiteral_0='unspec'
			{
				$current = grammarAccess.getPortDirectionAccess().getUNSPECIFIEDEnumLiteralDeclaration_0().getEnumLiteral().getInstance();
				newLeafNode(enumLiteral_0, grammarAccess.getPortDirectionAccess().getUNSPECIFIEDEnumLiteralDeclaration_0());
			}
		)
		    |
		(
			enumLiteral_1='in'
			{
				$current = grammarAccess.getPortDirectionAccess().getINEnumLiteralDeclaration_1().getEnumLiteral().getInstance();
				newLeafNode(enumLiteral_1, grammarAccess.getPortDirectionAccess().getINEnumLiteralDeclaration_1());
			}
		)
		    |
		(
			enumLiteral_2='out'
			{
				$current = grammarAccess.getPortDirectionAccess().getOUTEnumLiteralDeclaration_2().getEnumLiteral().getInstance();
				newLeafNode(enumLiteral_2, grammarAccess.getPortDirectionAccess().getOUTEnumLiteralDeclaration_2());
			}
		)
		    |
		(
			enumLiteral_3='inout'
			{
				$current = grammarAccess.getPortDirectionAccess().getINOUTEnumLiteralDeclaration_3().getEnumLiteral().getInstance();
				newLeafNode(enumLiteral_3, grammarAccess.getPortDirectionAccess().getINOUTEnumLiteralDeclaration_3());
			}
		)
	)
;

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 : .;
