Open jdvorak2001 opened 7 years ago
Looks like you're using my jison fork.
You're triggering a bug in the parser generator feature-analysis/optimization code, where jison detects your grammar doesn't have any custom action code, hence the entire performAction
function can be discarded (as nothing will be happening in there) and thus speed up parsing as that's one less function call+parameters-passing activity per reduce state at run-time.
Looks like the 'code stripper' doesn't properly remove the this.performAction.call(...)
code from the generated parser, produced by jison.
Assuming of course that I guessed correct above and you are using my fork/clone, which version are you running?
Latest = 0.4.18-174
forget what I said
Had a look while I was working on https://github.com/GerHobbelt/jison and found that the grammar you attached at least it not a viable jison grammar.
First of all, the (...)
parts in the grammar make this an EBNF grammar, so the %ebnf
should be specified or you'ld get this:
...\tooling\jison\lib\jison.js:179
throw err;
^
Error: unsupported parser input: "(" @ line 45, column 12 while lexing in bnf state:
: %empty | (at...
------------^
at Object.lexer__performAction [as performAction] (C:\Users\Ger\Projects\sites\library.visyond.gov\80\lib\tooling\jison\lib\util\parser.js:9464:51)
at Object.lexer_test_match [as test_match] (C:\Users\Ger\Projects\sites\library.visyond.gov\80\lib\tooling\jison\lib\util\parser.js:3722:36)
at Object.lexer_next [as next] (C:\Users\Ger\Projects\sites\library.visyond.gov\80\lib\tooling\jison\lib\util\parser.js:3821:26)
at Object.lexer_lex [as lex] (C:\Users\Ger\Projects\sites\library.visyond.gov\80\lib\tooling\jison\lib\util\parser.js:3852:22)
at lex (C:\Users\Ger\Projects\sites\library.visyond.gov\80\lib\tooling\jison\lib\util\parser.js:2630:27)
at Object.parse (C:\Users\Ger\Projects\sites\library.visyond.gov\80\lib\tooling\jison\lib\util\parser.js:2729:30)
at Object.parse (C:\Users\Ger\Projects\sites\library.visyond.gov\80\lib\tooling\jison\lib\util\ebnf-parser.js:6:16)
at autodetectAndConvertToJSONformat (C:\Users\Ger\Projects\sites\library.visyond.gov\80\lib\tooling\jison\lib\jison.js:169:32)
at new Jison_Generator (C:\Users\Ger\Projects\sites\library.visyond.gov\80\lib\tooling\jison\lib\jison.js:6451:15)
at Object.generateParserString (C:\Users\Ger\Projects\sites\library.visyond.gov\80\lib\tooling\jison\lib\cli.js:313:21)
After adding this option, several other things show up as faulty/unsupported and error out:
(...)
part are not supportedyytext
but I wonder if you truly know what you're doing there; it's far better and safer (when you maintain the grammar) to use $n
-named references, such as $stem
or $STRING
:: jison supports implicit named references for tokens, so if a rule has a terminal STRING, you can access the yyvalue/yytext
value of that token via $STRING
|
in the mc|mr
lexer lexer rule.mc|mr
lexer rule is completely obscured by the lexer rule for STRING
. flex wouldn't have saved your bacon here either, despite it testing all rules and picking the longest match.Overall it looks like a grammar in transition; a preliminary working version of the same is available at https://github.com/GerHobbelt/jison/blob/master/examples/issue-348.jison for your perusal, while your posted grammar is stored at https://github.com/GerHobbelt/jison/blob/master/examples/issue-348-grammar.txt for comparison.
I have the grammar in the attached file and input the following text for parsing: define mc with orientation=horizontal as stem text is "this is a test" option text = "option 1" and is correct option text = "option 2" option text = "option 3" score 1 point for all correct
mcmsDeclarativeGrammar.txt
I am getting "this.performAction.call is not a function" when trying to parse the above text.
Does anyone know why this is happening?
Thanks in advance.
Joe