I’m certainly no bison expert, but something like the following might be a starting point:
start: semicolon_terminated_statements ; semicolon_terminated_statements: /* empty */ | semicolon_terminated_statements semicolon_terminated_statement | semicolon_terminated_statements block ; block: '{' semicolon_terminated_statements '}' | '{' semicolon_terminated_statements decl '}' ; semicolon_terminated_statement: decl ';' | array_decl ';' | array_decl ; decl: VAR INTEGER NAME ; array_decl: VAR INTEGER NAME '[' NUMBER ']' '=' braced_initializer ; braced_initializer: '{' /* initialization */ '}' ; Derek Clegg > On Nov 15, 2014, at 6:25 AM, Matthias Simon <m...@5nord.de> wrote: > > Hi, > > I am struggling with some semicolon rules for some time now. In this language > (TTCN3) statements end with an mandatory semicolon, except there is a curly > bracket around. Example: > > // -------------8<-------------[SNIP!] > { > var integer a; > var integer b[2] := { 23, 5 } > var integer c > } > // ------------->8-------------[SNAP!] > > > Declaration for variable b does not require a terminating semicolon, due to > closing bracket of its initialization. Also declaration of variable c needs > no semicolon due to the closing block. > > TTCN3's grammar is already quite complex, therefore I made semicolon _always_ > mandatory and patched the lexer to `inject' semicolons when they were > expected by bison. This turned out to be quite hacky, so I am a little > clueless here. Perhaps you have some ideas how to solve this nicely? > > Cheers! > > Matthias > > _______________________________________________ > help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison