forked from koskenni/pytwolc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwolcsyntax.ebnf
84 lines (49 loc) · 1.63 KB
/
twolcsyntax.ebnf
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@@grammar::TwolCSyntax
@@left_recursion :: False
expr_start = expression $ ;
rul_start = rule $ ;
def_start = define $ ;
define = left:identifier op:'=' ~ right:expression ';' ;
identifier = token:/[a-zA-Z0-1Ø]+/ ;
rule = double_arrow_rule | right_arrow_rule | exclusion_rule | left_arrow_rule ;
double_arrow_rule = left:expression op:'<=>' ~ right:contexts ';' ;
right_arrow_rule = left:expression op:'=>' ~ right:contexts ';' ;
exclusion_rule = left:expression op:'/<=' ~ right:contexts ';' ;
left_arrow_rule = left:expression op:'<=' ~ right:contexts ';' ;
contexts = context_lst | context ;
context_lst = left:context ',' right:contexts ;
context = left:[expression] '_' right:[expression] ;
expression = composition | term ;
composition = left:term '.o.' ~ right:expression ;
term = union | difference | intersection | factor ;
union = left:factor op:'|' ~ right:term ;
difference = left:factor op:'-' ~ right:term ;
intersection = left:factor op:'&' ~ right:term ;
factor = concatenation | unit ;
concatenation = left:unit right:factor ;
unit =
| Kleene_plus
| Kleene_star
| Upper
| Lower
| Morphophonemic
| Surface
| One_but_not
| atom
;
Kleene_plus = expr:atom '+' ;
Kleene_star = expr:atom '*' ;
Upper = expr:atom '.u' ;
Lower = expr:atom '.l' ;
Morphophonemic = expr:atom '.m' ;
Surface = expr:atom '.s' ;
One_but_not = '\\' expr:atom ;
atom
= '[' @:subexpression ~ ']'
| '(' @:optexpression ~ ')'
| symbol_or_pair
| boundary ;
subexpression = expr:expression ;
optexpression = expr:expression ;
symbol_or_pair = token:/[a-zåüäöõšžA-ZØ:{}'´`]+/ ;
boundary = '.#.' ;