LesterLyu / fast-formula-parser

Parse and evaluate MS Excel formula in javascript.
https://www.npmjs.com/package/fast-formula-parser
MIT License
462 stars 64 forks source link

Parsing error with quotes #24

Closed rmdort closed 4 years ago

rmdort commented 4 years ago

Do you know why i receive parser error with double quotes?

import {
  lex,
} from "fast-formula-parser/grammar/lexing";

lex('=SUM("') => Throws parsing error (one double quote)

lex('=SUM('') => Works fine (one single quote)
LesterLyu commented 4 years ago

The Lexer can not be used to validate grammar. You should use a normal parser/dependency parser to validate grammar.


In the Lexer, double quotes are only used to match Strings. That's why lex('SUM("') throws an error.

const String = createToken({
    name: 'String',
    pattern: /"(""|[^"])*"/
});
rmdort commented 4 years ago

Got it thank you