Skip to content

Commit a94697f

Browse files
committed
Add some docs on lex syntax
1 parent 12067d6 commit a94697f

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

doc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [Extensions](lexextensions.md)
88
- [Hand-written lexers](manuallexer.md)
99
- [Start States](start_states.md)
10+
- [Syntax](lexsyntax.md)
1011
- [Parsing](parsing.md)
1112
- [Yacc compatibility](yacccompatibility.md)
1213
- [Extensions](yaccextensions.md)

doc/src/lexsyntax.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
The syntax of the lrlex `.l` format, aims to be familiar to the format used by posix lex.
2+
It uses the same basic structure as lex.
3+
4+
```
5+
Definitions
6+
%%
7+
Rules
8+
%%
9+
UserSubroutines
10+
```
11+
12+
## Definitions
13+
14+
### Optional %grmtools section
15+
16+
Defined in [extensions](./lexextensions.md)
17+
18+
## Rules
19+
20+
Each rule is given by
21+
22+
### Optional Start State
23+
Between angle brackets <Start_State>
24+
25+
### Regex
26+
27+
Regular expressions are define by the rust [regex](https://docs.rs/regex) crate.
28+
29+
30+
### Separator space
31+
32+
Any horizontal space character in the unicode `Pattern_White_Space` character set.
33+
34+
### Optional State operator
35+
36+
Between angle brackets these are documented in [Start States](./start_states.md)
37+
* `<+STATE>` Push the state given by `STATE` to the top of the stack.
38+
* `<-STATE> Pop the state off the top of the stack.
39+
* `<STATE>` Replace the state stack with the state `STATE`
40+
41+
42+
### Token Name
43+
44+
Token name may contain any non-space character between double quotes, including double quotes
45+
46+
### End of line
47+
48+
The end of line finishes a rule.
49+
50+
## UserSubroutines
51+
52+
Since lrlex doesn't support user actions, it doesn't support User Subroutines either.
53+

0 commit comments

Comments
 (0)