/* * generated by Xtext */ grammar InternalP4Dsl; options { superClass=AbstractInternalAntlrParser; } @lexer::header { package com.perforce.example.p4dsl.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.perforce.example.p4dsl.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.perforce.example.p4dsl.services.P4DslGrammarAccess; } @parser::members { private P4DslGrammarAccess grammarAccess; public InternalP4DslParser(TokenStream input, P4DslGrammarAccess grammarAccess) { this(input); this.grammarAccess = grammarAccess; registerRules(grammarAccess.getGrammar()); } @Override protected String getFirstRuleName() { return "Model"; } @Override protected P4DslGrammarAccess 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(); }: ( ( { newCompositeNode(grammarAccess.getModelAccess().getCommandCommandParserRuleCall_0()); } lv_command_0_0=ruleCommand { if ($current==null) { $current = createModelElementForParent(grammarAccess.getModelRule()); } add( $current, "command", lv_command_0_0, "Command"); afterParserOrEnumRuleCall(); } ) )* ; // Entry rule entryRuleCommand entryRuleCommand returns [EObject current=null] : { newCompositeNode(grammarAccess.getCommandRule()); } iv_ruleCommand=ruleCommand { $current=$iv_ruleCommand.current; } EOF ; // Rule Command ruleCommand returns [EObject current=null] @init { enterRule(); } @after { leaveRule(); }: ( otherlv_0='p4' { newLeafNode(otherlv_0, grammarAccess.getCommandAccess().getP4Keyword_0()); } { newCompositeNode(grammarAccess.getCommandAccess().getP4CommandParserRuleCall_1()); } this_P4Command_1=ruleP4Command { $current = $this_P4Command_1.current; afterParserOrEnumRuleCall(); } ) ; // Entry rule entryRuleP4Command entryRuleP4Command returns [EObject current=null] : { newCompositeNode(grammarAccess.getP4CommandRule()); } iv_ruleP4Command=ruleP4Command { $current=$iv_ruleP4Command.current; } EOF ; // Rule P4Command ruleP4Command returns [EObject current=null] @init { enterRule(); } @after { leaveRule(); }: ( { newCompositeNode(grammarAccess.getP4CommandAccess().getPUCFlagParserRuleCall_0()); } this_PUCFlag_0=rulePUCFlag { $current = $this_PUCFlag_0.current; afterParserOrEnumRuleCall(); } | { newCompositeNode(grammarAccess.getP4CommandAccess().getFileBasedCommandParserRuleCall_1()); } this_FileBasedCommand_1=ruleFileBasedCommand { $current = $this_FileBasedCommand_1.current; afterParserOrEnumRuleCall(); } ) ; // Entry rule entryRulePUCFlag entryRulePUCFlag returns [EObject current=null] : { newCompositeNode(grammarAccess.getPUCFlagRule()); } iv_rulePUCFlag=rulePUCFlag { $current=$iv_rulePUCFlag.current; } EOF ; // Rule PUCFlag rulePUCFlag returns [EObject current=null] @init { enterRule(); } @after { leaveRule(); }: ( { newCompositeNode(grammarAccess.getPUCFlagAccess().getPortParserRuleCall_0()); } this_Port_0=rulePort { $current = $this_Port_0.current; afterParserOrEnumRuleCall(); } | { newCompositeNode(grammarAccess.getPUCFlagAccess().getUserParserRuleCall_1()); } this_User_1=ruleUser { $current = $this_User_1.current; afterParserOrEnumRuleCall(); } | { newCompositeNode(grammarAccess.getPUCFlagAccess().getClientParserRuleCall_2()); } this_Client_2=ruleClient { $current = $this_Client_2.current; afterParserOrEnumRuleCall(); } ) ; // 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(); }: ( otherlv_0='-p' { newLeafNode(otherlv_0, grammarAccess.getPortAccess().getPKeyword_0()); } ( ( { newCompositeNode(grammarAccess.getPortAccess().getNameP4PORTParserRuleCall_1_0()); } lv_name_1_0=ruleP4PORT { if ($current==null) { $current = createModelElementForParent(grammarAccess.getPortRule()); } set( $current, "name", lv_name_1_0, "P4PORT"); afterParserOrEnumRuleCall(); } ) )( ( { newCompositeNode(grammarAccess.getPortAccess().getP4commandP4CommandParserRuleCall_2_0()); } lv_p4command_2_0=ruleP4Command { if ($current==null) { $current = createModelElementForParent(grammarAccess.getPortRule()); } add( $current, "p4command", lv_p4command_2_0, "P4Command"); afterParserOrEnumRuleCall(); } ) )) ; // Entry rule entryRuleUser entryRuleUser returns [EObject current=null] : { newCompositeNode(grammarAccess.getUserRule()); } iv_ruleUser=ruleUser { $current=$iv_ruleUser.current; } EOF ; // Rule User ruleUser returns [EObject current=null] @init { enterRule(); } @after { leaveRule(); }: ( otherlv_0='-u' { newLeafNode(otherlv_0, grammarAccess.getUserAccess().getUKeyword_0()); } ( ( lv_name_1_0=RULE_ID { newLeafNode(lv_name_1_0, grammarAccess.getUserAccess().getNameIDTerminalRuleCall_1_0()); } { if ($current==null) { $current = createModelElement(grammarAccess.getUserRule()); } setWithLastConsumed( $current, "name", lv_name_1_0, "ID"); } ) )( ( { newCompositeNode(grammarAccess.getUserAccess().getP4commandP4CommandParserRuleCall_2_0()); } lv_p4command_2_0=ruleP4Command { if ($current==null) { $current = createModelElementForParent(grammarAccess.getUserRule()); } add( $current, "p4command", lv_p4command_2_0, "P4Command"); afterParserOrEnumRuleCall(); } ) )) ; // Entry rule entryRuleClient entryRuleClient returns [EObject current=null] : { newCompositeNode(grammarAccess.getClientRule()); } iv_ruleClient=ruleClient { $current=$iv_ruleClient.current; } EOF ; // Rule Client ruleClient returns [EObject current=null] @init { enterRule(); } @after { leaveRule(); }: ( otherlv_0='-c' { newLeafNode(otherlv_0, grammarAccess.getClientAccess().getCKeyword_0()); } ( ( lv_name_1_0=RULE_ID { newLeafNode(lv_name_1_0, grammarAccess.getClientAccess().getNameIDTerminalRuleCall_1_0()); } { if ($current==null) { $current = createModelElement(grammarAccess.getClientRule()); } setWithLastConsumed( $current, "name", lv_name_1_0, "ID"); } ) )( ( { newCompositeNode(grammarAccess.getClientAccess().getP4commandP4CommandParserRuleCall_2_0()); } lv_p4command_2_0=ruleP4Command { if ($current==null) { $current = createModelElementForParent(grammarAccess.getClientRule()); } add( $current, "p4command", lv_p4command_2_0, "P4Command"); afterParserOrEnumRuleCall(); } ) )) ; // Entry rule entryRuleFileBasedCommand entryRuleFileBasedCommand returns [EObject current=null] : { newCompositeNode(grammarAccess.getFileBasedCommandRule()); } iv_ruleFileBasedCommand=ruleFileBasedCommand { $current=$iv_ruleFileBasedCommand.current; } EOF ; // Rule FileBasedCommand ruleFileBasedCommand returns [EObject current=null] @init { enterRule(); } @after { leaveRule(); }: ( { newCompositeNode(grammarAccess.getFileBasedCommandAccess().getAddParserRuleCall_0()); } this_Add_0=ruleAdd { $current = $this_Add_0.current; afterParserOrEnumRuleCall(); } | { newCompositeNode(grammarAccess.getFileBasedCommandAccess().getEditParserRuleCall_1()); } this_Edit_1=ruleEdit { $current = $this_Edit_1.current; afterParserOrEnumRuleCall(); } | { newCompositeNode(grammarAccess.getFileBasedCommandAccess().getDeleteParserRuleCall_2()); } this_Delete_2=ruleDelete { $current = $this_Delete_2.current; afterParserOrEnumRuleCall(); } ) ; // Entry rule entryRuleAdd entryRuleAdd returns [EObject current=null] : { newCompositeNode(grammarAccess.getAddRule()); } iv_ruleAdd=ruleAdd { $current=$iv_ruleAdd.current; } EOF ; // Rule Add ruleAdd returns [EObject current=null] @init { enterRule(); } @after { leaveRule(); }: ( otherlv_0='add' { newLeafNode(otherlv_0, grammarAccess.getAddAccess().getAddKeyword_0()); } ( ( { newCompositeNode(grammarAccess.getAddAccess().getNameFILEParserRuleCall_1_0()); } lv_name_1_0=ruleFILE { if ($current==null) { $current = createModelElementForParent(grammarAccess.getAddRule()); } set( $current, "name", lv_name_1_0, "FILE"); afterParserOrEnumRuleCall(); } ) )) ; // Entry rule entryRuleEdit entryRuleEdit returns [EObject current=null] : { newCompositeNode(grammarAccess.getEditRule()); } iv_ruleEdit=ruleEdit { $current=$iv_ruleEdit.current; } EOF ; // Rule Edit ruleEdit returns [EObject current=null] @init { enterRule(); } @after { leaveRule(); }: ( otherlv_0='edit' { newLeafNode(otherlv_0, grammarAccess.getEditAccess().getEditKeyword_0()); } ( ( { newCompositeNode(grammarAccess.getEditAccess().getNameFILEParserRuleCall_1_0()); } lv_name_1_0=ruleFILE { if ($current==null) { $current = createModelElementForParent(grammarAccess.getEditRule()); } set( $current, "name", lv_name_1_0, "FILE"); afterParserOrEnumRuleCall(); } ) )) ; // Entry rule entryRuleDelete entryRuleDelete returns [EObject current=null] : { newCompositeNode(grammarAccess.getDeleteRule()); } iv_ruleDelete=ruleDelete { $current=$iv_ruleDelete.current; } EOF ; // Rule Delete ruleDelete returns [EObject current=null] @init { enterRule(); } @after { leaveRule(); }: ( otherlv_0='delete' { newLeafNode(otherlv_0, grammarAccess.getDeleteAccess().getDeleteKeyword_0()); } ( ( { newCompositeNode(grammarAccess.getDeleteAccess().getNameFILEParserRuleCall_1_0()); } lv_name_1_0=ruleFILE { if ($current==null) { $current = createModelElementForParent(grammarAccess.getDeleteRule()); } set( $current, "name", lv_name_1_0, "FILE"); afterParserOrEnumRuleCall(); } ) )) ; // Entry rule entryRuleP4PORT entryRuleP4PORT returns [String current=null] : { newCompositeNode(grammarAccess.getP4PORTRule()); } iv_ruleP4PORT=ruleP4PORT { $current=$iv_ruleP4PORT.current.getText(); } EOF ; // Rule P4PORT ruleP4PORT returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()] @init { enterRule(); } @after { leaveRule(); }: ( this_ID_0=RULE_ID { $current.merge(this_ID_0); } { newLeafNode(this_ID_0, grammarAccess.getP4PORTAccess().getIDTerminalRuleCall_0()); } kw=':' { $current.merge(kw); newLeafNode(kw, grammarAccess.getP4PORTAccess().getColonKeyword_1()); } this_INT_2=RULE_INT { $current.merge(this_INT_2); } { newLeafNode(this_INT_2, grammarAccess.getP4PORTAccess().getINTTerminalRuleCall_2()); } ) ; // Entry rule entryRuleFILE entryRuleFILE returns [String current=null] : { newCompositeNode(grammarAccess.getFILERule()); } iv_ruleFILE=ruleFILE { $current=$iv_ruleFILE.current.getText(); } EOF ; // Rule FILE ruleFILE returns [AntlrDatatypeRuleToken current=new AntlrDatatypeRuleToken()] @init { enterRule(); } @after { leaveRule(); }: ( this_ID_0=RULE_ID { $current.merge(this_ID_0); } { newLeafNode(this_ID_0, grammarAccess.getFILEAccess().getIDTerminalRuleCall_0()); } |( this_ID_1=RULE_ID { $current.merge(this_ID_1); } { newLeafNode(this_ID_1, grammarAccess.getFILEAccess().getIDTerminalRuleCall_1_0()); } kw='.' { $current.merge(kw); newLeafNode(kw, grammarAccess.getFILEAccess().getFullStopKeyword_1_1()); } this_ID_3=RULE_ID { $current.merge(this_ID_3); } { newLeafNode(this_ID_3, grammarAccess.getFILEAccess().getIDTerminalRuleCall_1_2()); } )) ; RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; RULE_INT : ('0'..'9')+; RULE_STRING : ('"' ('\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|'\''|'\\')|~(('\\'|'"')))* '"'|'\'' ('\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|'\''|'\\')|~(('\\'|'\'')))* '\''); RULE_ML_COMMENT : '/*' ( options {greedy=false;} : . )*'*/'; RULE_SL_COMMENT : '//' ~(('\n'|'\r'))* ('\r'? '\n')?; RULE_WS : (' '|'\t'|'\r'|'\n')+; RULE_ANY_OTHER : .;