35 lines
1.3 KiB
Markdown
35 lines
1.3 KiB
Markdown
Lexesis(5) -- Syntax rules for Lexesis .lxs files
|
|
=================================================
|
|
|
|
DESCRIPTION
|
|
-----------
|
|
|
|
Input files for Lexesis(1) have a `.lxs` extension and have a set of some very simple rules:
|
|
On each line, a new type of token is specified with a different priority, starting with the highest at the top of the file and lowest at the bottom.
|
|
If your input matches more than one of the regexes in your input file, the generated lexer will choose the token with the highest priority.
|
|
The line begins with the name for the new type of token, following a `=` and finally the regex used to match tokens of that type.
|
|
If you want to add a comment to the file, make sure the line starts with a `#` and Lexesis will ignore that line.
|
|
|
|
Consider the following example:
|
|
|
|
CAPITAL = [A-Z]
|
|
NUMBER = [0-9]
|
|
|
|
# This is a comment
|
|
ALL = [a-zA-Z]
|
|
|
|
Here we have 3 different tokens `CAPITAL`, `NUMBER` and `ALL`.
|
|
Note that the names for the tokens only consist of capital letters, small letter and underscores, other characters are not recommended, in order to work for most possible backends.
|
|
When we run **A** through the generated lexer, it will return that it's a `CAPITAL`, since that is specified higher than `ALL`.
|
|
|
|
AUTHORS
|
|
-------
|
|
|
|
* Thomas Avé
|
|
* Robin Jadoul
|
|
|
|
SEE ALSO
|
|
--------
|
|
|
|
Lexesis(1)
|