zaach / jison

Bison in JavaScript.
http://jison.org
4.33k stars 448 forks source link

Using "constructor" as a literal causes a parse error #387

Open jarble opened 5 years ago

jarble commented 5 years ago

While I was testing Jison here, I found that Jison was unable to generate a parser from this simple grammar, since it contains the literal "constructor":

/* lexical grammar */
%lex
%%

\s+                   /* skip whitespace */
"constructor"         return 'constructor'
<<EOF>>               return 'EOF'
.                     return 'INVALID'

/lex

/* operator associations and precedence */

%start expressions

%% /* language grammar */

expressions
    :  "constructor" EOF
        {return "constructor";}
    ;

It works when I replace "constructor" with "constructor1", but it can't generate a parser from the grammar above. Is this a bug?