-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
Description of the issue
Boolean literals end up being parsed as IDENTIFIER terminals rather than boolean_literal instances.
Steps to reproduce
Write the following source to test.txt:
VAR_GLOBAL
variable : BOOL := TRUE;
END_VAR
Run
blark parse --print-tree test.txt
Expected result
The string TRUE gets parsed as a boolean literal:
iec_source
global_var_declarations
[... non-relevant part of the output omitted ...]
unary_expression
None
constant
boolean_literal TRUE
Actual result
The string TRUE gets parsed as an identifier. Note that the full meaning of the TRUE in the output below is, in lark's notation, Token('IDENTIFIER', 'TRUE').
iec_source
global_var_declarations
[... non-relevant part of the output omitted ...]
unary_expression
None
variable_name
TRUE
None
Additional information
I am able to get the expected parse result by increasing the priority of the constant rule in the grammar, i.e., by replacing this line:
constant: time_literal
with this:
constant.1: time_literal
Please let me know if this seems a sensible solution. I will gladly prepare a PR if you agree.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels