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

Tests generate SyntaxError: Function statements require a function name #399

Open
BurtHarris opened this issue May 17, 2021 · 2 comments
Open

Comments

@BurtHarris
Copy link

Running npm install and npm test seems to produce two error messages (in addition to conflict messages).

  testLR1
  test LR parse
        test basic JSON grammar
          ⚡ SyntaxError: Function statements require a function name
              at new RegExpLexer (C:\try\jison\node_modules\jison-lex\regexp-lexer.js:124:22)
              at o.constructor.Jison_Generator [as constructor] (C:\try\jison\lib\jison.js:111:22)        
              at o.constructor.<computed> [as constructor] (C:\try\jison\lib\util\typal.js:23:28)
              at new o.constructor (C:\try\jison\lib\util\typal.js:77:70)
              at Object.Jison_Generator [as Generator] (C:\try\jison\lib\jison.js:1902:20)
              at new Parser (C:\try\jison\lib\jison.js:1911:25)
              at exports.test basic JSON grammar (C:\try\jison\tests\parser\lr1.js:116:18)
              at test (C:\try\jison\node_modules\test\test.js:29:20)
              at next (C:\try\jison\node_modules\test\test.js:69:7)
              at Object.end (C:\try\jison\node_modules\test\test.js:25:7)
test module include
        ⚡ SyntaxError: Function statements require a function name
            at new RegExpLexer (C:\try\jison\node_modules\jison-lex\regexp-lexer.js:124:22)
            at o.constructor.Jison_Generator [as constructor] (C:\try\jison\lib\jison.js:111:22)        
            at o.constructor.<computed> [as constructor] (C:\try\jison\lib\util\typal.js:23:28)
            at new o.constructor (C:\try\jison\lib\util\typal.js:77:70)
            at new Jison_Generator (C:\try\jison\lib\jison.js:1906:20)
            at exports.test module include (C:\try\jison\tests\parser\generator.js:223:15)
            at test (C:\try\jison\node_modules\test\test.js:29:20)
            at next (C:\try\jison\node_modules\test\test.js:69:7)
            at Object.end (C:\try\jison\node_modules\test\test.js:25:7)
            at test (C:\try\jison\node_modules\test\test.js:41:28)

Environment

node v14.17.0
npm 7.13.0

@BurtHarris
Copy link
Author

It looks like this is a duplicate of zaach/jison-lex#27 under Node versions greater than 10.

@fraczak
Copy link

fraczak commented Mar 25, 2023

I was able to fix it by changing regexp in jison-lex/regexp-lexer.js (line 57) to:

rules[i][1] = String(rules[i][1]).replace(/^(?:\s|\n)*function\s*\(\s*\)(?:\s|\n)*\{((.|\n)*)\}(?:\s|\n|;)*$/, '$1');

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