-
Notifications
You must be signed in to change notification settings - Fork 0
/
spl.bnf
90 lines (61 loc) · 2.25 KB
/
spl.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
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
<program> ::= <identifier> ":" <block> ENDP <identifier> "."
<block> ::= DECLARATIONS <declaration_block> CODE <statement_list>
| CODE <statement_list>
<declaration_block> ::= <identifier> <type_block>
| <identifier> <type_block> <declaration_block>
| <identifier> "," <declaration_block>
<type_block> ::= OF TYPE <type> ";"
<type> ::= CHARACTER
| INTEGER
| REAL
<statement_list> ::= <statement>
| <statement> ";" <statement_list>
<statement> ::= <assignment_statement>
| <if_statement>
| <do_statement>
| <while_statement>
| <for_statement>
| <write_statement>
| <read_statement>
<assignment_statement> ::= <expression> "->" <identifier>
<if_statement> ::= IF <conditional> THEN <statement_list> ENDIF
| IF <conditional> THEN <statement_list> ELSE <statement_list> ENDIF
<do_statement> ::= DO <statment_list> WHILE <conditional> ENDDO
<while_statement ::= WHILE <conditional> DO <statement_list> ENDWHILE
<for_statement> ::= FOR <identifier> IS <expression> BY <expression> TO <expression> DO
<statement_list> ENDFOR
<write_statement> ::= WRITE "(" <output_list> ")"
| NEWLINE
<read_statement> ::= READ "(" <identifier> ")"
<output_list> ::= <value>
| <value> "," <output_list>
<conditional> ::= NOT <conditional>
| <conditional_variable>
| <conditional_variable> AND <conditional>
| <conditional_variable> OR <conditional>
<conditional_variable> ::= <expression> <conditional> <expression>
<comparator> ::= "="|"<>"|"<"|">"|"<="|">="
<expression> ::= <term>
| <term> "+" <expression>
| <term> "-" <expression>
<term> ::= <value>
| <value> "*" <term>
| <value> "/" <term>
<value> ::= <identifier>
| <constant>
| "(" <expression> ")"
<constant> ::= <number_constant>
| <character_constant>
<character_constant> ::= "'" <character> "'"
<number_constant> ::= <number>
| "-" <number>
| "-" <number> "." <number>
| <number> "." <number>
<identifier> ::= <character>
| <identifier> <character>
| <identifier> <digit>
<number> ::= | <digit> <number>
| <digit>
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<character> ::= a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z
A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z