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
Possible to use precedence in pattern matching step?
I have 3 terms on for digits ("[0-9]+"), "u" and one for identifiers "[a-zA-Z_][a-zA-Z_0-9]+"
I "u" to identify an unsigned integer and I can specify its bit arity with a number after it
e.g "100u8" is an an unsigned 8-bit integer with value 100.
100u works fine (unsigned integer with value 100 and unspecified bit-arity)
However 100 is pared as "Digits" <- "Base10Digits", (I do this because I can parse digits in different bases) then "u8" is parsed as an identifier, and there is no rule to match this.
Right now "u" has a higher precedence than "Identifier" but identifier gets matched first.
Would it be possible to:
A ) Try matching patterns with higher precedence first
B ) If there is no suitable rule for the matched term, fallback and see if there is a suitable term (case: Unexpected Identifier)?
The text was updated successfully, but these errors were encountered:
Right now there is no mechanism for terms precedence.
The simplest one which is just whichever is first passed in terms(...) call in parser definition should have the biggest precedence shouldn't be hard to implement.
I will consider adding the feature in near future.
After a brief analyze of the code I can tell that the term that is first on the terms(...) call in parser definition is actually matched first.
So I can't see the problem here, can you please provide some code?
Is "u" actually separate term? Why? It seems it should be part of the number term.
Possible to use precedence in pattern matching step?
I have 3 terms on for digits ("[0-9]+"), "u" and one for identifiers "[a-zA-Z_][a-zA-Z_0-9]+"
I "u" to identify an unsigned integer and I can specify its bit arity with a number after it
e.g "100u8" is an an unsigned 8-bit integer with value 100.
100u works fine (unsigned integer with value 100 and unspecified bit-arity)
However 100 is pared as "Digits" <- "Base10Digits", (I do this because I can parse digits in different bases) then "u8" is parsed as an identifier, and there is no rule to match this.
Right now "u" has a higher precedence than "Identifier" but identifier gets matched first.
Would it be possible to:
A ) Try matching patterns with higher precedence first
B ) If there is no suitable rule for the matched term, fallback and see if there is a suitable term (case: Unexpected Identifier)?
The text was updated successfully, but these errors were encountered: