-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
amod EBNF.txt
124 lines (85 loc) · 2.76 KB
/
amod EBNF.txt
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
This was generated by converting the output of "./gactar -ebnf" using https://bottlecaps.de/convert/
That site will also generate nice railroad diagrams for the grammar.
---
AmodFile ::= '~~' 'model' '~~' ModelSection '~~' 'config' '~~' ConfigSection? '~~' 'init' '~~' InitSection? '~~' 'productions' '~~' ProductionSection?
ModelSection
::= 'name' ':' ( string | ident ) ( 'description' ':' string )? ( 'authors' '{' string* '}' )? ( 'examples' '{' Pattern* '}' )?
Pattern ::= '[' ident ':' PatternSlot+ ']'
PatternSlot
::= '!'? ( 'nil' | ident | string | number | var )
| wildcard
ConfigSection
::= GactarConfig? ModuleConfig? ChunkConfig?
GactarConfig
::= 'gactar' '{' Field* '}'
Field ::= ident FieldValue
FieldValue
::= ':' ( ident | string | number )
| '{' Field* '}'
ModuleConfig
::= 'modules' '{' Module* '}'
Module ::= ident '{' Field* '}'
ChunkConfig
::= 'chunks' '{' ChunkDecl* '}'
ChunkDecl
::= '[' ident ':' ident+ ']'
InitSection
::= Initialization*
Initialization
::= ModuleInitializer
| SimilarityInitializer
ModuleInitializer
::= ident ( '{' ( NamedInitializer+ | BufferInitializer+ ) '}' | NamedInitializer )
NamedInitializer
::= ident? Pattern
BufferInitializer
::= ident ( '{' NamedInitializer+ '}' | NamedInitializer )
SimilarityInitializer
::= 'similar' '{' Similar+ '}'
Similar ::= '(' ident ident number ')'
ProductionSection
::= Production+
Production
::= ident '{' ( 'description' ':' string )? Match Do '}'
Match ::= 'match' '{' MatchItem+ '}'
MatchItem
::= MatchBufferPatternItem
| MatchBufferStateItem
| MatchModuleStateItem
MatchBufferPatternItem
::= ident Pattern WhenClause?
WhenClause
::= 'when' WhenExpression ( 'and' WhenExpression )*
WhenExpression
::= '(' var ComparisonOperator Arg ')'
ComparisonOperator
::= equality
| inequality
Arg ::= 'nil'
| var
| ident
| string
| number
MatchBufferStateItem
::= 'buffer_state' ident ident
MatchModuleStateItem
::= 'module_state' ident ident
Do ::= 'do' '{' Statement+ '}'
Statement
::= ClearStatement
| PrintStatement
| RecallStatement
| SetStatement
| 'stop'
ClearStatement
::= 'clear' ( ident ','? )+
PrintStatement
::= 'print' ( Arg ','? )*
RecallStatement
::= 'recall' Pattern WithClause?
WithClause
::= 'with' WithExpression ( 'and' WithExpression )*
WithExpression
::= '(' ident Arg ')'
SetStatement
::= 'set' ident ( '.' ident )? 'to' ( Arg | Pattern )