I'm trying to write a parser using Jison that'll parse the output of the javap
tool. Here's the contents of my .jison file:
%lex
%x classfile
%%
"Classfile" { this.begin("classfile"); }
<classfile>\s+ { /* ignore whitespace */ }
<classfile>[^\n]+ { this.popState(); return 'CLASSFILE'; }
<INITIAL><<EOF>> { return 'EOF'; }
/lex
%start root
%%
root
: CLASSFILE EOF { return $1; }
;
Unfortunately, when I run "jison javap.jison", I get this error:
undefined:5
case 0:"Classfile" { this.begin("classfile"); }
^
SyntaxError: Unexpected token {
at Function (<anonymous>)
at Object.buildActions (C:\Users\cdmck_000\AppData\Roaming\npm\node_modules\jison\node_modules\jison-lex\regexp-lexer.js:118:12)
at Object.RegExpLexer (C:\Users\cdmck_000\AppData\Roaming\npm\node_modules\jison\node_modules\jison-lex\regexp-lexer.js:131:39)
at Jison_Generator (C:\Users\cdmck_000\AppData\Roaming\npm\node_modules\jison\lib\jison.js:108:22)
at (anonymous function) (C:\Users\cdmck_000\AppData\Roaming\npm\node_modules\jison\lib\util\typal.js:23:28)
at new o.constructor (C:\Users\cdmck_000\AppData\Roaming\npm\node_modules\jison\lib\util\typal.js:77:70)
at new Jison_Generator (C:\Users\cdmck_000\AppData\Roaming\npm\node_modules\jison\lib\jison.js:1578:20)
at processGrammar (C:\Users\cdmck_000\AppData\Roaming\npm\node_modules\jison\lib\cli.js:87:21)
at Object.exports.main (C:\Users\cdmck_000\AppData\Roaming\npm\node_modules\jison\lib\cli.js:61:56)
at Object.<anonymous> (C:\Users\cdmck_000\AppData\Roaming\npm\node_modules\jison\lib\cli.js:105:13)
I've tried replacing "Classfile"
with \w+
but then it just gives me an error at the \
of \w+
instead.
I converted the line endings to UNIX format from Windows format and the problem went away.