Division sign (slash) is confused with multiline comment
See original GitHub issueHello,
I listed below a snapshot of my rules for parsing binary operation:
binary_operation: sum_operation
sum_operation: mul_operation
| sum_operation PLUS mul_operation -> add
| sum_operation MINUS mul_operation -> minus
mul_operation: power_operation
| mul_operation MULTIPLICATION power_operation -> mul
| mul_operation DIVISION power_operation -> div
power_operation: new_expression
| power_operation POWER expression -> power
expression: constant
| reference
reference: name
name: ID | quoted_identifier
ID: /[A-Za-z][A-Za-z0-9\d_]*/
PLUS: "+"
DIVISION: "/"
MINUS: "-"
POWER : "^"
MULTIPLICATION: "*"
MULTILINE_COMMENT: /\/\*.*?\*\//s
%ignore MULTILINE_COMMENT
%ignore /\s/s
The rules work well when parsing the expression:
x/**/:=/**/(1.00000000000000002E-02/**/*y)
But parsing the following expression results in the error below:
x/**/:=/**/(y/**// 4.0)
lark.exceptions.UnexpectedCharacters: No terminal defined for ‘/’ at line Expecting: {‘MINUS’, ‘PLUS’, ‘MULTIPLICATION’, ‘POWER’}
Any help would be much appreciated,
Best regards
Issue Analytics
- State:
- Created 3 years ago
- Comments:23 (17 by maintainers)
Top Results From Across the Web
When parsing Javascript, what determines the meaning of a ...
Forward-slashes can mean a number of different things: division operator, regular expression literal, comment introducer, or line-comment introducer. The last ...
Read more >Slash (punctuation) - Wikipedia
Once used to mark periods and commas, the slash is now used to represent division and fractions, exclusive 'or' and inclusive 'or', and...
Read more >Comments in C/C++ - GeeksforGeeks
Multi-line comment. Single line Comment. Represented as // double forward slash. It is used to denote a single line comment ...
Read more >Comments in programming languages
We have two types of comments here, the end-of-line comment and the block comment. An end-of-line comment terminates at the end of the...
Read more >Clarifying Code with Javascript Comments | Udacity
Javascript multiline comments, also known as block comments, start with a forward slash followed by an asterisk (/*) and end with an ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please give an MCVE. Your issue leads to a lot of open questions:
I can also see that what you posted there can’t be the exact grammar you are using (or we have an incredible severe bug in Lark somewhere that should prevent most grammars from working). Otherwise
DIVIDE
would have to appear in theExpected
list.We are certainly ready and open to help you, but you didn’t give us enough information.
I went with @MegaIng 's suggestion.
@khaled-ek @charles-esterbrook This is now fixed in
master
, and will be part of the next release.Hopefully it won’t break anyone’s code.