blob: 0777d55e30a5bca23891c8fcbff6722bf302ae90 (
plain)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
\part{Appendix}
\appendix
\chapter{Syntax}
\begin{grammar}
<letter> = `A' | `B' | … | `Z' | `a' | `b' | … | `z' | `\_'.
<counting-digit> = `1' | `2' | `3' | `4' | `5' | `6' | `7' | `8' | `9'.
<decimal-digit> = `0' | <counting-digit>.
<hex-digit> = <decimal-digit> | `A' | `B' | … | `F' | `a' | `b' | … | `f'.
<binary-digit> = `0' | `1'.
<hex-character> = `\\x' <hex-digit> <hex-digit>.
<escaped-character> = `\\' \\
(`n' | `a' | `b' | `t' | `f' | `r' | `v' | `\\' | `\textquotesingle' | `\textquotedbl' | `?\@' | `0').
<printable-character> = \enspace? a printable ASCII character\space?.
<character> = <printable-character> | <escaped-character> | <hex-digit>.
<identifier> = <letter> \{<letter> | <decimal-digit>\}.
<identifier-definition> = <identifier> [`*'].
<trait-identifier> = `#' <identifier>.
<integer-literal> = `0' | <counting-digit> \{<decimal-digit>\}.
<word-literal> = <integer-literal> `u'
\alt{} `0' (`X' | `x') <hex-digit> \{<hex-digit>\}
\alt{} `0' (`B' | `b') <binary-digit> \{<binary-digit>\}.
<real-literal> = <integer-literal> `.\@' <decimal-digit> \{<decimal-digit>\}
\alt{} <integer-literal>\} `e' [`+' | `-'] <decimal-digit> \{<decimal-digit>\}.
<string-literal> = `\textquotedbl' \{<character>\} `\textquotedbl'.
<character-literal> = `\textquotesingle' <character> `\textquotesingle'.
<literal> = <integer-literal> | <word-literal> | <real-literal>
\alt{} <string-literal> | <character-literal>
\alt{} `true' | `false' | `nil'.
<trait> = <trait-identifier> `(' [<types>] `)'.
<cast> = `cast' `(' <expression> `:\@' <type> `)'.
<procedure-call> = <designator> `(' [<expressions>] `)'.
<relation-operator> = `=' | `<>' | `<' | `>' | `<=' | `>='.
<multiplication-operator> = `*' | `/' | `\%'.
<addition-operator> = `+' | `-'.
<shift-operator> = `<<' | `>>'.
<unary-operator> = `@' | `~' | `-'.
<selector> = `[' <expression> `]' | `.\@' <identifier> | `^'.
<case> = <expressions> `:\@' <optional-statements>.
<designator> = <reference> <selector> | <identifier>.
<reference> = <literal>
\alt{} <designator>
\alt{} <trait>
\alt{} <cast>
\alt{} <procedure-call>
\alt{} `(' <expression> `)'.
<factor> = <unary-operator> <factor> | <reference>.
<term> = <factor> \{<multiplication-operator> <factor>\}.
<simple-expression> = <term> \{<addition-operator> <term>\}.
<comparand> = <simple-expression> \{<shift-operator> <simple-expression>\}.
<relation> = <comparand> \{<relation-operator> <comparand>\}.
<operand> = <relation> \{`&' <relation>\}.
<expression> = <operand> \{(`or' | `xor') <operand>\}.
<expressions> = <expression> \{`,' <expression>\}.
<identifier-definitions> = <identifier-definition> \{`,' <identifier-definition>\}.
<types> = <type> \{`,' <type>\}.
<required-statements> = <statement> \{`;' <statement>\}.
<optional-statements> = [<required-statements>].
<return-declaration> = [`->' `!\@' | `->' type].
<field> = <identifier> `:\@' <type>.
<array-type> = `[' <expression> `]' <type>.
<pointer-type> = `^' <type>.
<record-type> = `record' [`(' <identifier> `)'] [<field> \{`;' <field>\}] `end'.
<enumeration-type> = `(' <identifier> \{`,' <identifier>\} `)'.
<procedure-type> = `proc' `(' [<types>] `)' <return-declaration>.
<type> = <array-type>
\alt{} <pointer-type>
\alt{} <record-type>
\alt{} <enumeration-type>
\alt{} <procedure-type>
\alt{} <identifier>.
<assignment> = <designator> `:=' <expression>.
<if-statement> = `if' <expression> `then' <optional-statements> \\
\{`elsif' <expression> `then' <optional-statements>\} \\
{[`else' <optional-statements>]} `end'.
<while-statement> = `while' <expression> `do' <optional-statements> \\
\{`elsif' <expression> `do' <optional-statements>\} `end'.
<defer-statement> = `defer' <optional-statements> `end'.
<case-statement> = `case' <expression> `of' <case> \{`|' case\} \\
{[`else' <optional-statements>]} `end'.
<label-declaration> = `.\@' <identifier>.
<goto-statement> = `goto' <identifier>.
<statement> = <assignment> | <procedure-call> | <defer-statement>
| <label-declaration> | <goto-statement> |
| <while-statement> | <if-statement> | <case-statement>.
<statement-part> = [`begin' <required-statements>
\alt{} `return' <expression>
\alt{} `begin' <required-statements> `;' `return' <expression>].
<constant-declaration> = <identifier-definition> `:=' <expression>.
<constant-part> = [`const' \{<constant-declaration> `;'\}].
<variable-declaration> = <identifier-definitions> `:\@' <type> \\
{[`:=' (<expression> | `extern')]}.
<variable-part> = [`var' \{<variable-declaration> `;'\}].
<type-declaration> = <identifier-definition> `=' <type>.
<type-part> = [`type' \{<type-declaration> `;'\}].
<import-declaration> = <identifier> \{`.\@' <identifier>\}.
<import-part> = [`import' \{import-declaration `;'\}].
<procedure-heading> = `proc' <identifier-definition> \\
`(' [<field> \{`,' <field>\}] `)' <return-declaration>.
<block> = <constant-part> <variable-part> <statement-part> `end'.
<procedure-declaration> = <procedure-heading> `;' (block | `extern').
<declaration-sequence> = <import-part> \\
<constant-part> <type-part> <variable-part> \\
\{<procedure-declaration> `;'\}.
<program> = `program' `;' <declaration-sequence> <statement-part> `end' `.\@'
\alt{} `module' `;' <declaration-sequence> `end' `.\@'.
\end{grammar}
|