-
Notifications
You must be signed in to change notification settings - Fork 3
/
lelwel.llw
46 lines (43 loc) · 1.15 KB
/
lelwel.llw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/// Keyword
token Token='token' Start='start' Right='right' Skip='skip';
/// Punctuator
token Colon=':' Semi=';' Equal='=' LPar='(' RPar=')' LBrak='[' RBrak=']'
Or='|' Star='*' Plus='+' Hat='^';
/// Identifier for rules and tokens
token Id='<identifier>' Str='<string literal>';
token Predicate='<semantic predicate>' Action='<semantic action>' NodeRename='<node rename>';
token NodeMarker='<node marker>' NodeCreation='<node creation>';
token Comment DocComment Whitespace;
start file;
skip Comment DocComment Whitespace;
file: decl*;
decl^:
token_list
| rule_decl
| start_decl
| right_decl
| skip_decl
;
start_decl: 'start' Id ';';
right_decl: 'right' (Id | Str)+ ';';
skip_decl: 'skip' (Id | Str)+ ';';
token_list: 'token' token_decl+ ';';
token_decl: Id ['=' Str];
rule_decl: Id ['^'] ':' [regex] ';';
regex^: alternation;
alternation^: concat [('|' concat)+ >];
concat^: postfix [postfix+ >];
postfix:
postfix '*' @star
| postfix '+' @plus
| '(' regex ')' @paren
| '[' regex ']' @optional
| Id @name
| Str @symbol
| Predicate @predicate
| Action @action
| NodeRename @node_rename
| NodeMarker @node_marker
| NodeCreation @node_creation
| '^' @node_elision
;