help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to implement optional semicolon rules


From: Matthias Simon
Subject: Re: How to implement optional semicolon rules
Date: Wed, 19 Nov 2014 00:53:07 +0100
User-agent: Roundcube Webmail/0.7.1

Thank you for all your answers. The language I am trying to implement is quite complex, unfortunately. It has various --and also optional-- block-like structures. Hence I personally would prefer setting the context variable for the lexer, over rearranging the whole grammar just for this nagging semicolon-rule. What I tried was following:

Block
    : '{' Statements '}'
    ;

Statements
    :            Statement Semicolon
    | Statements Statement Semicolon
    ;

Semicolon
    : { driver.expect_semicolon = 1; } ';'
    ;

If expect_semicolon is set and the lexer reads a '}', it then will unput this character and return a ';' instead. My problem is, expect_semicolon is set _after_ the next is already read and the ';'-injection is too late. What am I missing?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]