forked from GetPoplog/Grammar
/
pop11_grammar_ebnf.txt
115 lines (91 loc) · 2.68 KB
/
pop11_grammar_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
Grammar ::= Expression
Expression ::=
Literal
| ConstantExpression
| Variable
| Assignment
| Definition
| Declaration
| Conditional
| BooleanExpression
| Iterative
| OperatorExpression
| FunctionApplication
| Jump
| Label
| LoopExits
| '(' Sequence ')'
| Block
ConstantExpression ::=
Construct
| '"' Word '"'
| '"' String '"'
Definition ::=
'define' Word ('(' Varslist? ')' | Varslist)? ('->' Varslist)* ';' Sequence 'enddefine'
Assignment ::=
Expression ('->' | '->>') (Variable | FunctionApplication)
| Expression '-->' Expression
Variable ::=
Word
| 'nonop' Operation
| 'nonmac' Macro
| 'nonsyntax' SyntaxWord
Declaration ::=
'global'? ('vars' | 'constant') Varslist ';'
| 'lvars' (',' | Word)+ ';'
| 'dlocal' (',' | Word)+ ';'
Varslist ::=
(','* ('procedure' | 'macro' | 'syntax' | Number)? Word)+
Sequence ::=
(Expression (',' | ';' | '=>' | '==>'))+
Block ::= 'lblock' Sequence 'endlblock'
Literal ::=
Number
| String
Construct ::=
ListConstruct
| PatternConstruct
| VectorConstruct
VectorConstruct ::=
'{' ListSegment* '}'
ListConstruct ::=
'[' ListSegment* ']'
PatternConstruct ::=
'[' PatternSegment ']'
ListSegment ::=
'%' Sequence '%'
| Word
| Literal
| Construct
| ('^' | '^^') (Word | '(' Sequence ')')
PatternSegment ::=
ListSegment
| ('?' | '??') Word (':' (Integer | Word | ListSegment))?
| '='
| '=='
Label ::=
Word ':' '*'?
Jump ::=
'goto' Word
Iterative ::=
'for' Expression 'step' Expression 'till' Expression 'do' Sequence 'endfor'
| 'while' Expression 'do' Sequence 'endwhile'
| 'until' Expression 'do' Sequence 'enduntil'
| 'for' Word (('in' | 'on') | ('from' Expression ('by' Expression)?)? 'to') Expression 'do' Sequence 'endfor'
| 'for' Word 'from_repeater' Expression 'do' Sequence 'endfor'
| 'foreach' Expression ('in' Expression)? 'do' Sequence 'endforeach'
| 'forevery' Expression ('in' Expression)? 'do' Sequence 'endforevery'
| 'repeat' (Expression 'times' | 'forever')? Sequence 'endrepeat'
Conditional ::=
'if' Expression 'then' Sequence (('elseif' | 'elseunless') Expression 'then' Sequence)* ('else' Sequence)? 'endif'
| 'unless' Expression 'then' Sequence (('elseif' | 'elseunless') Expression 'then' Sequence)* ('else' Sequence)? 'endunless'
LoopExits ::=
('quitloop' | 'nextloop') ('(' Integer ')')?
| ('quitif' | 'quitunless' | 'nextif' | 'nextunless') '(' Expression ')' ('(' Integer ')')?
BooleanExpression ::=
Expression (('and' | 'or') Expression)*
OperatorExpression ::=
Expression Operator Expression
FunctionApplication ::=
Expression '(' Expression? (',' Expression?)* ')'
| '.' Expression