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

Cannot set property 'lastIndex' of undefined #1

Closed
HamedFathi opened this issue Jul 10, 2019 · 2 comments
Closed

Cannot set property 'lastIndex' of undefined #1

HamedFathi opened this issue Jul 10, 2019 · 2 comments

Comments

@HamedFathi
Copy link

HamedFathi commented Jul 10, 2019

I wrote your basic sample in VSCode

const Lexer = require('flex-js');
var lexer = new Lexer();
// options
lexer.setIgnoreCase(true);  // does not make sense for this scanner, just for reference
// definitions
lexer.addDefinition('DIGIT', /[0-9]/);
// rules
lexer.addRule(/{DIGIT}+\.{DIGIT}+/, function (lexer) {
  console.log('Found float: ' + lexer.text);
});
lexer.addRule(/\s+/);
// code
lexer.setSource('1.2 3.4 5.6');
lexer.lex();

and I got an error

...\node_modules\flex-js\src\Lexer.js:647
  re.lastIndex = this.index;
               ^

TypeError: Cannot set property 'lastIndex' of undefined
    at Lexer.execRegExp (...\node_modules\flex-js\src\Lexer.js:647:16)

Screenshot_1

I am not sure what is the problem but I handled the error with a line of code

  if (!re) return undefined;

Screenshot_2

Can you guide me?

@sormy
Copy link
Owner

sormy commented Jul 11, 2019

What OS and NodeJS version are you using?
Provided example works without issues on Node v12.5.0 (macOS)

@sormy
Copy link
Owner

sormy commented Jul 21, 2019

No activity

@sormy sormy closed this as completed Jul 21, 2019
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