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

Not able to use INITIAL and an exclusive state #19

Open
vihanb opened this issue Jan 22, 2017 · 3 comments
Open

Not able to use INITIAL and an exclusive state #19

vihanb opened this issue Jan 22, 2017 · 3 comments

Comments

@vihanb
Copy link

vihanb commented Jan 22, 2017

I have this line which causes an error:

<INITIAL,MULTILINE_COMMENT>"/*"                    this.begin("MUTLILINE_COMMMENT");

where MULTILINE_COMMENT is successfully defined with %x MULTILINE_COMMENT

/usr/local/lib/node_modules/jison/node_modules/jison-lex/regexp-lexer.js:42
                startConditions[conditions[k]].rules.push(i);
                                              ^

TypeError: Cannot read property 'rules' of undefined
    at prepareRules (/usr/local/lib/node_modules/jison/node_modules/jison-lex/regexp-lexer.js:42:47)
    at Object.buildActions (/usr/local/lib/node_modules/jison/node_modules/jison-lex/regexp-lexer.js:112:18)
    at processGrammar (/usr/local/lib/node_modules/jison/node_modules/jison-lex/regexp-lexer.js:484:39)
    at RegExpLexer (/usr/local/lib/node_modules/jison/node_modules/jison-lex/regexp-lexer.js:122:16)
    at o.constructor.Jison_Generator [as constructor] (/usr/local/lib/node_modules/jison/lib/jison.js:111:22)
    at o.constructor.(anonymous function) [as constructor] (/usr/local/lib/node_modules/jison/lib/util/typal.js:23:28)
    at new o.constructor (/usr/local/lib/node_modules/jison/lib/util/typal.js:77:70)
    at new Jison_Generator (/usr/local/lib/node_modules/jison/lib/jison.js:1910:20)
    at Object.generateParserString (/usr/local/lib/node_modules/jison/lib/cli.js:153:21)
    at processGrammar (/usr/local/lib/node_modules/jison/lib/cli.js:72:22)
@GerHobbelt
Copy link
Contributor

2 typos in your code:

this.begin("MUTLILINE_COMMMENT");

should be

this.begin("MULTILINE_COMMENT");

Thought: For improved robustness, jison should maybe check/test for this type of user-coder error in the lexer generator, so that this type of error is easier to diagnose for everyone.

@vihanb
Copy link
Author

vihanb commented Feb 10, 2017

Oh my god how did I miss this. (This is not first time I have made such mistake)

@GerHobbelt
Copy link
Contributor

No sweat; as said, the current lexer engine doesn't exactly help to catch this type of mistake when using the jison tool.

A stop-gap change in the engine is coming up to help catch this type of mistake at runtime at least as it happens quite easily during grammar development.
Should surface in about a week in the GerHobbelt/jison fork + a pull req here:
https://github.com/GerHobbelt/jison

GerHobbelt added a commit to GerHobbelt/jison-lex that referenced this issue Feb 10, 2017
…he lexer robust against user-programmer bugs such as zaach#19
GerHobbelt added a commit to GerHobbelt/jison that referenced this issue Feb 20, 2017
…: this is testing the robustness of the jison-generated lexer engine.
GerHobbelt added a commit to GerHobbelt/jison that referenced this issue Feb 20, 2017
…: this is testing the robustness of the jison-generated lexer engine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants