Skip to content

why can not i match it correctly #1433

Answered by ballcoach12
zrwsmd asked this question in Q&A
Discussion options

You must be logged in to vote

Here are some grammar changes to get you started. I broke inputs and outputs into separate lists and rules, but hopefully you can see the pattern I implemented here.

grammar StructuredText

entry StructuredTextRoot:
    'PROGRAM' name=Identifier
     inputs=Inputs_List
     outputs=Outputs_List*
     
;

Inputs_List infers InputsList: 
	'VAR_INPUT'
		((items += Var_Decl_Init))+
	'END_VAR'	
;

Outputs_List infers OutputsList:
	'VAR_OUTPUT'
		((items += Output_Var_Decl_Init))+
	'END_VAR'	
;

Output_Var_Decl_Init infers VarDeclarationInit:
	variables+=Variable_Primary (',' variables+=Variable_Primary)* ':'
	typeName=Native_Type_Name
	(':=' initialValue= (Constant | Variable_Reference))? ';'
…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@zrwsmd
Comment options

@msujew
Comment options

@zrwsmd
Comment options

@msujew
Comment options

@montymxb
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by zrwsmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants