2
lex.setIdExtraSymbols("_");
3
lex.addMarkup("{", "}", "", lex.LexemeType.Comment);
4
lex.addMarkup("(*", "*)", "", lex.LexemeType.Comment);
5
lex.addMarkup("//", "", "", lex.LexemeType.Comment);
6
lex.addMarkup("'", "'", "", lex.LexemeType.Annotation);
8
lex.addMask("@BUILDING_NUMBER_MASK", lex.LexemeType.Number, 10);
13
program = program_heading ";" program_block ".";
17
program_heading = "program" ID
18
= "program" ID "(" program_parameter_list ")";
21
= "program_parameter_list" ;
23
block = __declaration_part_list__ statement_part
26
__declaration_part_list__
27
= __declaration_part_list__ __one_declaration_part__ | __one_declaration_part__;
29
__one_declaration_part__
30
= label_declaration_part | constant_definition_part | type_definition_part
31
variable_declaration_part | procedure_and_function_declaration_part;
38
= "label" __label_list__ ";";
40
__label_list__ = __label_list__ "," label | label;
42
label = digit_sequence;
44
digit_sequence = NUMBER;
50
constant_definition_part
51
= "const" __constant_definition_list__ ";";
53
__constant_definition_list__
54
= __constant_definition_list__ ";" constant_definition | constant_definition;
57
= /*identifier*/ID "=" constant ;
62
= /*constant_identifier*/ID
63
// = sign unsigned_number
64
= sign /*constant_identifier*/ID
67
//unsigned_number = NUMBER;
69
//unsigned_integer = digit_sequence;
71
//unsigned_real = digit_sequence "." fractional_part
72
// = digit_sequence "." fractional_part "e" scale_factor
73
// = digit_sequence "e" scale_factor;
75
//fractional_part = digit_sequence;
77
//scale_factor = digit_sequence
78
// = sign digit_sequence;
94
= "type" __type_definition_list__ ";" ;
96
__type_definition_list__
97
= __type_definition_list__ ";" type_definition | type_definition;
100
= /*identifier*/ID "=" type_denoter ;
102
type_denoter = /*type_identifier*/ID
105
//type_identifier = identifier;
107
new_type = new_ordinal_type | new_structured_type | new_pointer_type;
110
= enumerated_type | subrange_type;
113
= "(" identifier_list ")";
115
identifier_list = identifier_list "," /*identifier*/ID | /*identifier*/ID;
117
subrange_type = constant ".." constant;
120
= unpacked_structured_type
121
= "packed" unpacked_structured_type;
123
unpacked_structured_type
124
= array_type | record_type | set_type | file_type;
126
array_type = "array" "[" __index_type_list__ "]" "of" component_type;
129
= __index_type_list__ "," index_type | index_type;
131
index_type = ordinal_type;
133
ordinal_type = new_ordinal_type | /*ordinal_type_identifier*/ID;
135
ordinal_type_identifier
136
= /*type_identifier*/ID;
138
component_type = type_denoter;
140
record_type = "record" field_list "end"
143
field_list = fixed_part
145
= fixed_part ";" variant_part
146
= fixed_part ";" variant_part ";"
150
fixed_part = __record_section_list__ <;
152
__record_section_list__
153
= __record_section_list__ ";" record_section | record_section;
155
record_section = identifier_list ":" type_denoter;
157
variant_part = "case" variant_selector "of" __variant_list__ <;
161
= tag_field ":" tag_type;
163
tag_field = /*identifier*/ID;
165
tag_type = ordinal_type_identifier;
168
= __variant_list__ ";" variant | variant;
170
variant = case_constant_list ":" "(" field_list ")"
171
= case_constant_list ":" "(" ")";
174
= case_constant_list "," case_constant | case_constant;
176
case_constant = constant;
178
set_type = "set" "of" base_type;
180
base_type = ordinal_type;
182
file_type = "file" "of" component_type;
185
= "↑" /*domain_type*/ID;
187
//domain_type = type_identifier;
193
variable_declaration_part
194
= "var" __variable_declaration_list__ ";";
196
__variable_declaration_list__
197
= __variable_declaration_list__ ";" variable_declaration | variable_declaration;
200
= identifier_list ":" type_denoter;
202
procedure_and_function_declaration_part
203
= __procedure_or_function_declaration__ ";" <
204
= __procedure_or_function_declaration__ ";" procedure_and_function_declaration_part;
206
__procedure_or_function_declaration__
207
= procedure_declaration | function_declaration;
210
= procedure_heading ";" directive
211
= /*procedure_identification*/"procedure" ID ";" procedure_block
212
= procedure_heading ";" procedure_block;
215
// = "procedure" /*identifier*/ID
216
// = "procedure" /*identifier*/ID formal_parameter_list;
219
= "(" __formal_parameter_section_list__ ")";
221
__formal_parameter_section_list__
222
= __formal_parameter_section_list__ ";" formal_parameter_section | formal_parameter_section;
225
formal_parameter_section
226
= value_parameter_specification | variable_parameter_specification | procedural_parameter_specification |functional_parameter_specification;
228
formal_parameter_section
229
= conformant_array_parameter_specification;
231
conformant_array_parameter_specification
232
= value_conformant_array_specification | variable_conformant_array_specification;
234
value_conformant_array_specification
235
= identifier_list ":" conformant_array_schema;
237
conformant_array_schema
238
= packed_conformant_array_schema | unpacked_conformant_array_schema;
240
packed_conformant_array_schema
241
= "packed" "array" "[" index_type_specification "]" "of" /*type_identifier*/ID;
243
index_type_specification
244
= /*identifier*/ID ".." /*identifier*/ID ":" /*ordinal_type_identifier*/ID;
246
unpacked_conformant_array_schema
247
= "array" "[" __index_type_specification_list__ "]" "of" /*type_identifier*/ID
248
= "array" "[" __index_type_specification_list__ "]" "of" conformant_array_schema ;
250
__index_type_specification_list__
251
= __index_type_specification_list__ ";" index_type_specification | index_type_specification ;
253
value_parameter_specification
254
= identifier_list ":" /*type_identifier*/ID;
256
variable_parameter_specification
257
= "var" identifier_list ":" /*type_identifier*/ID;
259
procedural_parameter_specification
262
functional_parameter_specification
266
= "function" /*identifier*/ID ":" ID//result_type
267
= "function" /*identifier*/ID formal_parameter_list ":" ID;//result_type;
269
//result_type = simple_type_identifier | pointer_type_identifier;
271
//simple_type_identifier
274
//pointer_type_identifier
279
//procedure_identification
280
// = "procedure" ID;//procedure_identifier;
286
= "procedure" /*identifier*/ID <
287
= "procedure" /*identifier*/ID formal_parameter_list;
289
procedure_block = block;
292
= function_heading ";" directive | function_identification ";" function_block | function_heading ";" function_block;
294
function_identification
295
= "function" function_identifier;
300
function_block = block;
302
variable_conformant_array_specification
303
= "var" identifier_list ":" conformant_array_schema;
309
statement_part = compound_statement;
313
= "begin" statement_sequence "end";
316
= statement_sequence ";" statement | statement_sequence ";" | statement
317
= statement_sequence ";"
320
statement = simple_statement | structured_statement
321
= label ":" simple_statement
322
= label ":" structured_statement
326
= /*empty_statement |*/ assignment_statement | procedure_statement | goto_statement ;
328
//empty_statement = "empty_statement";//----------------------------6 .8 .2.1 пустой
331
= variable_access ":=" expression
332
= function_identifier ":=" expression;
334
variable_access = entire_variable | component_variable;// | identified_variable | buffer_variable ;
336
entire_variable = variable_identifier;
342
= indexed_variable | field_designator;
345
= array_variable "[" __index_expression_list__ "]";
347
array_variable = variable_access;
349
__index_expression_list__
350
= __index_expression_list__ "," index_expression | index_expression;
356
= record_variable "." ID /*field_specifier*/;// | field_designator_identifier;
358
record_variable = variable_access;
360
//field_specifier = field_identifier;
365
//field_designator_identifier
369
// = pointer_variable "↑" ;
374
//buffer_variable = file_variable "↑" ;
376
file_variable = variable_access;
378
expression = simple_expression
379
= simple_expression relational_operator simple_expression;
382
= __adding_operator_term_list__
383
= sign __adding_operator_term_list__;
385
term = __multiplying_operator_factor_list__;
387
__multiplying_operator_factor_list__
388
= __multiplying_operator_factor_list__ multiplying_operator factor
391
factor = "ID";//identifier;
394
= "*" | "/" | "div" | "mod" | "and";
396
__adding_operator_term_list__
397
= __adding_operator_term_list__ adding_operator term
400
adding_operator = "+" | "-" | "or" ;
403
= "=" | "<>" | "<" | ">" | "<=" | ">=" | "in" ;
406
= procedure_identifier
407
= procedure_identifier actual_parameter_list
408
= procedure_identifier read_parameter_list
409
= procedure_identifier readln_parameter_list
410
= procedure_identifier write_parameter_list
411
= procedure_identifier writeln_parameter_list;
414
= "(" __actual_parameter_list__ ")";
416
__actual_parameter_list__
417
= __actual_parameter_list__ "," "actual_parameter" | "actual_parameter" ;
420
// = "expression" | variable_access | procedure_identifier | function_identifier;
423
= "(" __variable_access_list__ ")"
424
= "(" file_variable "," __variable_access_list__ ")";
426
__variable_access_list__
427
= __variable_access_list__ "," "variable_access" | "variable_access";
430
= "(" file_variable __variable_access_list__ ")";
433
= "(" __write_parameter_list__ ")"
434
= "(" file_variable "," __write_parameter_list__ ")";
436
__write_parameter_list__
437
= __write_parameter_list__ "," write_parameter | write_parameter;
439
write_parameter = expression
440
= expression ":" expression
441
= expression ":" expression ":" expression;
443
writeln_parameter_list
444
= "(" file_variable __write_parameter_list__")" ;
446
goto_statement = "goto" label;
449
= compound_statement | conditional_statement | repetitive_statement | with_statement;
452
= if_statement | case_statement;
454
if_statement = "if" boolean_expression "then" statement >
455
= "if" boolean_expression "then" statement else_part;
460
else_part = "else" statement;
462
case_statement = "case" case_index "of" __case_list_element_list__ "end"
463
= "case" case_index "of" __case_list_element_list__ ";" "end";
465
case_index = expression;
467
__case_list_element_list__
468
= __case_list_element_list__ ";" case_list_element | case_list_element;
471
= case_constant_list ":" statement;
474
= case_constant_list "," case_constant | case_constant;
476
case_constant = constant;
479
= repeat_statement | while_statement | for_statement;
482
= "repeat" statement_sequence "until" boolean_expression;
484
while_statement = "while" boolean_expression "do" statement;
486
for_statement = "for" control_variable ":=" initial_value "to" final_value "do" statement
487
= "for" control_variable ":=" initial_value "downto" final_value "do" statement;
492
initial_value = expression;
494
final_value = expression;
496
with_statement = "with" __record_variable_list__ "do" statement;
498
__record_variable_list__
499
= __record_variable_list__ "," record_variable | record_variable;