SyntaxError in Jison parser

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:


%x classfile


"Classfile"             { this.begin("classfile"); }

<classfile>\s+          { /* ignore whitespace */ }
<classfile>[^\n]+       { this.popState(); return 'CLASSFILE'; }

<INITIAL><<EOF>>        { return 'EOF'; }


%start root


  : CLASSFILE EOF { return $1; }

Unfortunately, when I run "jison javap.jison", I get this error:

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.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.