Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty alternative in rule causes syntax error in *Parser.py for Python2/3 targets #1252

Closed
robinkjoy opened this issue Aug 10, 2016 · 2 comments

Comments

@robinkjoy
Copy link

Sample grammar

grammar Test;

tokens { ID }
root
  : ( ID
    |
    ) SEMI EOF
  ;
SEMI   : ';' ;
WS : [ \t\r\n]+ -> skip ;

this generates following snippet in TestParser.py for python2 and 3

            if token in [SystemRDLParser.ID]:
                self.state = 2
                self.match(SystemRDLParser.ID)

            elif token in [SystemRDLParser.SEMI]:

            else:
                raise NoViableAltException(self)

Here elif is empty resulting in syntax error. Maybe pass is missing?

@renatahodovan
Copy link
Contributor

@robinkjoy: yeah, there is already a PR submitted to fix this: #1172

@parrt
Copy link
Member

parrt commented Nov 22, 2016

Fixed by #1172

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants