source: branches/Analyzátor gramatiky/grammer/PS.grm

Last change on this file was 10, checked in by george, 16 years ago

Přesunuto: analýza gramatiky do branches.
Přidáno: Hlavní větev překladač pascalu pro AVR.

File size: 4.5 KB
Line 
1program= program_heading block '.' .
2 identifier_list= NAME { ',' NAME } .
3 program_heading= PROGRAM NAME '(' identifier_list ')' ';' .
4
5 block= declaration_part statement_part .
6
7 constant= [ '+' | '-' ] ( CONSTANT_NAME | NUMBER ) | STRING .
8
9 type= simple_type | structured_type | TYPE_NAME .
10 simple_type= constant '..' constant.
11 structured_type= array_type | record_type .
12 array_type= ARRAY '[' index_type { ',' index_type } ']' OF
13 element_type .
14 index_type= simple_type .
15 element_type= type .
16 record_type= RECORD field_list END .
17 field_list= record_section { ';' record_section } .
18 record_section= identifier_list ':' type .
19
20 declaration_part= [ constant_definition_part ]
21 [ type_definition_part ] [ variable_declaration_part ]
22 procedure_and_function_declaration_part .
23 constant_definition_part= CONST constant_definition ';'
24 { constant_definition ';' } .
25 constant_definition= NAME '=' constant .
26 type_definition_part= TYPE type_definition ';' { type_definition ';' } .
27 type_definition= NAME '=' type .
28 variable_declaration_part= VAR variable_declaration ';'
29 { variable_declaration ';' } .
30 variable_declaration= identifier_list ':' type .
31 procedure_and_function_declaration_part=
32 { ( procedure_declaration | function_declaration ) ';' } .
33 formal_parameter_list= '(' formal_parameter_section
34 { ';' formal_parameter_section } ')' .
35 formal_parameter_section= [ VAR ]identifier_list ':' parameter_type .
36 parameter_type= TYPE_NAME .
37 procedure_heading= PROCEDURE NAME [ formal_parameter_list ] .
38 function_heading= FUNCTION NAME [ formal_parameter_list ] ':' result_type .
39 result_type= TYPE_NAME .
40
41 procedure_declaration= procedure_heading ';' block.
42 function_declaration= function_heading ';' block .
43
44 statement_part= BEGIN statement_sequence END .
45 statement_sequence= statement { ';' statement } .
46
47 expression= F .
48 expression_list= expression { ',' expression } .
49
50 variable_access= ACCESS_NAME { end_access } .
51 end_access= { array_access | record_access | function_parameters } .
52 array_access= '[' expression_list ']' .
53 record_access= '.' variable_access .
54 function_parameters= '(' [ expression_list ] ')' .
55
56 actual_parameter_list= '(' expression { ',' expression } ')' .
57
58 expression= simple_expression [ relational_operator simple_expression ] .
59 relational_operator= '=' | '<>' | '<' | '<=' | '>' | '>=' .
60 simple_expression= [ '+' | '-' ] term { addition_operator term } .
61 addition_operator= '+' | '-' | OR .
62 term= factor { multiplication_operator factor } .
63 multiplication_operator= '*' | '/' | DIV | MOD | AND .
64 factor= NUMBER | STRING | CONSTANT_NAME
65 | variable_access | function_designator
66 | '(' expression ')' | NOT factor .
67 function_designator= FUNCTION_NAME [ actual_parameter_list ] .
68
69 statement= ( simple_statement | structured_statement ) .
70 simple_statement= [ assignment_statement | procedure_statement ] .
71 assignment_statement= ( variable_access | FUNCTION_NAME ) ':=' expression .
72 procedure_statement= PROCEDURE_NAME [ actual_parameter_list ] .
73 structured_statement= compound_statement | repetitive_statement
74 | conditional_statement .
75 compound_statement= BEGIN statement_sequence END .
76 repetitive_statement= while_statement | repeat_statement
77 | for_statement .
78 while_statement= WHILE expression DO statement .
79 repeat_statement= REPEAT statement_sequence UNTIL expression .
80 for_statement= FOR VARIABLE_NAME ':=' initial_expression
81 ( TO | DOWNTO ) final_expression DO statement .
82 initial_expression= expression .
83 final_expression= expression .
84 conditional_statement= if_statement | case_statement .
85 if_statement= IF expression THEN statement [ ELSE statement ] .
86 case_statement= CASE expression OF
87 case_element { ';' case_element } [ ';' ] END .
88 case_element= case_label_list ':' statement .
89 case_label_list= constant { ',' constant } .
90.
Note: See TracBrowser for help on using the repository browser.