-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject_Pascal_Grammar .txt
294 lines (271 loc) · 9.19 KB
/
object_Pascal_Grammar .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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
@ object Pascal Grammar
Goal -> (Program | Package | Library | Unit)
Program -> [PROGRAM Ident ['(' IdentList ')'] ';']
ProgramBlock '.'
Unit -> UNIT Ident [PortabilityDirective] ';'
InterfaceSection
ImplementationSection
InitSection '.'
Package -> PACKAGE Ident ';'
[RequiresClause]
[ContainsClause]
END '.'
Library -> LIBRARY Ident ';'
ProgramBlock '.'
ProgramBlock -> [UsesClause]
Block
UsesClause -> USES IdentList ';'
PortabilityDirective -> platform
-> deprecated
-> library
InterfaceSection -> INTERFACE
[UsesClause]
[InterfaceDecl]...
InterfaceDecl -> ConstSection
-> TypeSection
-> VarSection
-> ExportedHeading
ExportedHeading -> ProcedureHeading ';' [Directive]
-> FunctionHeading ';' [Directive]
ImplementationSection -> IMPLEMENTATION
[UsesClause]
[DeclSection]...
[ExportsStmt]...
Block -> [DeclSection]
[ExportsStmt]...
CompoundStmt
[ExportsStmt]...
ExportsStmt -> EXPORTS ExportsItem [, ExportsItem]...
ExportsItem -> Ident [NAME|INDEX "'" ConstExpr "'"]
[INDEX|NAME "'" ConstExpr "'"]
DeclSection -> LabelDeclSection
-> ConstSection
-> TypeSection
-> VarSection
-> ProcedureDeclSection
LabelDeclSection -> LABEL LabelId
ConstSection -> CONST (ConstantDecl ';')...
ConstantDecl -> Ident '=' ConstExpr [PortabilityDirective]
-> Ident ':' TypeId '=' TypedConstant [PortabilityDirective]
TypeSection -> TYPE (TypeDecl ';')
TypeDecl -> Ident '=' [TYPE] Type [PortabilityDirective]
-> Ident '=' [TYPE] RestrictedType [PortabilityDirective]
TypedConstant -> (ConstExpr | ArrayConstant | RecordConstant)
ArrayConstant -> '(' TypedConstant ',' ')'
RecordConstant -> '(' RecordFieldConstant ';'... ')'
RecordFieldConstant -> Ident ':' TypedConstant
Type -> TypeId
-> SimpleType
-> StrucType
-> PointerType
-> StringType
-> ProcedureType
-> VariantType
-> ClassRefType
RestrictedType -> ObjectType
-> ClassType
-> InterfaceType
ClassRefType -> CLASS OF TypeId
SimpleType -> (OrdinalType | RealType)
RealType -> REAL48
-> REAL
-> SINGLE
-> DOUBLE
-> EXTENDED
-> CURRENCY
-> COMP
OrdinalType -> (SubrangeType | EnumeratedType | OrdIdent)
OrdIdent -> SHORTINT
-> SMALLINT
-> INTEGER
-> BYTE
-> LONGINT
-> INT64
-> WORD
-> BOOLEAN
-> CHAR
-> WIDECHAR
-> LONGWORD
-> PCHAR
VariantType -> VARIANT
-> OLEVARIANT
SubrangeType -> ConstExpr '..' ConstExpr
EnumeratedType -> '(' EnumeratedTypeElement ','... ')'
EnumeratedTypeElement -> Ident [ '=' ConstExpr ]
StringType -> STRING
-> ANSISTRING
-> WIDESTRING
-> STRING '[' ConstExpr ']'
StrucType -> [PACKED] (ArrayType | SetType | FileType | RecType [PACKED])
ArrayType -> ARRAY ['[' OrdinalType ','... ']'] OF Type [PortabilityDirective]
RecType -> RECORD [FieldList] END [PortabilityDirective]
FieldList -> FieldDecl ';'... [VariantSection] [';']
FieldDecl -> IdentList ':' Type [PortabilityDirective]
VariantSection -> CASE [Ident ':'] TypeId OF RecVariant ';'...
RecVariant -> ConstExpr ','... ':' '(' [FieldList] ')'
SetType -> SET OF OrdinalType [PortabilityDirective]
FileType -> FILE OF TypeId [PortabilityDirective]
PointerType -> '^' TypeId [PortabilityDirective]
ProcedureType -> (ProcedureHeading | FunctionHeading) [OF OBJECT]
VarSection -> VAR (VarDecl ';')...
VarDecl On Windows -> IdentList ':' Type [(ABSOLUTE (Ident | ConstExpr)) | '=' ConstExpr] [PortabilityDirective]
On Linux -> IdentList ':' Type [ABSOLUTE (Ident) | '=' ConstExpr] [PortabilityDirective]
Expression -> SimpleExpression [RelOp SimpleExpression]...
SimpleExpression -> ['+' | '-'] Term [AddOp Term]...
Term -> Factor [MulOp Factor]...
Factor -> Designator ['(' ExprList ')']
-> '@' Designator
-> Number
-> String
-> NIL
-> '(' Expression ')'
-> NOT Factor
-> SetConstructor
-> TypeId '(' Expression ')'
RelOp -> '>'
-> '<'
-> '<='
-> '>='
-> '<>'
-> IN
-> IS
-> AS
AddOp -> '+'
-> '-'
-> OR
-> XOR
MulOp -> '*'
-> '/'
-> DIV
-> MOD
-> AND
-> SHL
-> SHR
Designator -> QualId ['.' Ident | '[' ExprList ']' | '^']...
SetConstructor -> '[' [SetElement ','...] ']'
SetElement -> Expression ['..' Expression]
ExprList -> Expression ','...
Statement -> [LabelId ':'] [SimpleStatement | StructStmt]
StmtList -> Statement ';'
SimpleStatement -> Designator ['(' [ExprList] ')']
-> Designator ':=' Expression
-> INHERITED
-> GOTO LabelId
StructStmt -> CompoundStmt
-> ConditionalStmt
-> LoopStmt
-> WithStmt
-> TryExceptStmt
-> TryFinallyStmt
-> RaiseStmt
-> AssemblerStmt
CompoundStmt -> BEGIN StmtList END
ConditionalStmt -> IfStmt
-> CaseStmt
IfStmt -> IF Expression THEN Statement [ELSE Statement]
CaseStmt -> CASE Expression OF CaseSelector ';'... [ELSE StmtList] [';'] END
CaseSelector -> CaseLabel ','... ':' Statement
CaseLabel -> ConstExpr ['..' ConstExpr]
LoopStmt -> RepeatStmt
-> WhileStmt
-> ForStmt
RepeatStmt -> REPEAT Statement UNTIL Expression
WhileStmt -> WHILE Expression DO Statement
ForStmt -> FOR QualId ':=' Expression (TO | DOWNTO) Expression DO Statement
WithStmt -> WITH IdentList DO Statement
TryExceptStmt -> TRY
Statement...
EXCEPT
ExceptionBlock
END
ExceptionBlock -> [ON [Ident ':'] TypeID DO Statement]...
[ELSE Statement...]
TryFinallyStmt -> TRY
Statement
FINALLY
Statement
END
RaiseStmt -> RAISE [object] [AT address]
AssemblerStatement -> ASM
-> <assemblylanguage>
-> END
ProcedureDeclSection -> ProcedureDecl
-> FunctionDecl
ProcedureDecl -> ProcedureHeading ';' [Directive] [PortabilityDirective]
Block ';'
FunctionDecl -> FunctionHeading ';' [Directive] [PortabilityDirective]
Block ';'
FunctionHeading -> FUNCTION Ident [FormalParameters] ':' (SimpleType | STRING)
ProcedureHeading -> PROCEDURE Ident [FormalParameters]
FormalParameters -> '(' [FormalParm ';'...] ')'
FormalParm -> [VAR | CONST | OUT] Parameter
Parameter -> IdentList [':' ([ARRAY OF] SimpleType | STRING | FILE)]
-> Ident ':' SimpleType '=' ConstExpr
Directive -> CDECL
-> REGISTER
-> DYNAMIC
-> VIRTUAL
-> EXPORT
-> EXTERNAL
-> NEAR
-> FAR
-> FORWARD
-> MESSAGE ConstExpr
-> OVERRIDE
-> OVERLOAD
-> PASCAL
-> REINTRODUCE
-> SAFECALL
-> STDCALL
-> VARARGS
-> LOCAL
-> ABSTRACT
ObjectType -> OBJECT [ObjHeritage] [ObjFieldList] [MethodList] END
ObjHeritage -> '(' QualId ')'
MethodList -> (MethodHeading [';' VIRTUAL]) ';'...
MethodHeading -> ProcedureHeading
-> FunctionHeading
-> ConstructorHeading
-> DestructorHeading
ConstructorHeading -> CONSTRUCTOR Ident [FormalParameters]
DestructorHeading -> DESTRUCTOR Ident [FormalParameters]
ObjFieldList -> (IdentList ':' Type) ';'
InitSection -> INITIALIZATION StmtList [FINALIZATION StmtList] END
-> BEGIN StmtList END
-> END
ClassType -> CLASS [ClassHeritage]
[ClassVisibility]
[ClassFieldList]
[ClassMethodList]
[ClassPropertyList]
END
ClassHeritage -> '(' IdentList ')'
ClassVisibility -> [PUBLIC | PROTECTED | PRIVATE | PUBLISHED]
ClassFieldList -> (ClassVisibility ObjFieldList) ';'...
ClassMethodList -> (ClassVisibility MethodList) ';'...
ClassPropertyList -> (ClassVisibility PropertyList ';')...
PropertyList -> PROPERTY Ident [PropertyInterface] [PropertySpecifiers] [PortabilityDirective]
PropertyInterface -> [PropertyParameterList] ':' Ident
PropertyParameterList -> '[' (IdentList ':' TypeId) ';'... ']'
PropertySpecifiers -> [INDEX ConstExpr]
[READ Ident]
[WRITE Ident]
[STORED (Ident | Constant)]
[(DEFAULT ConstExpr) | NODEFAULT]
[IMPLEMENTS TypeId]
InterfaceType -> INTERFACE [InterfaceHeritage]
[ClassMethodList]
[ClassPropertyList] ...
END
InterfaceHeritage -> '(' Ident ')'
RequiresClause -> REQUIRES IdentList... ';'
ContainsClause -> CONTAINS IdentList... ';'
IdentList -> Ident ','...
QualId -> [UnitId '.'] Ident
TypeId -> [UnitId '.'] <type-identifier>
Ident -> <identifier>
ConstExpr -> <constant-expression>
UnitId -> <unit-identifier>
LabelId -> <label-identifier>
Number -> <number>
String -> <string>