Hi I am trying to implement a parser for a simple language with grammar like this.
program ::= "program" declarations "begin" statements "end"
declaration ::= "var" ident "as" type
type ::= "string" | "int"
I have the first two done, how would I write the type grammar?
program( prog( DECLS, STATS ) ) --> [ 'program' ], declarations( DECLS ), [ 'begin' ], statements( STATS ), [ 'end' ].
declaration( decl( IDENT, TYPE ) ) --> [ 'var' ], ident( IDENT ), [ 'as' ], type( TYPE ).
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.