-
Notifications
You must be signed in to change notification settings - Fork 41
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
Expression that subtracts a literal number without space fails to parse #133
Comments
gthb
changed the title
Expression that subtracts a literal number fails to parse
Expression that subtracts a literal number without space fails to parse
Aug 8, 2023
I tried out just moving the lexer definitions of diff --git a/src/lexer.ts b/src/lexer.ts
index eafe785..360cbfc 100644
--- a/src/lexer.ts
+++ b/src/lexer.ts
@@ -51,8 +51,6 @@ export const lexer = compile({
star: '*',
comma: ',',
space: { match: /[\s\t\n\v\f\r]+/, lineBreaks: true, },
- int: /\-?\d+(?![\.\d])/,
- float: /\-?(?:(?:\d*\.\d+)|(?:\d+\.\d*))/,
// word: /[a-zA-Z][A-Za-z0-9_\-]*/,
lparen: '(',
rparen: ')',
@@ -71,6 +69,8 @@ export const lexer = compile({
op_membertext: '->>',
op_member: '->',
op_minus: '-',
+ int: /\-?\d+(?![\.\d])/,
+ float: /\-?(?:(?:\d*\.\d+)|(?:\d+\.\d*))/,
op_div: /\//,
op_not_ilike: /\!~~\*/, // !~~* =ILIKE
op_not_like: /\!~~/, // !~~ =LIKE That makes some tests fail:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This existing test passes just fine:
... but adding this corresponding test for subtraction fails:
... with a syntax error saying:
Unexpected int token: "-51"
in the spaceless case, so presumably the problem is that lexical analysis outputs the two tokensLITERAL 42
,LITERAL -51
, but the parsing only works if the tokens areLITERAL 42
,MINUS
,LITERAL 51
, i.e. the minus token should have a higher precedence than the negative integer literal token.Full test failure output
The text was updated successfully, but these errors were encountered: