Синтаксис языка EXPRESS-X
В настоящем приложении определены лексические элементы языка и грамматические правила, которым данные элементы должны подчиняться.
Примечание - Прямое применение данного определения синтаксиса приведет к неоднозначности при построении синтаксических анализаторов. Данное определение разработано для представления информации, относящейся к использованию идентификаторов. Интерпретированные идентификаторы определяют лексические элементы, являющиеся ссылками на объявленные идентификаторы, и поэтому не должны трактоваться как простые идентификаторы (simple_id). Разработчик синтаксического анализатора должен обеспечить разрешение ссылок на идентификаторы и получение необходимого ссылочного лексического элемента для проверки грамматических правил.
Все грамматические правила языка EXPRESS, определенные в ИСО 10303-11, приложение А, являются также грамматическими правилами языка EXPRESS-X. Помимо грамматических правил языка EXPRESS к грамматическим правилам языка EXPRESS-X относятся грамматические правила, определенные в данном приложении.
В.1 Лексические элементы
Приведенные ниже правила определяют лексические элементы, используемые в языке EXPRESS-X. За исключением тех случаев, когда это явно установлено в синтаксических правилах, никакие пробелы или комментарии не должны присутствовать в тексте, относящемся к отдельному синтаксическому правилу, представленному в настоящем приложении.
В.1.1 Ключевые слова
В настоящем подразделе установлены правила, используемые для представления ключевых слов языка EXPRESS-X.
Примечание - В настоящем подразделе используется соглашение, по которому каждое ключевое слово представлено синтаксическим правилом, содержащим в левой части данное ключевое слово, записанное с использованием символов верхнего регистра (прописных букв).
Зарезервированными словами языка EXPRESS-X являются зарезервированные слова языка EXPRESS, а также ключевые слова и имена встроенных функций языка EXPRESS-X. Зарезервированные слова языка EXPRESS-X не должны использоваться как идентификаторы.
1 | DEPENDENT_MAP = 'dependent_map' . |
2 | EACH = 'each' . |
3 | ELSEIF = 'elseif' . |
4 | END_DEPENDENT_MAP = 'end_dependent_map' . |
5 | END_MAP = 'end_map' . |
6 | END_SCHEMA_MAP = 'end_schema_map' . |
7 | END_SCHEMA_VIEW = 'end_schema_view' . |
8 | END_VIEW = 'end_view' . |
9 | EXTENT = 'extent' . |
10 | IDENTIFIED_BY = 'identified_by' . |
11 | INDEXING = 'indexing' . |
12 | MAP = 'map'. |
13 | ORDERED_BY = 'ordered_by' . |
14 | PARTITION = 'partition' . |
15 | SCHEMA_MAP = 'schema_map' . |
16 | SCHEMA_VIEW = 'schema_view' . |
17 | SOURCE = 'source' . |
18 | TARGET = 'target' . |
19 | VIEW = 'view'. |
B.1.2 Классы символов
20 | digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' . |
21 | letter = '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' . |
22 | simple_id = letter { letter | digit | '_' } . |
В.1.3 Интерпретированные идентификаторы
Примечание - Все интерпретированные идентификаторы языка EXPRESS являются также интерпретированными идентификаторами языка EXPRESS-X. Кроме того, в языке EXPRESS-X используются следующие интерпретированные идентификаторы.
23 | partition_ref = partition_id. |
24 | map_ref = map_id. |
25 | schema_map_ref = schema_map_id. |
26 | schema_view_ref = schema_view_id. |
27 | source_parameter_ref = source_parameter_id. |
28 | source_schema_ref = schema_ref. |
29 | target_parameter_ref = target_parameter_id. |
30 | target_schema_ref = schema_ref. |
31 | view_attribute_ref = view_attribute_id. |
32 | view_ref = view_id. |
B.2 Грамматические правила
Представленные в данном разделе правила определяют, как рассмотренные выше лексические элементы и лексические элементы языка EXPRESS могут объединяться в конструкции языка EXPRESS-X. Пробелы и комментарии языка EXPRESS могут быть помещены между любыми двумя лексемами в данных правилах. Первичным синтаксическим правилом языка EXPRESS-X является syntax_х.
33 | abstract_supertype_declaration = ABSTRACT SUPERTYPE [ subtype_constraint ] . |
34 | actual_parameter_list = '(' parameter { ',' parameter } ')' . |
35 | add_like_op = '+' | '-' | OR | XOR . |
36 | aggregate_initializer = '[' [ element { ',' element } ] ']' . |
37 | aggregate_source = simple_expression . |
38 | aggregate_type = AGGREGATE [ ':' type_label ] OF parameter_type . |
39 | aggregation_types = array_type | bag_type | list_type | set_type . |
40 | algorithm_head = { declaration } [ constant_decl ] [ local_decl ] . |
41 | array_type = ARRAY bound_spec OF [ OPTIONAL ] [ UNIQUE ] base_type . |
42 | assignment_stmt = general_ref { qualifier } ':=' expression ';' . |
43 | backward_path_qualifier = '<-' ; attribute_ref ] path_condition . |
44 | bag_type = BAG [ bound_spec ] OF base_type . |
45 | base_type = aggregation_types | simple_types | named_types . |
46 | binary_type = BINARY [ width_spec ] . |
47 | binding_header = [ PARTITION partition_id ';' ] [ from_clause ] |
48 | boolean_type = BOOLEAN . |
49 | bound_1 = numeric_expression . |
50 | bound_2 = numeric_expression . |
51 | bound_spec = '[' bound_1 ':' bound_2 ']' . |
52 | built_in_constant = CONST_E | PI | SELF | '?' . |
53 | built_in_function = ABS | ACOS | ASIN | ATAN | BLENGTH | COS |
54 | built_in_procedure = INSERT | REMOVE . |
55 | case_action = case_label { ',' case_label } ':' stmt . |
56 | case_expr = CASE selector OF { case_expr_action } [ OTHERWISE ':' |
57 | case_expr_action = case_label { ',' case_label } ':' expression ';' . |
58 | case_label = expression . |
59 | case_stmt = CASE selector OF { case_action } [ OTHERWISE ':' stmt ] END_CASE ';' . |
60 | compound_stmt = BEGIN stmt { stmt } END ';' . |
61 | constant_body = constant_id ':' base_type ':=' expression ';' . |
62 | constant_decl = CONSTANT constant_body { constant_body } END_CONSTANT ';' . |
63 | constant_factor = built_in_constant | constant_ref . |
64 | constant_id = simple_id . |
65 | declaration = function_decl | procedure_decl . |
66 | dependent_map_decl = DEPENDENT_MAP map_id AS target_parameter { |
67 | dependent_view_decl = VIEW view_id ':' base_type ';' binding_header |
68 | dep_binding_decl = dep_from_clause [ where clause ] [ ordered_by_clause ] . |
69 | dep_from_clause = FROM dep_source_parameter ';' { dep_source_parameter ';' } . |
70 | dep_map_decl_body = dep_binding_decl map_project_clause . |
71 | dep_map_partition = [ PARTITION partition_id ':' ] dep_map_decl_body . |
72 | dep_source_parameter = source_parameter_id { ',' |
73 | domain_rule = [ label ':' ] logical_expression . |
74 | element = expression [ ':' repetition ] . |
75 | entity_constructor = entity_reference '(' [ expression { ',' expression } ] ')' . |
76 | entity_id = simple_id . |
77 | entity_instantiation_loop = FOR instantiation_loop_control ';' map_project_clause . |
78 | entity_reference = [ ( source_schema_ref | target_schema_ref | schema ref ) '.' ] entity_ref . |
79 | enumeration_reference = [ type_reference '.' ] enumeration_ref . |
80 | escape_stmt = ESCAPE ';' . |
81 | expression = simple_expression [ rel_op_extended simple_expression ] . |
82 | expression_or_wild = expression | '_' . |
83 | extent_reference = source_entity_reference | view_reference . |
84 | factor = simple_factor [ '**' simple_factor ] . |
85 | foreach_expr = EACH variable_id IN expression [ where_clause ] RETURN expression . |
86 | forloop_expr = repeat_control RETURN expression . |
87 | formal_parameter = parameter_id { ',' parameter_id } ':' parameter_type . |
88 | forward_path_qualifier = ':: ' attribute_ref [ path_condition ] . |
89 | for_expr = FOR ( foreach_expr | forloop_expr ) . |
90 | from_clause = FROM source_parameter ';' { source_parameter ';' } . |
91 | function_call = ( built_in_function | function_ref ) [ actual_parameter_list ] . |
92 | function_decl = function_head [ algorithm_head ] stmt { stmt } END_FUNCTION ';' . |
93 | function_head = FUNCTION function_id [ ,(, formal_parameter { ';' |
94 | function_id = simple_id . |
95 | generalized_types = aggregate_type | general_aggregation_types | generic_type . |
96 | general_aggregation_types = general_array_type | general_bag_type | |
97 | general_array_type = ARRAY [ bound_spec ] OF [ OPTIONAL ] [ UNIQUE ] parameter_type . |
98 | general_attribute_qualifier = '. ' ( attribute_ref | view_attribute_ref ) . |
99 | general_bag_type = BAG [ bound_spec ] OF parameter_type . |
100 | general_list_type = LIST [ bound_spec ] OF [ UNIQUE ] parameter_type . |
101 | general_ref = parameter_ref | variable_ref | source_parameter_ref . |
102 | general_schema_alias_id = schema_id | schema_map_id | schema_view_id . |
103 | general_schema_ref = schema_ref | schema_map_ref | schema_view_ref . |
104 | general_set_type = SET [ bound_spec ] OF parameter_type . |
105 | generic_type = GENERIC [ ':' type_label ] . |
106 | group qualifier = '\' entity_ref . |
107 | identified_by_clause = IDENTIFIED_BY id_parameter ';' { id_parameter '; } . |
108 | id_parameter = [ id_parameter_id ,:' ] expression . |
109 | id_parameter_id = slmple_id . |
110 | if_expr = IF logical_expression THEN expression { ELSIF |
111 | if_stmt = IF logical_expression THEN stmt { stmt } [ ELSE stmt { stmt } ] END_IF ';' . |
112 | increment = numeric_expression. |
113 | increment_control = variable_id ,:=' bound_1 TO bound_2 [ BY increment ]. |
114 | index = numeric_expression. |
115 | index_1 = index. |
116 | index_2 = index. |
117 | index_qualifier = ,[, index_1 [ ':' index_2] ']'. |
118 | instantiation_foreach_control = EACH variable_id IN expression { |
119 | instantiation_loop_control = instantiation_foreach_control | repeat_control. |
120 | integer_type = INTEGER. |
121 | interval = '{' interval_low interval_op interval_item interval_op interval_high '}'. |
122 | interval_high = simple_expression. |
123 | interval_item = simple_expression. |
124 | interval_low = simple_expression. |
125 | interval_op = '<' | '<='. |
126 | label = simple_id. |
127 | list_type = LIST [ bound_spec ] OF [ UNIQUE ] base_type. |
128 | literal = binary_literal | integer_literal | logical_literal | real_literal | string_literal. |
129 | local_decl = LOCAL local_variable { local_variable } END_LOCAL ';'. |
130 | local_variable = variable_id { '.' variable_id } ':' parameter_type [ ':=' expression ] ';'. |
131 | logical_expression = expression. |
132 | logical_literal = FALSE | TRUE | UNKNOWN. |
133 | logical_type = LOGICAL. |
134 | map_attribute_declaration = [ target_parameter_ref [ index_qualifier ] [ group_qualifier ] '.' ] attrlbute_ref [ index_qualifier ] ':=' expression ';'. |
135 | map_call = [ target_parameter_ref '@' ] map_reference [ partition_qualification ] '(' expression_or_wild { ',' expression_or_wild } ')'. |
136 | map_decl = MAP map_id AS target_parameter ';' { target_parameter ';' } ( map_subtype_of_clause subtype_binding_header map_decl_body ) | ( binding_header map_decl_body { binding_header map_decl_body } ) END MAP ';'. |
137 | map_decl_body = ( entity_instantiation_loop { entity_instantiation_ loop } ) |
138 | map_id = simple_id. |
139 | map_project_clause = SELECT { map_attribute_declaration }. |
140 | map_reference = [ schema_map_ref '.' ] map_ref. |
141 | map_subtype_of_clause = SUBTYPE OF '(' map_reference ')' ';'. |
142 | multiplication_like_op = '*' | '/' | DIV | MOD | AND | '||'. |
143 | named_types = entity_reference | type_reference | view_reference. |
144 | null_stmt = ';'. |
145 | number_type = NUMBER. |
146 | numeric_expression = simple_expression. |
147 | one_of = ONEOF '(' supertype_expression { ',' supertype_expression } ')'. |
148 | ordered_by_clause = ORDERED_BY expression { ',' expression } ';'. |
149 | parameter = expression. |
150 | parameter_id = simple_id. |
151 | parameter_type = generalized_types | named_types | simple_types. |
152 | partition_id = simple_id. |
153 | partition_qualification = '\' partition_ref. |
154 | path_condition = '{' extent_reference [ '|' logical_expression ] '}'. |
155 | path_qualifier = forward_path_qualifier | backward_path_qualifier. |
156 | population = entity_reference. |
157 | precision_spec = numeric_expression. |
158 | primary = literal | ( qualifiable_factor { qualifier } ). |
159 | procedure_call_stmt = ( built_in_procedure | procedure_ref ) [ actual_parameter_list ] ';'. |
160 | procedure_decl = procedure_head [ algorithm_head ] { stmt } END_PROCEDURE ';'. |
161 | procedure_head = PROCEDURE procedure_id [ ,(, [ VAR ] |
162 | procedure_id = simple_id. |
163 | qualifiable_factor = attribute_ref | constant_factor | function_call | general_ref | map_call | population | target_parameter_ref | view_attribute_ref | view_call. |
164 | qualifier = general_attribute_qualifier | group_qualifier | index_qualifier | path_qualifier. |
165 | query_expression = QUERY '(' variable_id '<*' aggregate_source '|' logical_expression ')'. |
166 | real_type = REAL ['(' precision_spec ')' ]. |
167 | reference_clause = REFERENCE FROM schema_ref_or_rename [ '(' |
168 | rel_op = '<' | ' >' | '<=' | '>=' | '<>' | '=' | ':<>:' | ':=:'. |
169 | rel_op_extended = rel_op | IN | LIKE. |
170 | rename_id = constant_id | entity_id | function_id | procedure_id | type_id. |
171 | repeat_control = [ increment_control ] [ while_control ] [ until_control ]. |
172 | repeat_stmt = REPEAT repeat_control ';' stmt { stmt } END_REPEAT ';'. |
173 | repetition = numeric_expression. |
174 | resource_or_rename = resource_ref [ AS rename_id ]. |
175 | resource_ref = constant_ref | entity_ref | function_ref | procedure_ ref | type_ref | view_ref | map_ref. |
176 | return_stmt = RETURN [ '(' expression ')' ] ';'. |
177 | root_view_decl = VIEW view_id [ supertype_constraint ] ';' binding_header SELECT view_attr_decl_stmt_list { binding_header SELECT view_attr_decl_stmt_list } END_VIEW ';'. |
178 | rule_decl = rule_head [ algorithm_head ] { stmt } where_clause END_RULE ';'. |
179 | rule_head = RULE rule_id FOR '(' entity_ref { ',' entity_ref } ')' ';'. |
180 | rule_id = simple_id. |
181 | schema_id = simple_id. |
182 | schema_map_body_element = function_decl | procedure_decl | view_decl | map_decl | dependent_map_decl | rule_decl. |
183 | schema_map_body_element_list = schema_map_body_element { |
184 | schema_map_decl = SCHEMA_MAP schema_map_id ';' reference_clause { reference_clause } [ constant_decl ] schema_map_body_element_list END_SCHEMA_MAP ';'. |
185 | schema_map_id = simple_id. |
186 | schema_ref_or_rename = [ general_schema_alias_id ':' ] general_schema_ref. |
187 | schema_view_body_element = function_decl | procedure_decl | view_decl | rule_decl. |
188 | schema_view_body_element_list = schema_view_body_element { |
189 | schema_view_decl = SCHEMA_VIEW schema_view_id ';' { |
190 | schema_view_id = simple_id. |
191 | selector = expression. |
192 | set_type = SET [ bound_spec ] OF base_type. |
193 | simple_expression = term { add_like_op term }. |
194 | simple_factor = aggregate_initializer | entity_constructor | enumeration_reference | interval | query_expression | ( [ unary_op ] ( '(' expression ')' | primary ) ) | case_expr | for_expr | if_expr. |
195 | simple_types = binary_type | boolean_type | integer_type | |
196 | skip_stmt = SKIP ';'. |
197 | source_entity_reference = entity_reference. |
198 | source_parameter = source_parameter_id ':' extent_reference. |
199 | source_parameter_id = simple_id. |
200 | stmt = assignment_stmt | case_stmt | compound_stmt | escape_stmt | if_stmt | null_stmt | procedure_call_stmt | repeat_stmt | return_stmt | skip_stmt. |
201 | string_literal = simple_string_literal | encoded_string_literal. |
202 | string_type = STRING [ width_spec ]. |
203 | subtype_binding_header = [ PARTITION partition_id ';' ] where_clause. |
204 | subtype_constraint = OF '(' supertype_expression ')'. |
205 | subtype_declaration = SUBTYPE OF '(' view_ref { ',' view_ref } ')'. |
206 | subtype_view_decl = VIEW view_id subtype_declaration ';' |
207 | supertype_constraint = abstract_supertype_declaration | supertype_rule. |
208 | supertype_expression = supertype_factor { ANDOR supertype_factor }. |
209 | supertype_factor = supertype_term { AND supertype_term }. |
210 | supertype_rule = SUPERTYPE [ subtype_constraint ]. |
211 | supertype_term = view_ref | one_of | '(' supertype_expression ')'. |
212 | syntax_x = schema_map_decl | schema_view_decl. |
213 | target_entity_reference = entity_reference { '&' entity_reference ). |
214 | target_parameter = target_parameter_id { ',' target_parameter_id } |
215 | target_parameter_id = simple_id ';'. |
216 | term = factor { multiplication_like_op factor }. |
217 | type_id = simple_id. |
218 | type_label = type_label_id | type_label_ref. |
219 | type_label_id = simple_id. |
220 | type_reference = [ schema_ref '.' ] type_ref. |
221 | unary_op = '+' | '-' | NOT. |
222 | until_control = UNTIL logical_expression. |
223 | variable_id = simple_id. |
224 | view_attribute_decl = view_attribute_id ':' [ OPTIONAL ] [ |
225 | view_attribute_id = simple_id. |
226 | view_attr_decl_stmt_list = { view_attribute_decl }. |
227 | view_call = view_reference [ partition_qualification ] '(' [ |
228 | view_decl = ( root_view_decl | dependent_view_decl | subtype_view_decl ). |
229 | view_id = simple_id. |
230 | view_reference = [ ( schema_map_ref | schema_view_ref ) '.' ] view_ref. |
231 | where_clause = WHERE domain_rule ';' { domain_rule ';' ). |
232 | while_control = WHILE logical_expression. |
233 | width = numeric_expression. |
234 | width_spec = '(' width ')' [ FIXED ]. |
B.3 Список перекрестных ссылок