The syntax of the lrlex .l format, aims to be familiar to the format used by posix lex.
It uses the same basic structure as lex.
Definitions
%%
Rules
%%
User Subroutines
Definitions
Within the definitions section, you can add an option %grmtools section
documented in extensions
Rules
Each rule is given by the following elements in sequence:
- Optional Start State, one or more names comma separated between angle brackets. For example
<Start_State>documented in Start States. - Regex, syntax defined by the rust regex crate with optional escaping for any character.
- Separator space, any horizontal space character in the unicode
Pattern_White_Spacecharacter set - Optional State operator, given between angle brackets documented in Start States
<+STATE>Push the state given bySTATEto the top of the stack.<-STATE>Pop the state off the top of the stack.<STATE>Replace the state stack with the stateSTATE
- Token Name, for example
"token"any non-space character between double quotes, including double quotes. - End of line, finishes each rule.
User Subroutines
Since lrlex doesn’t support user actions, it doesn’t support User Subroutines either.