-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbnf.file
101 lines (69 loc) · 3.54 KB
/
bnf.file
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
<program> ::= <identifier> ":" <block> "ENDP" <identifier> "."
<block> ::= "DECLARATIONS" <declaration_block> "CODE" <statement_list>
| "CODE" <statement_list>
<declaration_block> ::= <identifier_list> "OF" "TYPE" <type> ";" <declaration_block>
| <identifier_list> "OF" "TYPE" <type> ";"
<identifier_list> ::= <identifier>
| <identifier> "," <identifier_list>
<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" <statement_list> "WHILE" <conditional> "ENDDO"
<while_statement> ::= "WHILE" <conditional> "DO" <statement_list> "ENDWHILE"
<for_statement> ::= "FOR" <for_loop> <statement_list> "ENDFOR"
<for_loop> ::= <identifier> "IS" <expression> "BY" <expression> "TO" <expression> "DO"
<write_statement> ::= "WRITE" "(" <output_list> ")"
| "NEWLINE"
<read_statement> ::= "READ" "(" <identifier> ")"
<output_list> ::= <value>
| <value> "," <output_list>
<comparison> ::= <expression> <comparator> <expression>
<conditional> ::= "NOT" <conditional>
| <comparison>
| <comparison> "AND" <conditional>
| <comparison> "OR" <conditional>
<comparator> ::= "="
| "<>"
| "<"
| ">"
| "<="
| ">="
<expression> ::= <expression> "+" <term>
| <expression> "-" <term>
| <term>
<term> ::= <term> "*" <value>
| <term> "/" <value>
| <value>
<value> ::= <identifier>
| <constant>
| "(" <expression> ")"
<constant> ::= <real_constant>
| <integer_constant>
| <character_constant>
<character_constant> ::= "'" <character> "'"
<real_constant> ::= <number> "." <number>
| "-" <number> "." <number>
<integer_constant> ::= <number>
| "-" <number>
<number> ::= <digit>
| <digit> <number>
<identifier> ::= <character>
| <identifier> <character>
| <identifier> <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