You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PROGRAM Test
VAR
RetainInt: INT;
END_VAR
END_PROGRAM
This parses as variable called "Int" with variable attribute "Retain" and type "INT".
It is supposed to parse as variable called "RetainInt" with no variable attributes and type "INT".
I don't have any experience with lark, but I think a simple solution would be to guard against this with a change in iec.lark: variable_attributes: /(VAR_ATTRIB(!?\w))/+. to prevent it being followed by other letters (should also immediately guard against multiple attributes being written without spaces).
The text was updated successfully, but these errors were encountered:
You uncovered somewhat of a larger/systematic issue with how blark's grammar is much too relaxed with respect to real whitespace grammar rules.
This specific issue could potentially be fixed on a per-token basis (along the lines of this change) by adding in lookbehind and lookahead regular expression markers that expect there to be whitespace before and after the token. I'm not 100% sure if this is the best way to go about it, though.
If it is, the grammar will have a fair amount of updates needed as there are a number of other similar scenarios - where whitespace happens to be an important delimiter.
Example:
This parses as variable called "Int" with variable attribute "Retain" and type "INT".
It is supposed to parse as variable called "RetainInt" with no variable attributes and type "INT".
I don't have any experience with lark, but I think a simple solution would be to guard against this with a change in iec.lark:
variable_attributes: /(VAR_ATTRIB(!?\w))/+
. to prevent it being followed by other letters (should also immediately guard against multiple attributes being written without spaces).The text was updated successfully, but these errors were encountered: