-
Notifications
You must be signed in to change notification settings - Fork 2
/
GRAMMAR.bnf
51 lines (34 loc) · 1.31 KB
/
GRAMMAR.bnf
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
Program ::= <Block>*
Block ::= <Head> ":" <NewLine>+ (<Indentation> <Block>)+
| <Line> <NewLine>+
| <IfBlock>
| <TryBlock>
IfBlock ::= "if" <Space> <Line> ":" <NewLine>+ (<Indentation> <Block>)+
("elseif" <Space> <Line> ":" <NewLine>+ (<Indentation> <Block>)+)*
("else" <Space>? ":" <NewLine>+ (<Indentation> <Block>)+)?
TryBlock ::= "try" <Space>* ":" <NewLine>+ (<Indentation> <Block>)+
("catch" <Space> <ProperWord> ":" <NewLine>+ (<Indentation> <Block>)+)*
Head ::= "while" <Space> <Line>
| "for" <Space> <ProperWord> (<Space> <Line>)? <Space>?
| "repeat" <Space> <Line>
| "func" <Space> <ProperWord> <Arguments>
| "local" <Space> <ProperWord> <Arguments>
| "labda" <Arguments>
| <ProperWord> <Arguments>
Indentation ::= <Tab>*
Line ::= (<Word> (<Space> <Word>)*)? <Space>?
Arguments ::= (<Space> <ProperWord>)* <Space>?
Space ::= " "+
Word ::= ProperWord
| Identity
| String
| Number
| Fraction
Identity ::= ":" <ProperWord>?
ProperWord ::= <Char>+
String ::= '"' <StringChar>* '"'
Number ::= '-'? <Digits> ('.' <Digits>)?
Fraction ::= '-'? <Digits> '/' <Digits>
Digits ::= ('0'..'9')+
Char ::= any non-whitespace, non-# character
StringChar ::= any character other than a double quote