/[eiffelstudio]/branches/CAT_mono/Src/framework/parser/parser/eiffel.y
ViewVC logotype

Contents of /branches/CAT_mono/Src/framework/parser/parser/eiffel.y

Parent Directory Parent Directory | Revision Log Revision Log


Revision 69650 - (show annotations)
Tue Jul 24 17:18:14 2007 UTC (12 years, 4 months ago) by juliant
File size: 88208 byte(s)
Added monomorph mark for class types, either "frozen" or "invariant".
First (simple) conformance check for monomorphic types.
1
2 %{
3 indexing
4
5 description: "Eiffel parsers"
6 legal: "See notice at end of class."
7 status: "See notice at end of class."
8 date: "$Date$"
9 revision: "$Revision$"
10
11 class EIFFEL_PARSER
12
13 inherit
14
15 EIFFEL_PARSER_SKELETON
16
17 create
18 make,
19 make_with_factory
20 %}
21
22 %start Eiffel_parser
23
24 %nonassoc TE_ASSIGNMENT
25 %nonassoc TE_DOTDOT
26 %left TE_IMPLIES
27 %left TE_OR
28 %left TE_XOR
29 %left TE_AND
30 %left TE_NE TE_EQ TE_LT TE_GT TE_LE TE_GE
31 %left TE_PLUS TE_MINUS
32 %left TE_STAR TE_SLASH TE_MOD TE_DIV
33 %right TE_POWER
34 %left TE_FREE
35 %right TE_NOT
36 %nonassoc TE_STRIP
37 %left TE_OLD
38 %left TE_DOT
39 %right TE_LPARAN
40
41 %token <ID_AS> TE_FREE TE_ID TE_TUPLE TE_A_BIT
42 %token TE_INTEGER
43 %token TE_REAL
44 %token <CHAR_AS>TE_CHAR
45
46 %token <SYMBOL_AS> TE_LSQURE TE_RSQURE
47 %token <SYMBOL_AS> TE_ACCEPT TE_ADDRESS TE_ASSIGNMENT
48 %token <SYMBOL_AS> TE_CURLYTILDE
49 %token <SYMBOL_AS> TE_LARRAY TE_RARRAY TE_RPARAN TE_LPARAN
50 %token <SYMBOL_AS> TE_LCURLY TE_RCURLY
51 %token <SYMBOL_AS> TE_BANG TE_SEMICOLON
52 %token <SYMBOL_AS> TE_COLON TE_COMMA
53 %token <SYMBOL_AS> TE_CONSTRAIN TE_QUESTION
54 %token <SYMBOL_AS> TE_DOTDOT TE_TILDE TE_DOT
55 %token <SYMBOL_AS> TE_EQ TE_LT TE_GT TE_LE TE_GE TE_NE
56 %token <SYMBOL_AS> TE_PLUS TE_MINUS TE_STAR TE_SLASH TE_POWER
57 %token <SYMBOL_AS> TE_DIV TE_MOD
58
59 %token <BOOL_AS> TE_FALSE TE_TRUE
60 %token <RESULT_AS> TE_RESULT
61 %token <RETRY_AS> TE_RETRY
62 %token <UNIQUE_AS> TE_UNIQUE
63 %token <CURRENT_AS> TE_CURRENT
64 %token <DEFERRED_AS> TE_DEFERRED
65 %token <VOID_AS> TE_VOID
66
67 %token <KEYWORD_AS> TE_END
68 %token <KEYWORD_AS> TE_FROZEN
69 %token <KEYWORD_AS> TE_PARTIAL_CLASS
70 %token <KEYWORD_AS> TE_INFIX
71 %token <KEYWORD_AS> TE_CREATION
72 %token <KEYWORD_AS> TE_PRECURSOR
73 %token <KEYWORD_AS> TE_PREFIX
74
75 %token <KEYWORD_AS> TE_IS
76 %token <KEYWORD_AS> TE_AGENT TE_ALIAS TE_ALL TE_AND TE_AS
77 %token <KEYWORD_AS> TE_ASSIGN TE_BIT TE_CHECK TE_CLASS TE_CONVERT
78 %token <KEYWORD_AS> TE_CREATE TE_DEBUG TE_DO TE_ELSE TE_ELSEIF
79 %token <KEYWORD_AS> TE_ENSURE TE_EXPANDED TE_EXPORT TE_EXTERNAL TE_FEATURE
80 %token <KEYWORD_AS> TE_FROM TE_IF TE_IMPLIES TE_INDEXING TE_INHERIT
81 %token <KEYWORD_AS> TE_INSPECT TE_INVARIANT TE_LIKE TE_LOCAL
82 %token <KEYWORD_AS> TE_LOOP TE_NOT TE_OBSOLETE TE_OLD TE_ONCE
83 %token <KEYWORD_AS> TE_ONCE_STRING TE_OR TE_REDEFINE TE_REFERENCE TE_RENAME
84 %token <KEYWORD_AS> TE_REQUIRE TE_RESCUE TE_SELECT TE_SEPARATE TE_STRIP
85 %token <KEYWORD_AS> TE_THEN TE_UNDEFINE TE_UNTIL TE_VARIANT TE_WHEN
86 %token <KEYWORD_AS> TE_XOR
87
88 %token TE_STRING TE_EMPTY_STRING TE_VERBATIM_STRING TE_EMPTY_VERBATIM_STRING
89 %token TE_STR_LT TE_STR_LE TE_STR_GT TE_STR_GE TE_STR_MINUS
90 %token TE_STR_PLUS TE_STR_STAR TE_STR_SLASH TE_STR_MOD
91 %token TE_STR_DIV TE_STR_POWER TE_STR_AND TE_STR_AND_THEN
92 %token TE_STR_IMPLIES TE_STR_OR TE_STR_OR_ELSE TE_STR_XOR
93 %token TE_STR_NOT TE_STR_FREE TE_STR_BRACKET
94
95 %type <SYMBOL_AS>ASemi
96 %type <KEYWORD_AS> Alias_mark Is_keyword
97 %type <ALIAS_TRIPLE>Alias
98 %type <PAIR[KEYWORD_AS, EIFFEL_LIST [INSTRUCTION_AS]]> Else_part Rescue
99
100 %type <PAIR[KEYWORD_AS, ID_AS]> Assigner_mark_opt
101 %type <PAIR[KEYWORD_AS, STRING_AS]> External_name Obsolete
102 %type <IDENTIFIER_LIST> Identifier_list Strip_identifier_list
103 %type <PAIR [KEYWORD_AS, EIFFEL_LIST [TAGGED_AS]]> Invariant
104 %type <AGENT_TARGET_TRIPLE> Agent_target
105
106 %type <ACCESS_AS> A_feature Creation_target
107 %type <ACCESS_FEAT_AS> Feature_access
108 %type <ACCESS_INV_AS> Creation_call
109 %type <ARRAY_AS> Manifest_array
110 %type <ASSIGN_AS> Assignment
111 %type <ASSIGNER_CALL_AS> Assigner_call
112 %type <ATOMIC_AS> Index_value Manifest_constant Expression_constant
113 %type <BINARY_AS> Qualified_binary_expression
114 %type <BIT_CONST_AS> Bit_constant
115 %type <BODY_AS> Declaration_body
116 %type <BOOL_AS> Boolean_constant
117 %type <CALL_AS> Call Remote_call Qualified_call
118 %type <CASE_AS> When_part
119 %type <CHAR_AS> Character_constant
120 %type <CHECK_AS> Check
121 %type <KEYWORD_AS> Class_mark
122 %type <CLIENT_AS> Clients Feature_client_clause
123 %type <CONSTANT_AS> Constant_attribute
124 %type <CONVERT_FEAT_AS> Convert_feature
125 %type <CREATE_AS> Creation_clause
126 %type <CREATION_AS> Creation
127 %type <CREATION_EXPR_AS> Creation_expression
128 %type <DEBUG_AS> Debug
129 %type <ELSIF_AS> Elseif_part
130 %type <ENSURE_AS> Postcondition
131 %type <EXPORT_ITEM_AS> New_export_item
132 %type <EXPR_AS> Bracket_target Expression Factor Qualified_expression Qualified_factor Typed_expression
133 %type <EXTERNAL_AS> External
134 %type <EXTERNAL_LANG_AS> External_language
135 %type <FEATURE_AS> Feature_declaration
136 %type <FEATURE_CLAUSE_AS> Feature_clause
137 %type <FEATURE_SET_AS> Feature_set
138 %type <FORMAL_AS> Formal_parameter
139 %type <FORMAL_DEC_AS> Formal_generic
140 %type <ID_AS> Class_or_tuple_identifier Class_identifier Identifier_as_lower Free_operator Feature_name_for_call
141 %type <IF_AS> Conditional
142 %type <INDEX_AS> Index_clause Index_clause_impl
143 %type <INSPECT_AS> Multi_branch
144 %type <INSTRUCTION_AS> Instruction Instruction_impl
145 %type <INTEGER_AS> Integer_constant Signed_integer Nosigned_integer Typed_integer Typed_nosigned_integer Typed_signed_integer
146 %type <INTERNAL_AS> Internal
147 %type <INTERVAL_AS> Choice
148 %type <INVARIANT_AS> Class_invariant
149 %type <LOOP_AS> Loop
150 %type <NESTED_AS> Call_on_feature_access
151 %type <OPERAND_AS> Delayed_actual
152 %type <PARENT_AS> Parent Parent_clause
153 %type <PRECURSOR_AS> A_precursor
154 %type <STATIC_ACCESS_AS> A_static_call Old_a_static_call New_a_static_call
155 %type <REAL_AS> Real_constant Signed_real Nosigned_real Typed_real Typed_nosigned_real Typed_signed_real
156 %type <RENAME_AS> Rename_pair
157 %type <REQUIRE_AS> Precondition
158 %type <REVERSE_AS> Reverse_assignment
159 %type <ROUT_BODY_AS> Routine_body
160 %type <ROUTINE_AS> Routine Optional_attribute_or_routine
161 %type <ROUTINE_CREATION_AS> Agent_call
162 %type <PAIR[ROUTINE_CREATION_AS, LOCATION_AS]> Tilda_agent_call
163 %type <STRING_AS> Manifest_string Non_empty_string Default_manifest_string Typed_manifest_string Infix_operator Prefix_operator Alias_name
164 %type <TAGGED_AS> Assertion_clause
165 %type <TUPLE_AS> Manifest_tuple
166 %type <TYPE_AS> Type Non_class_type Typed Class_or_tuple_type Class_type Tuple_type Type_no_id Constraint_type
167 %type <PAIR [SYMBOL_AS, TYPE_AS]> Type_mark
168 %type <CLASS_TYPE_AS> Parent_class_type
169 %type <TYPE_DEC_AS> Entity_declaration_group
170 %type <VARIANT_AS> Variant
171 %type <FEATURE_NAME> Infix Prefix Feature_name Extended_feature_name New_feature
172
173 %type <EIFFEL_LIST [ATOMIC_AS]> Index_terms
174 %type <EIFFEL_LIST [CASE_AS]> When_part_list_opt When_part_list
175 %type <CONVERT_FEAT_LIST_AS> Convert_list Convert_clause
176 %type <EIFFEL_LIST [CREATE_AS]> Creators Creation_clause_list
177 %type <EIFFEL_LIST [ELSIF_AS]> Elseif_list Elseif_part_list
178 %type <EIFFEL_LIST [EXPORT_ITEM_AS]> New_export_list
179 %type <EXPORT_CLAUSE_AS> New_exports New_exports_opt
180 %type <EIFFEL_LIST [EXPR_AS]> Expression_list
181 %type <PARAMETER_LIST_AS> Parameters
182 %type <EIFFEL_LIST [FEATURE_AS]> Feature_declaration_list
183 %type <EIFFEL_LIST [FEATURE_CLAUSE_AS]> Features Feature_clause_list
184 %type <EIFFEL_LIST [FEATURE_NAME]> Feature_list Feature_list_impl New_feature_list
185 %type <CREATION_CONSTRAIN_TRIPLE> Creation_constraint
186 %type <UNDEFINE_CLAUSE_AS> Undefine Undefine_opt
187 %type <REDEFINE_CLAUSE_AS> Redefine Redefine_opt
188 %type <SELECT_CLAUSE_AS> Select Select_opt
189 %type <FORMAL_GENERIC_LIST_AS> Formal_generics Formal_generic_list
190 %type <CLASS_LIST_AS> Client_list Class_list
191
192 %type <INDEXING_CLAUSE_AS> Indexing Index_list Dotnet_indexing
193 %type <EIFFEL_LIST [INSTRUCTION_AS]> Compound Instruction_list
194 %type <EIFFEL_LIST [INTERVAL_AS]> Choices
195 %type <EIFFEL_LIST [OPERAND_AS]> Delayed_actual_list
196 %type <DELAYED_ACTUAL_LIST_AS> Delayed_actuals
197 %type <PARENT_LIST_AS> Inheritance Parent_list
198 %type <EIFFEL_LIST [RENAME_AS]> Rename_list
199 %type <RENAME_CLAUSE_AS> Rename
200 %type <EIFFEL_LIST [STRING_AS]> String_list
201 %type <DEBUG_KEY_LIST_AS> Debug_keys
202 %type <EIFFEL_LIST [TAGGED_AS]> Assertion Assertion_list
203 %type <TYPE_LIST_AS> Generics Generics_opt Type_list Type_list_impl Actual_parameter_list
204 %type <TYPE_DEC_LIST_AS> Entity_declaration_list Named_parameter_list
205 %type <LOCAL_DEC_LIST_AS> Local_declarations
206 %type <FORMAL_ARGU_DEC_LIST_AS> Formal_arguments Optional_formal_arguments
207 %type <CONSTRAINT_TRIPLE> Constraint
208 %type <CONSTRAINT_LIST_AS> Multiple_constraint_list
209 %type <CONSTRAINING_TYPE_AS> Single_constraint
210
211 %expect 125
212
213 %%
214
215 --###################################################################
216 --# Root rule actually divided in 4 different parsers:
217 --# 1 - parsing Eiffel classes
218 --# 2 - parsing Eiffel types (differentiated by reading first a
219 --# random Identifier
220 --# 3 - parsing Eiffel expression (differentiated by reading first
221 --# the TE_FEATURE token)
222 --# 4 - parsing Eiffel indexing clause (needed for reading
223 --# `indexing.txt' file used to describe a cluster)
224 --# 5 - parsing Eiffel entity declaration list (to get correct type for
225 --# locals or arguments or attributes.
226 --###################################################################
227 Eiffel_parser:
228 Class_declaration
229 {
230 if type_parser or expression_parser or feature_parser or indexing_parser or entity_declaration_parser or invariant_parser then
231 raise_error
232 end
233 }
234 | Identifier_as_lower Type
235 {
236 if not type_parser or expression_parser or feature_parser or indexing_parser or entity_declaration_parser or invariant_parser then
237 raise_error
238 end
239 type_node := $2
240 }
241 | TE_FEATURE Feature_declaration
242 {
243 if not feature_parser or type_parser or expression_parser or indexing_parser or entity_declaration_parser or invariant_parser then
244 raise_error
245 end
246 feature_node := $2
247 }
248 | TE_CHECK Expression
249 {
250 if not expression_parser or type_parser or feature_parser or indexing_parser or entity_declaration_parser or invariant_parser then
251 raise_error
252 end
253 expression_node := $2
254 }
255 | Indexing
256 {
257 if not indexing_parser or type_parser or expression_parser or feature_parser or entity_declaration_parser or invariant_parser then
258 raise_error
259 end
260 indexing_node := $1
261 }
262 | TE_INVARIANT Class_invariant
263 {
264 if not invariant_parser or type_parser or expression_parser or feature_parser or indexing_parser or entity_declaration_parser then
265 raise_error
266 end
267 invariant_node := $2
268 }
269 | TE_LOCAL
270 {
271 if not entity_declaration_parser or type_parser or expression_parser or feature_parser or indexing_parser or invariant_parser then
272 raise_error
273 end
274 entity_declaration_node := Void
275 }
276 | TE_LOCAL Add_counter Entity_declaration_list Remove_counter
277 {
278 if not entity_declaration_parser or type_parser or expression_parser or feature_parser or indexing_parser or invariant_parser then
279 raise_error
280 end
281 entity_declaration_node := $3
282 }
283 ;
284
285 Class_declaration:
286 Indexing -- $1
287 Header_mark -- $2
288 Class_mark -- $3
289 Class_or_tuple_identifier -- $4
290 Formal_generics -- $5
291 External_name -- $6
292 Obsolete -- $7
293 Inheritance End_inheritance_pos -- $8 $9
294 Creators -- $10
295 Convert_clause -- $11
296 Features End_features_pos -- $12 $13
297 Class_invariant -- $14
298 Indexing -- $15
299 TE_END -- $16
300 {
301 if $6 /= Void then
302 temp_string_as1 := $6.second
303 else
304 temp_string_as1 := Void
305 end
306 if $7 /= Void then
307 temp_string_as2 := $7.second
308 else
309 temp_string_as2 := Void
310 end
311
312 root_node := new_class_description ($4, temp_string_as1,
313 is_deferred, is_expanded, is_separate, is_frozen_class, is_external_class, is_partial_class,
314 $1, $15, $5, $8, $10, $11, $12, $14, suppliers, temp_string_as2, $16)
315 if root_node /= Void then
316 root_node.set_text_positions (
317 formal_generics_end_position,
318 inheritance_end_position,
319 features_end_position)
320 if $6 /= Void then
321 root_node.set_alias_keyword ($6.first)
322 end
323 if $7 /= Void then
324 root_node.set_obsolete_keyword ($7.first)
325 end
326 root_node.set_header_mark (frozen_keyword, expanded_keyword, deferred_keyword, separate_keyword, external_keyword)
327 root_node.set_class_keyword ($3)
328 end
329 }
330 ;
331
332 End_inheritance_pos: { inheritance_end_position := position } ;
333 End_features_pos: { features_end_position := position } ;
334 End_feature_clause_pos: { feature_clause_end_position := position };
335 -- Indexing
336
337
338 Indexing: -- Empty
339 -- { $$ := Void }
340 | TE_INDEXING Add_indexing_counter Index_list Remove_counter
341 {
342 $$ := $3
343 if $$ /= Void then
344 $$.set_indexing_keyword ($1)
345 end
346 set_has_old_verbatim_strings_warning (initial_has_old_verbatim_strings_warning)
347 }
348 | TE_INDEXING
349 --- { $$ := Void }
350 {
351 $$ := ast_factory.new_indexing_clause_as (0)
352 if $$ /= Void then
353 $$.set_indexing_keyword ($1)
354 end
355 }
356 ;
357
358 Dotnet_indexing: -- Empty
359 -- { $$ := Void }
360 | TE_INDEXING TE_END
361 --- { $$ := Void }
362 {
363 $$ := ast_factory.new_indexing_clause_as (0)
364 if $$ /= Void then
365 $$.set_indexing_keyword ($1)
366 $$.set_end_keyword ($2)
367 end
368 }
369 | TE_INDEXING Add_indexing_counter Index_list Remove_counter TE_END
370 {
371 $$ := $3
372 if $$ /= Void then
373 if $1 /= Void then
374 $$.set_indexing_keyword ($1)
375 end
376 if $5 /= Void then
377 $$.set_end_keyword ($5)
378 end
379 end
380 set_has_old_verbatim_strings_warning (initial_has_old_verbatim_strings_warning)
381 }
382 ;
383
384 Index_list: Index_clause
385 {
386 $$ := ast_factory.new_indexing_clause_as (counter_value + 1)
387 if $$ /= Void and $1 /= Void then
388 $$.reverse_extend ($1)
389 $$.update_lookup ($1)
390 end
391 }
392 | Index_clause Increment_counter Index_list
393 {
394 $$ := $3
395 if $$ /= Void and $1 /= Void then
396 $$.reverse_extend ($1)
397 $$.update_lookup ($1)
398 end
399 }
400 ;
401
402 Index_clause: Add_counter Index_clause_impl Remove_counter
403 { $$ := $2 }
404 ;
405
406 Index_clause_impl: Identifier_as_lower TE_COLON Index_terms ASemi
407 {
408 $$ := ast_factory.new_index_as ($1, $3, $2)
409 }
410 | Index_terms ASemi
411 {
412 $$ := ast_factory.new_index_as (Void, $1, Void)
413 if has_syntax_warning and $1 /= Void then
414 Error_handler.insert_warning (
415 create {SYNTAX_WARNING}.make ($1.start_location.line,
416 $1.start_location.column, filename,
417 once "Missing `Index' part of `Index_clause'."))
418 end
419 }
420 ;
421
422 Index_terms: Index_value
423 {
424 $$ := ast_factory.new_eiffel_list_atomic_as (counter_value + 1)
425 if $$ /= Void and $1 /= Void then
426 $$.reverse_extend ($1)
427 end
428 }
429 | Index_value TE_COMMA Increment_counter Index_terms
430 {
431 $$ := $4
432 if $$ /= Void and $1 /= Void then
433 $$.reverse_extend ($1)
434 ast_factory.reverse_extend_separator ($$, $2)
435 end
436 }
437 | TE_SEMICOLON
438 {
439 -- TO DO: remove this TE_SEMICOLON (see: INDEX_AS.index_list /= Void)
440 $$ := ast_factory.new_eiffel_list_atomic_as (0)
441 }
442 ;
443
444 Index_value: Identifier_as_lower
445 { $$ := $1 }
446 | Manifest_constant
447 { $$ := $1 }
448 | Disable_supplier_recording_only_for_classic Creation_expression TE_END Enable_supplier_recording_only_for_classic
449 { $$ := ast_factory.new_custom_attribute_as ($2, Void, $3) }
450 | Disable_supplier_recording_only_for_classic Creation_expression Manifest_tuple TE_END Enable_supplier_recording_only_for_classic
451 { $$ := ast_factory.new_custom_attribute_as ($2, $3, $4) }
452 ;
453
454 Disable_supplier_recording:
455 {
456 is_supplier_recorded := False
457 }
458 ;
459
460 Enable_supplier_recording:
461 {
462 is_supplier_recorded := True
463 }
464 ;
465
466 Disable_supplier_recording_only_for_classic:
467 {
468 if not il_parser then
469 is_supplier_recorded := False
470 end
471 }
472 ;
473
474 Enable_supplier_recording_only_for_classic:
475 {
476 if not il_parser then
477 is_supplier_recorded := True
478 end
479 }
480 ;
481
482 Header_mark: Frozen_mark External_mark
483 {
484 is_deferred := False
485 is_expanded := False
486 is_separate := False
487
488 deferred_keyword := Void
489 expanded_keyword := Void
490 separate_keyword := Void
491 }
492 | TE_DEFERRED External_mark
493 {
494 is_frozen_class := False
495 is_deferred := True
496 is_expanded := False
497 is_separate := False
498
499 frozen_keyword := Void
500 deferred_keyword := $1
501 expanded_keyword := Void
502 separate_keyword := Void
503 }
504 | Frozen_mark TE_EXPANDED External_mark
505 {
506 is_deferred := False
507 is_expanded := True
508 is_separate := False
509
510 deferred_keyword := Void
511 expanded_keyword := $2
512 separate_keyword := Void
513 }
514 | Frozen_mark TE_SEPARATE External_mark
515 {
516 is_deferred := False
517 is_expanded := False
518 is_separate := True
519
520 deferred_keyword := Void
521 expanded_keyword := Void
522 separate_keyword := $2
523 }
524 ;
525
526 Frozen_mark: -- Empty
527 {
528 is_frozen_class := False
529 frozen_keyword := Void
530 }
531 | TE_FROZEN
532 {
533 -- I'm adding a few comments line
534 -- here because otherwise the generated
535 -- parser is very different from the
536 -- previous one, since line numbers are
537 -- emitted.
538 is_frozen_class := True
539 frozen_keyword := $1
540 }
541 ;
542
543 External_mark: -- Empty
544 {
545 is_external_class := False
546 external_keyword := Void
547 }
548 | TE_EXTERNAL
549 {
550 if il_parser then
551 is_external_class := True
552 external_keyword := $1
553 else
554 -- Trigger a syntax error.
555 raise_error
556 end
557 }
558 ;
559
560 Class_mark: TE_CLASS
561 {
562 $$ := $1;
563 is_partial_class := false;
564 }
565 | TE_PARTIAL_CLASS
566 {
567 $$ := $1;
568 is_partial_class := true;
569 }
570 ;
571
572 -- Obsolete
573
574
575 Obsolete: -- Empty
576 -- { $$ := Void }
577 | TE_OBSOLETE Manifest_string
578 {
579 $$ := ast_factory.new_keyword_string_pair ($1, $2)
580 }
581 ;
582
583
584 -- Features
585
586 Features: -- Empty
587 -- { $$ := Void }
588 | Add_counter Feature_clause_list Remove_counter
589 {
590 $$ := $2
591 if $$ /= Void and then $$.is_empty then
592 $$ := Void
593 end
594 }
595 ;
596
597 Feature_clause_list: Feature_clause
598 {
599 $$ := ast_factory.new_eiffel_list_feature_clause_as (counter_value + 1)
600 if $$ /= Void and $1 /= Void then
601 $$.reverse_extend ($1)
602 end
603 }
604 | Feature_clause Increment_counter Feature_clause_list
605 {
606 $$ := $3
607 if $$ /= Void and $1 /= Void then
608 $$.reverse_extend ($1)
609 end
610 }
611 ;
612
613 Feature_clause: Feature_client_clause End_feature_clause_pos
614 { $$ := ast_factory.new_feature_clause_as ($1,
615 ast_factory.new_eiffel_list_feature_as (0), fclause_pos, feature_clause_end_position) }
616 | Feature_client_clause Add_counter Feature_declaration_list Remove_counter End_feature_clause_pos
617 { $$ := ast_factory.new_feature_clause_as ($1, $3, fclause_pos, feature_clause_end_position) }
618 ;
619
620 Feature_client_clause: TE_FEATURE
621 {
622 fclause_pos := $1
623 if $1 /= Void then
624 -- Originally, it was 8, I changed it to 7, delete the following line when fully tested. (Jason)
625 fclause_pos.set_position (line, column, position, 7)
626 else
627 -- Originally, it was 8, I changed it to 7 (Jason)
628 fclause_pos := ast_factory.new_feature_keyword_as (line, column, position, 7, Current)
629 end
630
631 }
632 Clients
633 { $$ := $3 }
634 ;
635
636 Clients: -- Empty
637 -- { $$ := Void }
638 | Client_list
639 { $$ := ast_factory.new_client_as ($1) }
640 ;
641
642 Client_list: TE_LCURLY TE_RCURLY
643 {
644 $$ := ast_factory.new_class_list_as (1)
645 if $$ /= Void then
646 $$.reverse_extend (new_none_id)
647 $$.set_lcurly_symbol ($1)
648 $$.set_rcurly_symbol ($2)
649 end
650 }
651 | TE_LCURLY Add_counter Class_list Remove_counter TE_RCURLY
652 {
653 $$ := $3
654 if $$ /= Void then
655 $$.set_lcurly_symbol ($1)
656 $$.set_rcurly_symbol ($5)
657 end
658 }
659 ;
660
661 Class_list: Class_or_tuple_identifier
662 {
663 $$ := ast_factory.new_class_list_as (counter_value + 1)
664 if $$ /= Void and $1 /= Void then
665 $$.reverse_extend ($1)
666 suppliers.insert_light_supplier_id ($1)
667 end
668 }
669 | Class_or_tuple_identifier TE_COMMA Increment_counter Class_list
670 {
671 $$ := $4
672 if $$ /= Void and $1 /= Void then
673 $$.reverse_extend ($1)
674 suppliers.insert_light_supplier_id ($1)
675 ast_factory.reverse_extend_separator ($$, $2)
676 end
677 }
678 ;
679
680 Feature_declaration_list: Feature_declaration
681 {
682 $$ := ast_factory.new_eiffel_list_feature_as (counter_value + 1)
683 if $$ /= Void and $1 /= Void then
684 $$.reverse_extend ($1)
685 end
686 }
687 | Feature_declaration Increment_counter Feature_declaration_list
688 {
689 $$ := $3
690 if $$ /= Void and $1 /= Void then
691 $$.reverse_extend ($1)
692 end
693 }
694 ;
695
696 ASemi: -- Empty
697 | TE_SEMICOLON { $$ := $1 }
698 ;
699
700 Feature_declaration: Add_counter New_feature_list Remove_counter Declaration_body Optional_semicolons
701 {
702 $$ := ast_factory.new_feature_as ($2, $4, feature_indexes, position)
703 feature_indexes := Void
704 }
705 ;
706
707 New_feature_list: New_feature
708 {
709 $$ := ast_factory.new_eiffel_list_feature_name (counter_value + 1)
710 if $$ /= Void and $1 /= Void then
711 $$.reverse_extend ($1)
712 end
713 }
714 | New_feature TE_COMMA Increment_counter New_feature_list
715 {
716 $$ := $4
717 if $$ /= Void and $1 /= Void then
718 $$.reverse_extend ($1)
719 ast_factory.reverse_extend_separator ($$, $2)
720 end
721 }
722 ;
723
724 New_feature: Extended_feature_name
725 { $$ := $1 }
726 | TE_FROZEN Extended_feature_name
727 {
728 $$ := $2
729 if $$ /= Void then
730 $$.set_frozen_keyword ($1)
731 end
732 }
733 ;
734
735 Extended_feature_name: Feature_name
736 { $$ := $1 }
737 | Identifier_as_lower Alias
738 {
739 if $2 /= Void then
740 $$ := ast_factory.new_feature_name_alias_as ($1, $2.alias_name, has_convert_mark, $2.alias_keyword, $2.convert_keyword)
741 else
742 $$ := ast_factory.new_feature_name_alias_as ($1, Void, has_convert_mark, Void, Void)
743 end
744
745 }
746 ;
747
748 Feature_name: Identifier_as_lower
749 { $$ := ast_factory.new_feature_name_id_as ($1) }
750 | Infix
751 { $$ := $1 }
752 | Prefix
753 { $$ := $1 }
754 ;
755
756 Infix: TE_INFIX Infix_operator
757 { $$ := ast_factory.new_infix_as ($2, $1) }
758 ;
759
760
761 Prefix: TE_PREFIX Prefix_operator
762 { $$ := ast_factory.new_prefix_as ($2, $1) }
763 ;
764
765 Alias: TE_ALIAS Alias_name Alias_mark
766 {
767 $$ := ast_factory.new_alias_triple ($1, $2, $3)
768 }
769 ;
770
771 Alias_name: Infix_operator
772 { $$ := $1 }
773 | TE_STR_NOT
774 {
775 $$ := ast_factory.new_string_as ("not", line, column, position, 5, token_buffer2)
776 }
777 | TE_STR_BRACKET
778 {
779 $$ := ast_factory.new_string_as ("[]", line, column, position, 4, token_buffer2)
780 }
781 ;
782
783 Alias_mark: -- Empty
784 { has_convert_mark := False }
785 | TE_CONVERT
786 { has_convert_mark := True
787 $$ := $1
788 }
789 ;
790
791 Is_keyword: -- Empty
792 { $$ := Void }
793 | TE_IS
794 { $$ := $1 }
795 ;
796
797 Declaration_body: TE_COLON Type Assigner_mark_opt Dotnet_indexing
798 {
799 -- Attribute case
800 if $3 = Void then
801 $$ := ast_factory.new_body_as (Void, $2, Void, Void, $1, Void, Void, $4)
802 else
803 $$ := ast_factory.new_body_as (Void, $2, $3.second, Void, $1, Void, $3.first, $4)
804 end
805 feature_indexes := $4
806 }
807 | TE_COLON Type Assigner_mark_opt TE_EQ Constant_attribute Dotnet_indexing
808 {
809 -- Constant case
810 if $3 = Void then
811 $$ := ast_factory.new_body_as (Void, $2, Void, $5, $1, $4, Void, $6)
812 else
813 $$ := ast_factory.new_body_as (Void, $2, $3.second, $5, $1, $4, $3.first, $6)
814 end
815
816 feature_indexes := $6
817 }
818 | TE_COLON Type Assigner_mark_opt TE_IS Constant_attribute Dotnet_indexing
819 {
820 -- Constant case
821 if $3 = Void then
822 $$ := ast_factory.new_body_as (Void, $2, Void, $5, $1, $4, Void, $6)
823 else
824 $$ := ast_factory.new_body_as (Void, $2, $3.second, $5, $1, $4, $3.first, $6)
825 end
826
827 feature_indexes := $6
828 }
829 | Is_keyword Indexing Routine
830 {
831 -- procedure without arguments
832 $$ := ast_factory.new_body_as (Void, Void, Void, $3, Void, $1, Void, $2)
833 feature_indexes := $2
834 }
835 | TE_COLON Type Assigner_mark_opt TE_IS Indexing Routine
836 {
837 -- Function without arguments
838 if $3 = Void then
839 $$ := ast_factory.new_body_as (Void, $2, Void, $6, $1, $4, Void, $5)
840 else
841 $$ := ast_factory.new_body_as (Void, $2, $3.second, $6, $1, $4, $3.first, $5)
842 end
843
844 feature_indexes := $5
845 }
846 | TE_COLON Type Assigner_mark_opt Indexing Routine
847 {
848 -- Function without arguments
849 if $3 = Void then
850 $$ := ast_factory.new_body_as (Void, $2, Void, $5, $1, Void, Void, $4)
851 else
852 $$ := ast_factory.new_body_as (Void, $2, $3.second, $5, $1, Void, $3.first, $4)
853 end
854
855 feature_indexes := $4
856 }
857 | Formal_arguments Is_keyword Indexing Routine
858 {
859 -- procedure with arguments
860 $$ := ast_factory.new_body_as ($1, Void, Void, $4, Void, $2, Void, $3)
861 feature_indexes := $3
862 }
863 | Formal_arguments TE_COLON Type Assigner_mark_opt Is_keyword Indexing Routine
864 {
865 -- Function with arguments
866 if $4 = Void then
867 $$ := ast_factory.new_body_as ($1, $3, Void, $7, $2, $5, Void, $6)
868 else
869 $$ := ast_factory.new_body_as ($1, $3, $4.second, $7, $2, $5, $4.first, $6)
870 end
871 feature_indexes := $6
872 }
873 ;
874
875 Assigner_mark_opt: -- Empty
876 {
877 $$ := ast_factory.new_assigner_mark_as (Void, Void)
878 }
879 | TE_ASSIGN Identifier_as_lower
880 {
881 $$ := ast_factory.new_assigner_mark_as ($1, $2)
882 }
883 ;
884
885 Constant_attribute: Manifest_constant
886 { $$ := ast_factory.new_constant_as ($1) }
887 | TE_UNIQUE
888 { $$ := ast_factory.new_constant_as ($1) }
889 ;
890
891 -- Inheritance
892
893
894 Inheritance: -- Empty
895 -- { $$ := Void }
896 | TE_INHERIT ASemi
897 {
898 if has_syntax_warning then
899 Error_handler.insert_warning (
900 create {SYNTAX_WARNING}.make (line, column, filename,
901 once "Use `inherit ANY' or do not specify an empty inherit clause"))
902 end
903 --- $$ := Void
904 $$ := ast_factory.new_eiffel_list_parent_as (0)
905 if $$ /= Void then
906 $$.set_inherit_keyword ($1)
907 end
908 }
909 | TE_INHERIT Add_counter Parent_list Remove_counter
910 {
911 $$ := $3
912 if $$ /= Void then
913 $$.set_inherit_keyword ($1)
914 end
915 }
916 ;
917
918 Parent_list: Parent
919 {
920 $$ := ast_factory.new_eiffel_list_parent_as (counter_value + 1)
921 if $$ /= Void and $1 /= Void then
922 $$.reverse_extend ($1)
923 end
924 }
925 | Parent Increment_counter Parent_list
926 {
927 $$ := $3
928 if $$ /= Void and $1 /= Void then
929 $$.reverse_extend ($1)
930 end
931 }
932 ;
933
934 Parent: Parent_clause ASemi
935 { $$ := $1 }
936 ;
937
938 Parent_class_type: Class_identifier Generics_opt
939 { $$ := ast_factory.new_class_type_as ($1, $2) }
940 ;
941
942 Parent_clause: Parent_class_type
943 {
944 $$ := ast_factory.new_parent_as ($1, Void, Void, Void, Void, Void, Void)
945 }
946 | Parent_class_type Select TE_END
947 {
948 $$ := ast_factory.new_parent_as ($1, Void, Void, Void, Void, $2, $3)
949 }
950 | Parent_class_type Redefine Select_opt TE_END
951 {
952 $$ := ast_factory.new_parent_as ($1, Void, Void, Void, $2, $3, $4)
953 }
954 | Parent_class_type Undefine Redefine_opt Select_opt TE_END
955 {
956 $$ := ast_factory.new_parent_as ($1, Void, Void, $2, $3, $4, $5)
957 }
958 | Parent_class_type New_exports Undefine_opt Redefine_opt Select_opt TE_END
959 {
960 $$ := ast_factory.new_parent_as ($1, Void, $2, $3, $4, $5, $6)
961 }
962 | Parent_class_type Rename New_exports_opt Undefine_opt Redefine_opt Select_opt TE_END
963 {
964 $$ := ast_factory.new_parent_as ($1, $2, $3, $4, $5, $6, $7)
965 }
966 ;
967
968 Rename: TE_RENAME
969 {
970 $$ := ast_factory.new_rename_clause_as (Void, $1)
971 if is_constraint_renaming then
972 error_handler.insert_error (
973 create {SYNTAX_ERROR}.make ($1.line, $1.column, filename, "Empty rename clause.", False))
974 error_handler.raise_error
975 else
976 error_handler.insert_warning (
977 create {SYNTAX_WARNING}.make ($1.line, $1.column, filename,
978 "Remove empty rename clauses."))
979 end
980 }
981 | TE_RENAME Add_counter Rename_list Remove_counter
982 { $$ := ast_factory.new_rename_clause_as ($3, $1) }
983 ;
984
985 Rename_list: Rename_pair
986 {
987 $$ := ast_factory.new_eiffel_list_rename_as (counter_value + 1)
988 if $$ /= Void and $1 /= Void then
989 $$.reverse_extend ($1)
990 end
991 }
992 | Rename_pair TE_COMMA Increment_counter Rename_list
993 {
994 $$ := $4
995 if $$ /= Void and $1 /= Void then
996 $$.reverse_extend ($1)
997 ast_factory.reverse_extend_separator ($$, $2)
998 end
999 }
1000 ;
1001
1002 Rename_pair: Feature_name TE_AS Extended_feature_name
1003 { $$ := ast_factory.new_rename_as ($1, $3, $2) }
1004 ;
1005
1006 New_exports_opt: -- Empty
1007 -- { $$ := Void }
1008 | New_exports
1009 { $$ := $1 }
1010 ;
1011
1012 New_exports: TE_EXPORT Add_counter New_export_list Remove_counter
1013 { $$ := ast_factory.new_export_clause_as ($3, $1) }
1014 | TE_EXPORT ASemi
1015 { $$ := ast_factory.new_export_clause_as (Void, $1) }
1016 ;
1017
1018 New_export_list: New_export_item
1019 {
1020 $$ := ast_factory.new_eiffel_list_export_item_as (counter_value + 1)
1021 if $$ /= Void and $1 /= Void then
1022 $$.reverse_extend ($1)
1023 end
1024 }
1025 | New_export_item Increment_counter New_export_list
1026 {
1027 $$ := $3
1028 if $$ /= Void and $1 /= Void then
1029 $$.reverse_extend ($1)
1030 end
1031 }
1032 ;
1033
1034 New_export_item: Client_list Feature_set ASemi
1035 {
1036 $$ := ast_factory.new_export_item_as (ast_factory.new_client_as ($1), $2)
1037 }
1038 ;
1039
1040 Feature_set: -- Empty
1041 -- { $$ := Void }
1042 | TE_ALL
1043 { $$ := ast_factory.new_all_as ($1) }
1044 | Feature_list
1045 { $$ := ast_factory.new_feature_list_as ($1) }
1046 ;
1047
1048 Convert_clause: -- Empty
1049 -- { $$ := Void }
1050 | TE_CONVERT Add_counter Convert_list Remove_counter
1051 {
1052 $$ := $3
1053 if $$ /= Void then
1054 $$.set_convert_keyword ($1)
1055 end
1056 }
1057 ;
1058
1059 Convert_list: Convert_feature
1060 {
1061 $$ := ast_factory.new_eiffel_list_convert (counter_value + 1)
1062 if $$ /= Void and $1 /= Void then
1063 $$.reverse_extend ($1)
1064 end
1065 }
1066 | Convert_feature TE_COMMA Increment_counter Convert_list
1067 {
1068 $$ := $4
1069 if $$ /= Void and $1 /= Void then
1070 $$.reverse_extend ($1)
1071 ast_factory.reverse_extend_separator ($$, $2)
1072 end
1073 }
1074 ;
1075
1076
1077 Convert_feature: Feature_name TE_LPARAN TE_LCURLY Type_list TE_RCURLY TE_RPARAN
1078 {
1079 -- True because this is a conversion feature used as a creation
1080 -- procedure in current class.
1081 $$ := ast_factory.new_convert_feat_as (True, $1, $4, $2, $6, Void, $3, $5)
1082 }
1083 | Feature_name TE_COLON TE_LCURLY Type_list TE_RCURLY
1084 {
1085 -- False because this is not a conversion feature used as a creation
1086 -- procedure.
1087 $$ := ast_factory.new_convert_feat_as (False, $1, $4, Void, Void, $2, $3, $5)
1088 }
1089 ;
1090
1091 Feature_list: Add_counter Feature_list_impl Remove_counter
1092 { $$ := $2 }
1093 ;
1094
1095 Feature_list_impl: Feature_name
1096 {
1097 $$ := ast_factory.new_eiffel_list_feature_name (counter_value + 1)
1098 if $$ /= Void and $1 /= Void then
1099 $$.reverse_extend ($1)
1100 end
1101 }
1102 | Feature_name TE_COMMA Increment_counter Feature_list_impl
1103 {
1104 $$ := $4
1105 if $$ /= Void and $1 /= Void then
1106 $$.reverse_extend ($1)
1107 ast_factory.reverse_extend_separator ($$, $2)
1108 end
1109 }
1110 ;
1111
1112 Undefine_opt: -- Empty
1113 -- { $$ := Void }
1114 | Undefine
1115 { $$ := $1 }
1116 ;
1117
1118 Undefine: TE_UNDEFINE
1119 --- { $$ := Void }
1120 {
1121 $$ := ast_factory.new_undefine_clause_as (Void, $1)
1122 }
1123 | TE_UNDEFINE Feature_list
1124 {
1125 $$ := ast_factory.new_undefine_clause_as ($2, $1)
1126 }
1127 ;
1128
1129 Redefine_opt: -- Empty
1130 -- { $$ := Void }
1131 | Redefine
1132 { $$ := $1 }
1133 ;
1134
1135 Redefine: TE_REDEFINE
1136 --- { $$ := Void }
1137 {
1138 $$ := ast_factory.new_redefine_clause_as (Void, $1)
1139 }
1140 | TE_REDEFINE Feature_list
1141 {
1142 $$ := ast_factory.new_redefine_clause_as ($2, $1)
1143 }
1144 ;
1145
1146 Select_opt: -- Empty
1147 -- { $$ := Void }
1148 | Select
1149 { $$ := $1 }
1150 ;
1151
1152 Select: TE_SELECT
1153 --- { $$ := Void }
1154 {
1155 $$ := ast_factory.new_select_clause_as (Void, $1)
1156 }
1157 | TE_SELECT Feature_list
1158 {
1159 $$ := ast_factory.new_select_clause_as ($2, $1)
1160 }
1161 ;
1162
1163
1164 -- Feature declaration
1165
1166
1167 Formal_arguments: TE_LPARAN TE_RPARAN
1168 { $$ := ast_factory.new_formal_argu_dec_list_as (Void, $1, $2) }
1169 | TE_LPARAN Add_counter Entity_declaration_list Remove_counter TE_RPARAN
1170 { $$ := ast_factory.new_formal_argu_dec_list_as ($3, $1, $5) }
1171 ;
1172
1173 Entity_declaration_list: Entity_declaration_group
1174 {
1175 $$ := ast_factory.new_eiffel_list_type_dec_as (counter_value + 1)
1176 if $$ /= Void and $1 /= Void then
1177 $$.reverse_extend ($1)
1178 end
1179 }
1180 | Entity_declaration_group Increment_counter Entity_declaration_list
1181 {
1182 $$ := $3
1183 if $$ /= Void and $1 /= Void then
1184 $$.reverse_extend ($1)
1185 end
1186 }
1187 ;
1188
1189 Entity_declaration_group: Add_counter Identifier_list Remove_counter TE_COLON Type ASemi
1190 { $$ := ast_factory.new_type_dec_as ($2, $5, $4) }
1191 ;
1192
1193 Identifier_list: Identifier_as_lower
1194 {
1195 $$ := ast_factory.new_identifier_list (counter_value + 1)
1196 if $$ /= Void and $1 /= Void then
1197 $$.reverse_extend ($1.name_id)
1198 ast_factory.reverse_extend_identifier ($$.id_list, $1)
1199 end
1200 }
1201 | Identifier_as_lower TE_COMMA Increment_counter Identifier_list
1202 {
1203 $$ := $4
1204 if $$ /= Void and $1 /= Void then
1205 $$.reverse_extend ($1.name_id)
1206 ast_factory.reverse_extend_identifier ($$.id_list, $1)
1207 ast_factory.reverse_extend_separator ($$.id_list, $2)
1208 end
1209 }
1210 ;
1211
1212 Strip_identifier_list: -- Empty
1213 { $$ := ast_factory.new_identifier_list (0) }
1214 | Add_counter Identifier_list Remove_counter
1215 { $$ := $2 }
1216 ;
1217
1218 Routine:
1219 Obsolete
1220 { set_fbody_pos (position) }
1221 Precondition
1222 Local_declarations
1223 Routine_body
1224 Postcondition
1225 Rescue
1226 TE_END
1227 {
1228 if $1 /= Void then
1229 temp_string_as1 := $1.second
1230 temp_keyword_as := $1.first
1231 else
1232 temp_string_as1 := Void
1233 temp_keyword_as := Void
1234 end
1235 if $7 /= Void then
1236 $$ := ast_factory.new_routine_as (temp_string_as1, $3, $4, $5, $6, $7.second, $8, once_manifest_string_count, fbody_pos, temp_keyword_as, $7.first)
1237 else
1238 $$ := ast_factory.new_routine_as (temp_string_as1, $3, $4, $5, $6, Void, $8, once_manifest_string_count, fbody_pos, temp_keyword_as, Void)
1239 end
1240 once_manifest_string_count := 0
1241 }
1242 ;
1243
1244 Routine_body: Internal
1245 { $$ := $1 }
1246 | External
1247 { $$ := $1 }
1248 | TE_DEFERRED
1249 { $$ := $1 }
1250 ;
1251
1252 External: TE_EXTERNAL
1253 {
1254 -- To avoid warnings for manifest string used to represent external data.
1255 initial_has_old_verbatim_strings_warning := has_old_verbatim_strings_warning
1256 set_has_old_verbatim_strings_warning (false)
1257 }
1258 External_language External_name
1259 {
1260 if $3 /= Void and then $3.is_built_in then
1261 if $4 /= Void then
1262 $$ := ast_factory.new_built_in_as ($3, $4.second, $1, $4.first)
1263 else
1264 $$ := ast_factory.new_built_in_as ($3, Void, $1, Void)
1265 end
1266 elseif $4 /= Void then
1267 $$ := ast_factory.new_external_as ($3, $4.second, $1, $4.first)
1268 else
1269 $$ := ast_factory.new_external_as ($3, Void, $1, Void)
1270 end
1271 set_has_old_verbatim_strings_warning (initial_has_old_verbatim_strings_warning)
1272 }
1273 ;
1274
1275 External_language:
1276 Non_empty_string
1277 { $$ := ast_factory.new_external_lang_as ($1) }
1278 ;
1279
1280 External_name: -- Empty
1281 -- { $$ := Void }
1282 | TE_ALIAS Default_manifest_string
1283 {
1284 $$ := ast_factory.new_keyword_string_pair ($1, $2)
1285 }
1286 ;
1287
1288 Internal: TE_DO Compound
1289 { $$ := ast_factory.new_do_as ($2, $1) }
1290 | TE_ONCE Compound
1291 { $$ := ast_factory.new_once_as ($2, $1) }
1292 ;
1293
1294 Local_declarations: -- Empty
1295 -- { $$ := Void }
1296 | TE_LOCAL
1297 { $$ := ast_factory.new_local_dec_list_as (ast_factory.new_eiffel_list_type_dec_as (0), $1) }
1298 | TE_LOCAL Add_counter Entity_declaration_list Remove_counter
1299 { $$ := ast_factory.new_local_dec_list_as ($3, $1) }
1300 ;
1301
1302 Compound: Optional_semicolons
1303 -- { $$ := Void }
1304 | Optional_semicolons Add_counter Instruction_list Remove_counter
1305 { $$ := $3 }
1306 ;
1307
1308 Instruction_list: Instruction
1309 {
1310 $$ := ast_factory.new_eiffel_list_instruction_as (counter_value + 1)
1311 if $$ /= Void and $1 /= Void then
1312 $$.reverse_extend ($1)
1313 end
1314 }
1315 | Instruction Increment_counter Instruction_list
1316 {
1317 $$ := $3
1318 if $$ /= Void and $1 /= Void then
1319 $$.reverse_extend ($1)
1320 end
1321 }
1322 ;
1323
1324 Instruction: Instruction_impl Optional_semicolons
1325 {
1326 $$ := $1
1327 if $$ /= Void then
1328 $$.set_line_pragma (last_line_pragma)
1329 end
1330 }
1331 ;
1332
1333 Optional_semicolons: -- Empty
1334 | Optional_semicolons TE_SEMICOLON
1335 ;
1336
1337 Instruction_impl: Creation
1338 { $$ := $1 }
1339 | Expression
1340 {
1341 -- Call production should be used instead,
1342 -- but this complicates the grammar.
1343 if has_type then
1344 error_handler.insert_error (create {SYNTAX_ERROR}.make (line, column, filename, "Expression cannot be used as an instruction", False))
1345 error_handler.raise_error
1346 else
1347 $$ := new_call_instruction_from_expression ($1)
1348 end
1349 }
1350 | Assigner_call
1351 { $$ := $1 }
1352 | Assignment
1353 { $$ := $1 }
1354 | Reverse_assignment
1355 { $$ := $1 }
1356 | Conditional
1357 { $$ := $1 }
1358 | Multi_branch
1359 { $$ := $1 }
1360 | Loop
1361 { $$ := $1 }
1362 | Debug
1363 { $$ := $1 }
1364 | Check
1365 { $$ := $1 }
1366 | TE_RETRY
1367 { $$ := $1 }
1368 ;
1369
1370 Precondition: -- Empty
1371 -- { $$ := Void }
1372 | TE_REQUIRE
1373 { set_id_level (Assert_level) }
1374 Assertion
1375 {
1376 set_id_level (Normal_level)
1377 $$ := ast_factory.new_require_as ($3, $1)
1378 }
1379 | TE_REQUIRE TE_ELSE
1380 { set_id_level (Assert_level) }
1381 Assertion
1382 {
1383 set_id_level (Normal_level)
1384 $$ := ast_factory.new_require_else_as ($4, $1, $2)
1385 }
1386 ;
1387
1388 Postcondition: -- Empty
1389 -- { $$ := Void }
1390 | TE_ENSURE
1391 { set_id_level (Assert_level) }
1392 Assertion
1393 {
1394 set_id_level (Normal_level)
1395 $$ := ast_factory.new_ensure_as ($3, $1)
1396 }
1397 | TE_ENSURE TE_THEN
1398 { set_id_level (Assert_level) }
1399 Assertion
1400 {
1401 set_id_level (Normal_level)
1402 $$ := ast_factory.new_ensure_then_as ($4, $1, $2)
1403 }
1404 ;
1405
1406 Assertion: -- Empty
1407 -- { $$ := Void }
1408 | Add_counter Assertion_list Remove_counter
1409 {
1410 $$ := $2
1411 if $$ /= Void and then $$.is_empty then
1412 $$ := Void
1413 end
1414 }
1415 ;
1416
1417 Assertion_list: Assertion_clause
1418 {
1419 -- Special list treatment here as we do not want Void
1420 -- element in `Assertion_list'.
1421 if $1 /= Void then
1422 $$ := ast_factory.new_eiffel_list_tagged_as (counter_value + 1)
1423 if $$ /= Void then
1424 $$.reverse_extend ($1)
1425 end
1426 else
1427 $$ := ast_factory.new_eiffel_list_tagged_as (counter_value)
1428 end
1429 }
1430 | Assertion_clause
1431 {
1432 -- Only increment counter when clause is not Void.
1433 if $1 /= Void then
1434 increment_counter
1435 end
1436 }
1437 Assertion_list
1438 {
1439 $$ := $3
1440 if $$ /= Void and $1 /= Void then
1441 $$.reverse_extend ($1)
1442 end
1443 }
1444 ;
1445
1446 Assertion_clause: Expression ASemi
1447 { $$ := ast_factory.new_tagged_as (Void, $1, Void) }
1448 | Identifier_as_lower TE_COLON Expression ASemi
1449 { $$ := ast_factory.new_tagged_as ($1, $3, $2) }
1450 | Identifier_as_lower TE_COLON ASemi
1451 --- { $$ := Void }
1452 {
1453 -- Always create an object here for roundtrip parser.
1454 -- This "fake" assertion will be filtered out later.
1455 $$ := ast_factory.new_tagged_as ($1, Void, $2)
1456 }
1457 ;
1458
1459
1460 -- Type
1461
1462
1463 Type: Class_or_tuple_type
1464 { $$ := $1 }
1465 | TE_INVARIANT Class_or_tuple_type
1466 {
1467 $$ := $2
1468 ast_factory.set_monomorph_type ($$, True, $1)
1469 }
1470 | TE_FROZEN Class_or_tuple_type
1471 {
1472 $$ := $2
1473 ast_factory.set_monomorph_type ($$, True, $1)
1474 }
1475 | Non_class_type
1476 { $$ := $1 }
1477 ;
1478
1479 Type_no_id:
1480 Class_identifier Generics
1481 { $$ := new_class_type ($1, $2) }
1482 | Tuple_type
1483 { $$ := $1 }
1484 | Non_class_type
1485 { $$ := $1 }
1486 ;
1487
1488 Non_class_type: TE_EXPANDED Class_type
1489 {
1490 $$ := $2
1491 ast_factory.set_expanded_class_type ($$, True, $1)
1492 if has_syntax_warning and $2 /= Void then
1493 Error_handler.insert_warning (
1494 create {SYNTAX_WARNING}.make ($1.line, $1.column, filename,
1495 once "Make an expanded version of the base class associated with this type."))
1496 end
1497 }
1498 | TE_SEPARATE Class_or_tuple_type
1499 {
1500 last_class_type ?= $2
1501 if last_class_type /= Void then
1502 last_class_type.set_is_separate (True, $1)
1503 last_class_type := Void
1504 end
1505 $$ := $2
1506 }
1507 | TE_BIT Integer_constant
1508 { $$ := ast_factory.new_bits_as ($2, $1) }
1509 | TE_BIT Identifier_as_lower
1510 { $$ := ast_factory.new_bits_symbol_as ($2, $1) }
1511 | TE_LIKE Identifier_as_lower
1512 { $$ := ast_factory.new_like_id_as ($2, $1) }
1513 | TE_LIKE TE_CURRENT
1514 { $$ := ast_factory.new_like_current_as ($2, $1) }
1515 ;
1516
1517 Class_or_tuple_type: Class_type
1518 { $$ := $1 }
1519 | Tuple_type
1520 { $$ := $1 }
1521 ;
1522
1523 Class_type: Class_identifier Generics_opt
1524 { $$ := new_class_type ($1, $2) }
1525 ;
1526
1527 Generics_opt: -- Empty
1528 -- { $$ := Void }
1529 | Generics
1530 {
1531 $$ := $1
1532 }
1533 ;
1534
1535 Generics: TE_LSQURE Type_list TE_RSQURE
1536 {
1537 $$ := $2
1538 if $$ /= Void then
1539 $$.set_positions ($1, $3)
1540 end
1541 }
1542 | TE_LSQURE TE_RSQURE
1543 {
1544 $$ := ast_factory.new_eiffel_list_type (0)
1545 if $$ /= Void then
1546 $$.set_positions ($1, $2)
1547 end
1548 }
1549 ;
1550
1551 Type_list: Add_counter Type_list_impl Remove_counter
1552 { $$ := $2 }
1553 ;
1554
1555 Type_list_impl: Type
1556 {
1557 $$ := ast_factory.new_eiffel_list_type (counter_value + 1)
1558 if $$ /= Void and $1 /= Void then
1559 $$.reverse_extend ($1)
1560 end
1561 }
1562 | Type TE_COMMA Increment_counter Type_list_impl
1563 {
1564 $$ := $4
1565 if $$ /= Void and $1 /= Void then
1566 $$.reverse_extend ($1)
1567 ast_factory.reverse_extend_separator ($$, $2)
1568 end
1569 }
1570 ;
1571
1572 Tuple_type: TE_TUPLE
1573 { $$ := ast_factory.new_class_type_as ($1, Void) }
1574 | TE_TUPLE Add_counter Add_counter2 TE_LSQURE TE_RSQURE
1575 {
1576 last_type_list := ast_factory.new_eiffel_list_type (0)
1577 if last_type_list /= Void then
1578 last_type_list.set_positions ($4, $5)
1579 end
1580 $$ := ast_factory.new_class_type_as ($1, last_type_list)
1581 last_type_list := Void
1582 remove_counter
1583 remove_counter2
1584 }
1585 | TE_TUPLE Add_counter Add_counter2 TE_LSQURE Actual_parameter_list
1586 {
1587 if $5 /= Void then
1588 $5.set_positions ($4, last_rsqure.item)
1589 end
1590 $$ := ast_factory.new_class_type_as ($1, $5)
1591 last_rsqure.remove
1592 remove_counter
1593 remove_counter2
1594 }
1595 | TE_TUPLE Add_counter Add_counter2 TE_LSQURE Named_parameter_list
1596 {
1597 $$ := ast_factory.new_named_tuple_type_as (
1598 $1, ast_factory.new_formal_argu_dec_list_as ($5, $4, last_rsqure.item))
1599 last_rsqure.remove
1600 remove_counter
1601 remove_counter2
1602 }
1603 ;
1604
1605 Actual_parameter_list: Type TE_RSQURE
1606 {
1607 $$ := ast_factory.new_eiffel_list_type (counter_value + 1)
1608 if $$ /= Void and $1 /= Void then
1609 $$.reverse_extend ($1)
1610 end
1611 last_rsqure.force ($2)
1612 }
1613 | TE_ID TE_COMMA Increment_counter Actual_parameter_list
1614 {
1615 $$ := $4
1616 if $$ /= Void and $1 /= Void then
1617 $1.to_upper
1618 $$.reverse_extend (new_class_type ($1, Void))
1619 ast_factory.reverse_extend_separator ($$, $2)
1620 end
1621 }
1622 | Type_no_id TE_COMMA Increment_counter Actual_Parameter_List
1623 {
1624 $$ := $4
1625 if $$ /= Void and $1 /= Void then
1626 $$.reverse_extend ($1)
1627 ast_factory.reverse_extend_separator ($$, $2)
1628 end
1629 }
1630 ;
1631
1632 Named_parameter_list: TE_ID TE_COLON Type TE_RSQURE
1633 {
1634 $$ := ast_factory.new_eiffel_list_type_dec_as (counter2_value + 1)
1635 last_identifier_list := ast_factory.new_identifier_list (counter_value + 1)
1636
1637 if $$ /= Void and last_identifier_list /= Void and $1 /= Void then
1638 $1.to_lower
1639 last_identifier_list.reverse_extend ($1.name_id)
1640 ast_factory.reverse_extend_identifier (last_identifier_list.id_list, $1)
1641 end
1642 $$.reverse_extend (ast_factory.new_type_dec_as (last_identifier_list, $3, $2))
1643 last_identifier_list := Void
1644 last_rsqure.force ($4)
1645 }
1646 | TE_ID TE_COMMA Increment_counter Named_parameter_list
1647
1648 {
1649 $$ := $4
1650 if $$ /= Void then
1651 last_identifier_list := $$.reversed_first.id_list
1652 if last_identifier_list /= Void then
1653 $1.to_lower
1654 last_identifier_list.reverse_extend ($1.name_id)
1655 ast_factory.reverse_extend_identifier (last_identifier_list.id_list, $1)
1656 ast_factory.reverse_extend_separator (last_identifier_list.id_list, $2)
1657 end
1658 last_identifier_list := Void
1659 end
1660 }
1661 | TE_ID TE_COLON Type ASemi Increment_counter2 Add_counter Named_parameter_list
1662 {
1663 remove_counter
1664 $$ := $7
1665 last_identifier_list := ast_factory.new_identifier_list (counter_value + 1)
1666
1667 if $$ /= Void and $1 /= Void and $3 /= Void and last_identifier_list /= Void then
1668 $1.to_lower
1669 last_identifier_list.reverse_extend ($1.name_id)
1670 ast_factory.reverse_extend_identifier (last_identifier_list.id_list, $1)
1671
1672 $$.reverse_extend (ast_factory.new_type_dec_as (last_identifier_list, $3, $2))
1673 end
1674 last_identifier_list := Void
1675 }
1676 ;
1677
1678
1679 -- Formal generics
1680
1681 Formal_generics:
1682 {
1683 -- $$ := Void
1684 formal_generics_end_position := 0
1685 }
1686 | TE_LSQURE TE_RSQURE
1687 {
1688 formal_generics_end_position := position
1689 --- $$ := Void
1690 $$ := ast_factory.new_eiffel_list_formal_dec_as (0)
1691 if $$ /= Void then
1692 $$.set_squre_symbols ($1, $2)
1693 end
1694 }
1695 | TE_LSQURE Add_counter Disable_supplier_recording Formal_generic_list Enable_supplier_recording Remove_counter TE_RSQURE
1696 {
1697 formal_generics_end_position := position
1698 $$ := $4
1699 $$.transform_class_types_to_formals_and_record_suppliers (ast_factory, suppliers, formal_parameters)
1700 if $$ /= Void then
1701 $$.set_squre_symbols ($1, $7)
1702 end
1703 }
1704 ;
1705
1706 Formal_generic_list: Formal_generic
1707 {
1708 $$ := ast_factory.new_eiffel_list_formal_dec_as (counter_value + 1)
1709 if $$ /= Void and $1 /= Void then
1710 $$.reverse_extend ($1)
1711 end
1712 }
1713 | Formal_generic TE_COMMA Increment_counter Formal_generic_list
1714 {
1715 $$ := $4
1716 if $$ /= Void and $1 /= Void then
1717 $$.reverse_extend ($1)
1718 ast_factory.reverse_extend_separator ($$, $2)
1719 end
1720 }
1721 ;
1722
1723 Formal_parameter: TE_REFERENCE Class_identifier
1724 {
1725 if $2 /= Void and then none_class_name_id = $2.name_id then
1726 -- Trigger an error when constraint is NONE.
1727 -- Needs to be done manually since current test for
1728 -- checking that `$2' is not a class name
1729 -- will fail for NONE, whereas before there were some
1730 -- syntactic conflict since `NONE' was a keyword and
1731 -- therefore not part of `TE_ID'.
1732 raise_error
1733 else
1734 $$ := ast_factory.new_formal_as ($2, True, False, $1)
1735 end
1736 }
1737 | TE_EXPANDED Class_identifier
1738 {
1739 if $2 /= Void and then none_class_name_id = $2.name_id then
1740 -- Trigger an error when constraint is NONE.
1741 -- Needs to be done manually since current test for
1742 -- checking that `$2' is not a class name
1743 -- will fail for NONE, whereas before there were some
1744 -- syntactic conflict since `NONE' was a keyword and
1745 -- therefore not part of `TE_ID'.
1746 raise_error
1747 else
1748 $$ := ast_factory.new_formal_as ($2, False, True, $1)
1749 end
1750 }
1751
1752 | Class_identifier
1753 {
1754 if $1 /= Void and then none_class_name_id = $1.name_id then
1755 -- Trigger an error when constraint is NONE.
1756 -- Needs to be done manually since current test for
1757 -- checking that `$1' is not a class name
1758 -- will fail for NONE, whereas before there were some
1759 -- syntactic conflict since `NONE' was a keyword and
1760 -- therefore not part of `TE_ID'.
1761 raise_error
1762 else
1763 $$ := ast_factory.new_formal_as ($1, False, False, Void)
1764 end
1765 }
1766 ;
1767
1768 Formal_generic: Formal_parameter
1769 {
1770 if $1 /= Void then
1771 -- Needs to be done here, in case current formal is used in
1772 -- Constraint.
1773 formal_parameters.extend ($1)
1774 $1.set_position (formal_parameters.count)
1775 end
1776 }
1777 Constraint
1778 {
1779 if $3 /= Void then
1780 if $3.creation_constrain /= Void then
1781 $$ := ast_factory.new_formal_dec_as ($1, $3.type, $3.creation_constrain.feature_list, $3.constrain_symbol, $3.creation_constrain.create_keyword, $3.creation_constrain.end_keyword)
1782 else
1783 $$ := ast_factory.new_formal_dec_as ($1, $3.type, Void, $3.constrain_symbol, Void, Void)
1784 end
1785 else
1786 $$ := ast_factory.new_formal_dec_as ($1, Void, Void, Void, Void, Void)
1787 end
1788 }
1789 ;
1790
1791 Constraint: -- Empty
1792 -- { $$ := Void }
1793 | TE_CONSTRAIN Single_constraint Creation_constraint
1794 {
1795 constraining_type_list := ast_factory.new_eiffel_list_constraining_type_as (1)
1796 if $1 /= Void then
1797 constraining_type_list.reverse_extend ($2)
1798 end
1799
1800 $$ := ast_factory.new_constraint_triple ($1, constraining_type_list, $3)
1801 }
1802 | TE_CONSTRAIN TE_LCURLY Add_counter Multiple_constraint_list Remove_counter TE_RCURLY Creation_constraint
1803 {
1804 $$ := ast_factory.new_constraint_triple ($1, $4, $7)
1805 }
1806 ;
1807
1808 Single_constraint: -- Empty
1809 -- { $$ := Void }
1810 | Constraint_type {is_constraint_renaming := True} Rename {is_constraint_renaming := False} TE_END
1811 {
1812 $$ := ast_factory.new_constraining_type ($1, $3, $5)
1813 }
1814 | Constraint_type
1815 {
1816 $$ := ast_factory.new_constraining_type ($1, Void, Void)
1817 }
1818 ;
1819
1820 Constraint_type:
1821 Class_or_tuple_type
1822 { $$ := $1 }
1823 | TE_LIKE Identifier_as_lower
1824 {
1825 error_handler.insert_error (ast_factory.new_vtgc1_error (line, column, filename, $2, Void))
1826 error_handler.raise_error
1827 }
1828 | TE_LIKE TE_CURRENT
1829 {
1830 error_handler.insert_error (ast_factory.new_vtgc1_error (line, column, filename, Void, $2))
1831 error_handler.raise_error
1832 }
1833 ;
1834
1835 Multiple_constraint_list: Single_constraint
1836 {
1837 $$ := ast_factory.new_eiffel_list_constraining_type_as (counter_value + 1)
1838 if $$ /= Void and $1 /= Void then
1839 $$.reverse_extend ($1)
1840 end
1841 }
1842 | Single_constraint TE_COMMA Increment_counter Multiple_constraint_list
1843 {
1844 $$ := $4
1845 if $$ /= Void and $1 /= Void then
1846 $$.reverse_extend ($1)
1847 ast_factory.reverse_extend_separator ($$, $2)
1848 end
1849
1850 -- error_handler.insert_error (ast_factory.new_vtgc1_error (line, column, filename, Void, $2))
1851 -- error_handler.raise_error
1852
1853 }
1854 ;
1855
1856 Creation_constraint: -- Empty
1857 -- { $$ := Void }
1858 | TE_CREATE Feature_list TE_END
1859 {
1860 $$ := ast_factory.new_creation_constrain_triple ($2, $1, $3)
1861 }
1862 ;
1863
1864
1865 -- Instructions
1866
1867
1868 Conditional: TE_IF Expression TE_THEN Compound TE_END
1869 { $$ := ast_factory.new_if_as ($2, $4, Void, Void, $5, $1, $3, Void) }
1870 | TE_IF Expression TE_THEN Compound Else_part TE_END
1871 {
1872 if $5 /= Void then
1873 $$ := ast_factory.new_if_as ($2, $4, Void, $5.second, $6, $1, $3, $5.first)
1874 else
1875 $$ := ast_factory.new_if_as ($2, $4, Void, Void, $6, $1, $3, Void)
1876
1877 end
1878 }
1879 | TE_IF Expression TE_THEN Compound Elseif_list TE_END
1880 { $$ := ast_factory.new_if_as ($2, $4, $5, Void, $6, $1, $3, Void) }
1881 | TE_IF Expression TE_THEN Compound Elseif_list Else_part TE_END
1882 {
1883 if $6 /= Void then
1884 $$ := ast_factory.new_if_as ($2, $4, $5, $6.second, $7, $1, $3, $6.first)
1885 else
1886 $$ := ast_factory.new_if_as ($2, $4, $5, Void, $7, $1, $3, Void)
1887 end
1888 }
1889 ;
1890
1891 Elseif_list: Add_counter Elseif_part_list Remove_counter
1892 { $$ := $2 }
1893 ;
1894
1895 Elseif_part_list: Elseif_part
1896 {
1897 $$ := ast_factory.new_eiffel_list_elseif_as (counter_value + 1)
1898 if $$ /= Void and $1 /= Void then
1899 $$.reverse_extend ($1)
1900 end
1901 }
1902 | Elseif_part Increment_counter Elseif_part_list
1903 {
1904 $$ := $3
1905 if $$ /= Void and $1 /= Void then
1906 $$.reverse_extend ($1)
1907 end
1908 }
1909 ;
1910
1911 Elseif_part: TE_ELSEIF Expression TE_THEN Compound
1912 { $$ := ast_factory.new_elseif_as ($2, $4, $1, $3) }
1913 ;
1914
1915 Else_part: TE_ELSE Compound
1916 { $$ := ast_factory.new_keyword_instruction_list_pair ($1, $2) }
1917 ;
1918
1919 Multi_branch: TE_INSPECT Expression When_part_list_opt TE_END
1920 { $$ := ast_factory.new_inspect_as ($2, $3, Void, $4, $1, Void) }
1921 | TE_INSPECT Expression When_part_list_opt TE_ELSE Compound TE_END
1922 {
1923 if $5 /= Void then
1924 $$ := ast_factory.new_inspect_as ($2, $3, $5, $6, $1, $4)
1925 else
1926 $$ := ast_factory.new_inspect_as ($2, $3,
1927 ast_factory.new_eiffel_list_instruction_as (0), $6, $1, $4)
1928 end
1929 }
1930 ;
1931
1932 When_part_list_opt: -- Empty
1933 -- { $$ := Void }
1934 | Add_counter When_part_list Remove_counter
1935 { $$ := $2 }
1936 ;
1937
1938 When_part_list: When_part
1939 {
1940 $$ := ast_factory.new_eiffel_list_case_as (counter_value + 1)
1941 if $$ /= Void and $1 /= Void then
1942 $$.reverse_extend ($1)
1943 end
1944 }
1945 | When_part Increment_counter When_part_list
1946 {
1947 $$ := $3
1948 if $$ /= Void and $1 /= Void then
1949 $$.reverse_extend ($1)
1950 end
1951 }
1952 ;
1953
1954 When_part: TE_WHEN Add_counter Choices Remove_counter TE_THEN Compound
1955 { $$ := ast_factory.new_case_as ($3, $6, $1, $5) }
1956 ;
1957
1958 Choices: Choice
1959 {
1960 $$ := ast_factory.new_eiffel_list_interval_as (counter_value + 1)
1961 if $$ /= Void and $1 /= Void then
1962 $$.reverse_extend ($1)
1963 end
1964 }
1965 | Choice TE_COMMA Increment_counter Choices
1966 {
1967 $$ := $4
1968 if $$ /= Void and $1 /= Void then
1969 $$.reverse_extend ($1)
1970 ast_factory.reverse_extend_separator ($$, $2)
1971 end
1972 }
1973 ;
1974
1975 Choice: Integer_constant
1976 { $$ := ast_factory.new_interval_as ($1, Void, Void) }
1977 | Integer_constant TE_DOTDOT Integer_constant
1978 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
1979 | Character_constant
1980 { $$ := ast_factory.new_interval_as ($1, Void, Void) }
1981 | Character_constant TE_DOTDOT Character_constant
1982 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
1983 | Identifier_as_lower
1984 { $$ := ast_factory.new_interval_as ($1, Void, Void) }
1985 | Identifier_as_lower TE_DOTDOT Identifier_as_lower
1986 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
1987 | Identifier_as_lower TE_DOTDOT Integer_constant
1988 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
1989 | Integer_constant TE_DOTDOT Identifier_as_lower
1990 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
1991 | Identifier_as_lower TE_DOTDOT Character_constant
1992 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
1993 | Character_constant TE_DOTDOT Identifier_as_lower
1994 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
1995 | A_static_call
1996 { $$ := ast_factory.new_interval_as ($1, Void, Void) }
1997 | A_static_call TE_DOTDOT Identifier_as_lower
1998 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
1999 | Identifier_as_lower TE_DOTDOT A_static_call
2000 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
2001 | A_static_call TE_DOTDOT A_static_call
2002 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
2003 | A_static_call TE_DOTDOT Integer_constant
2004 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
2005 | Integer_constant TE_DOTDOT A_static_call
2006 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
2007 | A_static_call TE_DOTDOT Character_constant
2008 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
2009 | Character_constant TE_DOTDOT A_static_call
2010 { $$ := ast_factory.new_interval_as ($1, $3, $2) }
2011
2012 ;
2013
2014 Loop: TE_FROM Compound Invariant Variant TE_UNTIL Expression TE_LOOP Compound TE_END
2015 {
2016 if $3 /= Void then
2017 $$ := ast_factory.new_loop_as ($2, $3.second, $4, $6, $8, $9, $1, $3.first, $5, $7)
2018 else
2019 $$ := ast_factory.new_loop_as ($2, Void, $4, $6, $8, $9, $1, Void, $5, $7)
2020 end
2021 }
2022 ;
2023
2024 Invariant: -- Empty
2025 -- { $$ := Void }
2026 | TE_INVARIANT Assertion
2027 { $$ := ast_factory.new_invariant_pair ($1, $2) }
2028 ;
2029
2030 Class_invariant: -- Empty
2031 -- { $$ := Void }
2032 | TE_INVARIANT
2033 { set_id_level (Invariant_level) }
2034 Assertion
2035 {
2036 set_id_level (Normal_level)
2037 $$ := ast_factory.new_invariant_as ($3, once_manifest_string_count, $1)
2038 once_manifest_string_count := 0
2039 }
2040 ;
2041
2042 Variant: -- Empty
2043 -- { $$ := Void }
2044 | TE_VARIANT Identifier_as_lower TE_COLON Expression
2045 { $$ := ast_factory.new_variant_as ($2, $4, $1, $3) }
2046 | TE_VARIANT Expression
2047 { $$ := ast_factory.new_variant_as (Void, $2, $1, Void) }
2048 ;
2049
2050 Debug: TE_DEBUG Debug_keys Compound TE_END
2051 { $$ := ast_factory.new_debug_as ($2, $3, $1, $4) }
2052 ;
2053
2054 Debug_keys: -- Empty
2055 -- { $$ := Void }
2056 | TE_LPARAN TE_RPARAN
2057 { $$ := ast_factory.new_debug_key_list_as (Void, $1, $2) }
2058 | TE_LPARAN Add_counter String_list Remove_counter TE_RPARAN
2059 { $$ := ast_factory.new_debug_key_list_as ($3, $1, $5) }
2060 ;
2061
2062 String_list: Non_empty_string
2063 {
2064 $$ := ast_factory.new_eiffel_list_string_as (counter_value + 1)
2065 if $$ /= Void and $1 /= Void then
2066 $$.reverse_extend ($1)
2067 end
2068 }
2069 | Non_empty_string TE_COMMA Increment_counter String_list
2070 {
2071 $$ := $4
2072 if $$ /= Void and $1 /= Void then
2073 $$.reverse_extend ($1)
2074 ast_factory.reverse_extend_separator ($$, $2)
2075 end
2076 }
2077 ;
2078
2079 Rescue: -- Empty
2080 -- { $$ := Void }
2081 | TE_RESCUE Compound
2082 {
2083 if $2 = Void then
2084 $$ := ast_factory.new_keyword_instruction_list_pair ($1, ast_factory.new_eiffel_list_instruction_as (0))
2085 else
2086 $$ := ast_factory.new_keyword_instruction_list_pair ($1, $2)
2087 end
2088 }
2089 ;
2090
2091 Qualified_expression:
2092 Qualified_binary_expression
2093 { $$ := $1 }
2094 | Qualified_factor
2095 { $$ := $1 }
2096 | Qualified_call
2097 { $$ := ast_factory.new_expr_call_as ($1) }
2098 | A_static_call
2099 { $$ := $1 }
2100 ;
2101
2102 Assigner_call: Qualified_expression TE_ASSIGNMENT Expression
2103 { $$ := ast_factory.new_assigner_call_as ($1, $3, $2) }
2104 ;
2105
2106 Assignment: Identifier_as_lower TE_ASSIGNMENT Expression
2107 { $$ := ast_factory.new_assign_as (ast_factory.new_access_id_as ($1, Void), $3, $2) }
2108 | TE_RESULT TE_ASSIGNMENT Expression
2109 { $$ := ast_factory.new_assign_as ($1, $3, $2) }
2110 ;
2111
2112 Reverse_assignment: Identifier_as_lower TE_ACCEPT Expression
2113 { $$ := ast_factory.new_reverse_as (ast_factory.new_access_id_as ($1, Void), $3, $2) }
2114 | TE_RESULT TE_ACCEPT Expression
2115 { $$ := ast_factory.new_reverse_as ($1, $3, $2) }
2116 ;
2117
2118 Creators: -- Empty
2119 -- { $$ := Void }
2120 | Add_counter Creation_clause_list Remove_counter
2121 { $$ := $2 }
2122 ;
2123
2124 Creation_clause_list: Creation_clause
2125 {
2126 $$ := ast_factory.new_eiffel_list_create_as (counter_value + 1)
2127 if $$ /= Void and $1 /= Void then
2128 $$.reverse_extend ($1)
2129 end
2130 }
2131 | Creation_clause Increment_counter Creation_clause_list
2132 {
2133 $$ := $3
2134 if $$ /= Void and $1 /= Void then
2135 $$.reverse_extend ($1)
2136 end
2137 }
2138 ;
2139
2140 Creation_clause:
2141 TE_CREATE
2142 {
2143 $$ := ast_factory.new_create_as (Void, Void, $1)
2144 }
2145 | TE_CREATE Clients Feature_list
2146 {
2147 $$ := ast_factory.new_create_as ($2, $3, $1)
2148 }
2149 | TE_CREATE Client_list
2150 {
2151 $$ := ast_factory.new_create_as (ast_factory.new_client_as ($2), Void, $1)
2152 }
2153 | TE_CREATION
2154 {
2155 $$ := ast_factory.new_create_as (Void, Void, $1)
2156 if has_syntax_warning and $1 /= Void then
2157 Error_handler.insert_warning (
2158 create {SYNTAX_WARNING}.make ($1.line, $1.column, filename,
2159 once "Use keyword `create' instead."))
2160 end
2161 }
2162 | TE_CREATION Clients Feature_list
2163 {
2164 $$ := ast_factory.new_create_as ($2, $3, $1)
2165 if has_syntax_warning and $1 /= Void then
2166 Error_handler.insert_warning (
2167 create {SYNTAX_WARNING}.make ($1.line, $1.column, filename,
2168 once "Use keyword `create' instead."))
2169 end
2170 }
2171 | TE_CREATION Client_list
2172 {
2173 $$ := ast_factory.new_create_as (ast_factory.new_client_as ($2), Void, $1)
2174 if has_syntax_warning and $1 /= Void then
2175 Error_handler.insert_warning (
2176 create {SYNTAX_WARNING}.make ($1.line, $1.column, filename,
2177 once "Use keyword `create' instead."))
2178 end
2179 }
2180 ;
2181
2182 Agent_call:
2183 TE_AGENT Optional_formal_arguments Type_mark {add_feature_frame} Optional_attribute_or_routine {remove_feature_frame} Delayed_actuals
2184 {
2185 if $3 /= Void then
2186 last_type := $3.second
2187 last_symbol := $3.first
2188 else
2189 last_type := Void
2190 last_symbol := Void
2191 end
2192
2193 $$ := ast_factory.new_inline_agent_creation_as (
2194 ast_factory.new_body_as ($2, last_type, Void, $5, last_symbol, Void, Void, Void), $7, $1)
2195 }
2196 |
2197 TE_AGENT Feature_name_for_call Delayed_actuals
2198 {
2199 $$ := ast_factory.new_agent_routine_creation_as (
2200 Void, $2, $3, False, $1, Void)
2201 }
2202 |
2203 TE_AGENT Agent_target TE_DOT Feature_name_for_call Delayed_actuals
2204 {
2205 if $2 /= Void then
2206 $$ := ast_factory.new_agent_routine_creation_as ($2.operand, $4, $5, True, $1, $3)
2207 if $$ /= Void then
2208 $$.set_lparan_symbol ($2.lparan_symbol)
2209 $$.set_rparan_symbol ($2.rparan_symbol)
2210 end
2211 else
2212 $$ := ast_factory.new_agent_routine_creation_as (Void, $4, $5, True, $1, $3)
2213 end
2214 }
2215 | Tilda_agent_call
2216 {
2217 if $1 /= Void then
2218 $$ := $1.first
2219 if has_syntax_warning and $1.second /= Void then
2220 Error_handler.insert_warning (
2221 create {SYNTAX_WARNING}.make ($1.second.line,
2222 $1.second.column, filename, once "Use keyword `agent' instead."))
2223 end
2224 end
2225 }
2226 ;
2227
2228 Optional_formal_arguments:
2229 | Formal_arguments
2230 {
2231 $$ := $1
2232 }
2233 ;
2234
2235 Type_mark:
2236 | TE_COLON Type
2237 {
2238 create $$.make ($1, $2)
2239 }
2240 ;
2241
2242 Optional_attribute_or_routine:
2243 Routine
2244 {
2245 $$ := $1
2246 }
2247 ;
2248
2249 --Note: Manu 02/07/2004: we need to expand `Agent_target' otherwise it causes some
2250 -- Reduce/Reduce conflict. `Tilda_agent_call' should be written as:
2251 --Tilda_agent_call: TE_TILDE Identifier_as_lower Delayed_actuals
2252 -- { $$ := ast_factory.new_old_routine_creation_as ($2, ast_factory.new_operand_as (Void, Void, Void), $2, $3, False) }
2253 -- | Agent_targt TE_TILDE Identifier_as_lower Delayed_actuals
2254 -- { $$ := ast_factory.new_old_routine_creation_as ($3, $1, $3, $4, True) }
2255 -- ;
2256 Tilda_agent_call: TE_TILDE Identifier_as_lower Delayed_actuals
2257 {
2258 $$ := ast_factory.new_old_routine_creation_as ($2, Void, $2, $3, False, $1)
2259 }
2260 | Identifier_as_lower TE_TILDE Identifier_as_lower Delayed_actuals
2261 {
2262 $$ := ast_factory.new_old_routine_creation_as ($1, ast_factory.new_operand_as (Void, ast_factory.new_access_id_as ($1, Void), Void), $3, $4, True, $2)
2263 }
2264 | TE_LPARAN Expression TE_RPARAN TE_TILDE Identifier_as_lower Delayed_actuals
2265 {
2266 $$ := ast_factory.new_old_routine_creation_as ($2, ast_factory.new_operand_as (Void, Void, $2), $5, $6, True, $4)
2267 if $$ /= Void and then $$.first /= Void then
2268 $$.first.set_lparan_symbol ($1)
2269 $$.first.set_rparan_symbol ($3)
2270 end
2271 }
2272 | TE_RESULT TE_TILDE Identifier_as_lower Delayed_actuals
2273 {
2274 $$ := ast_factory.new_old_routine_creation_as ($3, ast_factory.new_operand_as (Void, $1, Void), $3, $4, True, $2)
2275 }
2276 | TE_CURRENT TE_TILDE Identifier_as_lower Delayed_actuals
2277 {
2278 $$ := ast_factory.new_old_routine_creation_as ($3, ast_factory.new_operand_as (Void, $1, Void), $3, $4, True, $2)
2279 }
2280 | TE_LCURLY Type TE_CURLYTILDE Identifier_as_lower Delayed_actuals
2281 {
2282 if $2 /= Void then
2283 $2.set_lcurly_symbol ($1)
2284 end
2285 $$ := ast_factory.new_old_routine_creation_as ($2, ast_factory.new_operand_as ($2, Void, Void), $4, $5, True, $3)
2286 }
2287 | TE_QUESTION TE_TILDE Identifier_as_lower Delayed_actuals
2288 {
2289 temp_operand_as := ast_factory.new_operand_as (Void, Void, Void)
2290 if temp_operand_as /= Void then
2291 temp_operand_as.set_question_mark_symbol ($1)
2292 end
2293 $$ := ast_factory.new_old_routine_creation_as ($3, temp_operand_as, $3, $4, True, $2)
2294 }
2295 ;
2296
2297 Agent_target: Identifier_as_lower
2298 { $$ := ast_factory.new_agent_target_triple (Void, Void, ast_factory.new_operand_as (Void, ast_factory.new_access_id_as ($1, Void), Void)) }
2299 | TE_LPARAN Add_counter Add_counter Expression Remove_counter Remove_counter TE_RPARAN
2300 { $$ := ast_factory.new_agent_target_triple ($1, $7, ast_factory.new_operand_as (Void, Void, $4)) }
2301 | TE_RESULT
2302 { $$ := ast_factory.new_agent_target_triple (Void, Void, ast_factory.new_operand_as (Void, $1, Void)) }
2303 | TE_CURRENT
2304 { $$ := ast_factory.new_agent_target_triple (Void, Void, ast_factory.new_operand_as (Void, $1, Void)) }
2305 | Typed
2306 { $$ := ast_factory.new_agent_target_triple (Void, Void, ast_factory.new_operand_as ($1, Void, Void))}
2307 | TE_QUESTION
2308 {
2309 temp_operand_as := ast_factory.new_operand_as (Void, Void, Void)
2310 if temp_operand_as /= Void then
2311 temp_operand_as.set_question_mark_symbol ($1)
2312 end
2313 $$ := ast_factory.new_agent_target_triple (Void, Void, temp_operand_as)
2314 }
2315 ;
2316
2317 Delayed_actuals: -- Empty
2318 -- { $$ := Void }
2319 | TE_LPARAN TE_RPARAN
2320 { $$ := ast_factory.new_delayed_actual_list_as (Void, $1, $2) }
2321 | TE_LPARAN Add_counter Delayed_actual_list Remove_counter TE_RPARAN
2322 { $$ := ast_factory.new_delayed_actual_list_as ($3, $1, $5) }
2323 ;
2324
2325 Delayed_actual_list: Delayed_actual
2326 {
2327 $$ := ast_factory.new_eiffel_list_operand_as (counter_value + 1)
2328 if $$ /= Void and $1 /= Void then
2329 $$.reverse_extend ($1)
2330 end
2331 }
2332 | Delayed_actual TE_COMMA Increment_counter Delayed_actual_list
2333 {
2334 $$ := $4
2335 if $$ /= Void and $1 /= Void then
2336 $$.reverse_extend ($1)
2337 ast_factory.reverse_extend_separator ($$, $2)
2338 end
2339 }
2340 ;
2341
2342 Delayed_actual: TE_QUESTION
2343 { $$ := ast_factory.new_operand_as (Void, Void, Void)
2344 if $$ /= Void then
2345 $$.set_question_mark_symbol ($1)
2346 end
2347 }
2348 -- Manu: 01/19/2005: Due to syntax ambiguity we cannot have `Typed' only
2349 -- as there will be no way to distinguish it from a Manifest type expression.
2350 -- To preserve this feature in case it is needed by some of our customers
2351 -- we have invented the new syntax ? Typed.
2352 | Typed TE_QUESTION
2353 { $$ := ast_factory.new_operand_as ($1, Void, Void)
2354 if $$ /= Void then
2355 $$.set_question_mark_symbol ($2)
2356 end
2357 }
2358 | Expression
2359 { $$ := ast_factory.new_operand_as (Void, Void, $1) }
2360 ;
2361
2362 Creation: TE_BANG TE_BANG Creation_target Creation_call
2363 {
2364 $$ := ast_factory.new_bang_creation_as (Void, $3, $4, $1, $2)
2365 if has_syntax_warning and $3 /= Void then
2366 Error_handler.insert_warning (
2367 create {SYNTAX_WARNING}.make ($3.start_location.line,
2368 $3.start_location.column, filename, "Use keyword `create' instead."))
2369 end
2370 }
2371 | TE_BANG Type TE_BANG Creation_target Creation_call
2372 {
2373 $$ := ast_factory.new_bang_creation_as ($2, $4, $5, $1, $3)
2374 if has_syntax_warning and $4 /= Void then
2375 Error_handler.insert_warning (
2376 create {SYNTAX_WARNING}.make ($4.start_location.line,
2377 $4.start_location.column, filename, "Use keyword `create' instead."))
2378 end
2379 }
2380 | TE_CREATE Creation_target Creation_call
2381 { $$ := ast_factory.new_create_creation_as (Void, $2, $3, $1) }
2382 | TE_CREATE Typed Creation_target Creation_call
2383 { $$ := ast_factory.new_create_creation_as ($2, $3, $4, $1) }
2384 ;
2385
2386 Creation_expression: TE_CREATE Typed Creation_call
2387 { $$ := ast_factory.new_create_creation_expr_as ($2, $3, $1) }
2388 | TE_BANG Type TE_BANG Creation_call
2389 {
2390 $$ := ast_factory.new_bang_creation_expr_as ($2, $4, $1, $3)
2391 if has_syntax_warning and $2 /= Void then
2392 Error_handler.insert_warning (
2393 create {SYNTAX_WARNING}.make ($2.start_location.line,
2394 $2.start_location.column, filename, "Use keyword `create' instead."))
2395 end
2396 }
2397 ;
2398
2399 Creation_target: Identifier_as_lower
2400 { $$ := ast_factory.new_access_id_as ($1, Void) }
2401 | TE_RESULT
2402 { $$ := $1 }
2403 ;
2404
2405 Creation_call: -- Empty
2406 -- { $$ := Void }
2407 | TE_DOT Identifier_as_lower Parameters
2408 { $$ := ast_factory.new_access_inv_as ($2, $3, $1) }
2409 ;
2410
2411
2412 -- Instruction call
2413
2414
2415 Call: A_feature
2416 { $$ := $1 }
2417 | A_precursor
2418 { $$ := $1 }
2419 | A_static_call
2420 { $$ := $1 }
2421 | Qualified_call
2422 { $$ := $1 }
2423 ;
2424
2425 Check: TE_CHECK Assertion TE_END
2426 { $$ := ast_factory.new_check_as ($2, $1, $3) }
2427 ;
2428
2429
2430 -- Expression
2431
2432 Typed: TE_LCURLY Type TE_RCURLY
2433 { $$ := $2
2434 if $$ /= Void then
2435 $$.set_lcurly_symbol ($1)
2436 $$.set_rcurly_symbol ($3)
2437 end
2438 }
2439 ;
2440
2441 Expression:
2442 Nosigned_integer
2443 { $$ := $1; has_type := True }
2444 | Nosigned_real
2445 { $$ := $1; has_type := True }
2446 | Factor
2447 { $$ := $1 }
2448 | Typed_expression
2449 { $$ := $1; has_type := True }
2450 | Expression TE_EQ Expression
2451 { $$ := ast_factory.new_bin_eq_as ($1, $3, $2); has_type := True }
2452 | Expression TE_NE Expression
2453 { $$ := ast_factory.new_bin_ne_as ($1, $3, $2); has_type := True }
2454 | Qualified_binary_expression
2455 { $$ := $1; has_type := True }
2456 ;
2457
2458 Qualified_binary_expression:
2459 Expression TE_PLUS Expression
2460 { $$ := ast_factory.new_bin_plus_as ($1, $3, $2) }
2461 | Expression TE_MINUS Expression
2462 { $$ := ast_factory.new_bin_minus_as ($1, $3, $2) }
2463 | Expression TE_STAR Expression
2464 { $$ := ast_factory.new_bin_star_as ($1, $3, $2) }
2465 | Expression TE_SLASH Expression
2466 { $$ := ast_factory.new_bin_slash_as ($1, $3, $2) }
2467 | Expression TE_MOD Expression
2468 { $$ := ast_factory.new_bin_mod_as ($1, $3, $2) }
2469 | Expression TE_DIV Expression
2470 { $$ := ast_factory.new_bin_div_as ($1, $3, $2) }
2471 | Expression TE_POWER Expression
2472 { $$ := ast_factory.new_bin_power_as ($1, $3, $2) }
2473 | Expression TE_AND Expression
2474 { $$ := ast_factory.new_bin_and_as ($1, $3, $2) }
2475 | Expression TE_AND TE_THEN Expression %prec TE_AND
2476 { $$ := ast_factory.new_bin_and_then_as ($1, $4, $2, $3) }
2477 | Expression TE_OR Expression
2478 { $$ := ast_factory.new_bin_or_as ($1, $3, $2) }
2479 | Expression TE_OR TE_ELSE Expression %prec TE_OR
2480 { $$ := ast_factory.new_bin_or_else_as ($1, $4,$2, $3) }
2481 | Expression TE_IMPLIES Expression
2482 { $$ := ast_factory.new_bin_implies_as ($1, $3, $2) }
2483 | Expression TE_XOR Expression
2484 { $$ := ast_factory.new_bin_xor_as ($1, $3, $2) }
2485 | Expression TE_GE Expression
2486 { $$ := ast_factory.new_bin_ge_as ($1, $3, $2) }
2487 | Expression TE_GT Expression
2488 { $$ := ast_factory.new_bin_gt_as ($1, $3, $2) }
2489 | Expression TE_LE Expression
2490 { $$ := ast_factory.new_bin_le_as ($1, $3, $2) }
2491 | Expression TE_LT Expression
2492 { $$ := ast_factory.new_bin_lt_as ($1, $3, $2) }
2493 | Expression Free_operator Expression %prec TE_FREE
2494 { $$ := ast_factory.new_bin_free_as ($1, $2, $3) }
2495 ;
2496
2497 Factor: TE_VOID
2498 { $$ := $1; has_type := True }
2499 | Manifest_array
2500 { $$ := $1; has_type := True }
2501 | Agent_call
2502 { $$ := $1; has_type := False }
2503 | TE_OLD Expression
2504 { $$ := ast_factory.new_un_old_as ($2, $1); has_type := True }
2505 | TE_STRIP TE_LPARAN Strip_identifier_list TE_RPARAN
2506 {
2507 $$ := ast_factory.new_un_strip_as ($3, $1, $2, $4); has_type := True
2508 }
2509 | TE_ADDRESS Feature_name
2510 { $$ := ast_factory.new_address_as ($2, $1); has_type := True }
2511 | TE_ADDRESS TE_LPARAN Expression TE_RPARAN
2512 {
2513 $$ := ast_factory.new_expr_address_as ($3, $1, $2, $4); has_type := True
2514 }
2515 | TE_ADDRESS TE_CURRENT
2516 {
2517 $$ := ast_factory.new_address_current_as ($2, $1); has_type := True
2518 }
2519 | TE_ADDRESS TE_RESULT
2520 {
2521 $$ := ast_factory.new_address_result_as ($2, $1); has_type := True
2522 }
2523 | Bracket_target
2524 { $$ := $1 }
2525 | Qualified_factor
2526 { $$ := $1; has_type := True }
2527 ;
2528
2529 Qualified_factor:
2530 Bracket_target TE_LSQURE Add_counter Expression_list Remove_counter TE_RSQURE
2531 { $$ := ast_factory.new_bracket_as ($1, $4, $2, $6) }
2532 | TE_MINUS Factor
2533 { $$ := ast_factory.new_un_minus_as ($2, $1) }
2534 | TE_PLUS Factor
2535 { $$ := ast_factory.new_un_plus_as ($2, $1) }
2536 | TE_NOT Expression
2537 { $$ := ast_factory.new_un_not_as ($2, $1) }
2538 | Free_operator Expression %prec TE_NOT
2539 { $$ := ast_factory.new_un_free_as ($1, $2) }
2540 ;
2541
2542 Typed_expression: Typed
2543
2544 { $$ := ast_factory.new_type_expr_as ($1) }
2545 | Typed_nosigned_integer
2546 { $$ := $1 }
2547 | Typed_nosigned_real
2548 { $$ := $1 }
2549 ;
2550
2551 Free_operator: TE_FREE
2552 {
2553 if $1 /= Void then
2554 $1.to_lower
2555 end
2556 $$ := $1
2557 }
2558 ;
2559
2560
2561 -- Expression call
2562
2563 Qualified_call:
2564 TE_CURRENT TE_DOT Remote_call
2565 { $$ := ast_factory.new_nested_as ($1, $3, $2) }
2566 | TE_RESULT TE_DOT Remote_call
2567 { $$ := ast_factory.new_nested_as ($1, $3, $2) }
2568 | A_feature TE_DOT Remote_call
2569 { $$ := ast_factory.new_nested_as ($1, $3, $2) }
2570 | TE_LPARAN Expression TE_RPARAN TE_DOT Remote_call
2571 { $$ := ast_factory.new_nested_expr_as ($2, $5, $4, $1, $3) }
2572 | Bracket_target TE_LSQURE Add_counter Expression_list Remove_counter TE_RSQURE TE_DOT Remote_call
2573 { $$ := ast_factory.new_nested_expr_as (ast_factory.new_bracket_as ($1, $4, $2, $6), $8, $7, Void, Void) }
2574 | A_precursor TE_DOT Remote_call
2575 { $$ := ast_factory.new_nested_as ($1, $3, $2) }
2576 | A_static_call TE_DOT Remote_call
2577 { $$ := ast_factory.new_nested_as ($1, $3, $2) }
2578 ;
2579
2580 A_precursor: TE_PRECURSOR Parameters
2581 { $$ := ast_factory.new_precursor_as ($1, Void, $2) }
2582 | TE_PRECURSOR TE_LCURLY Class_identifier TE_RCURLY Parameters
2583 {
2584 temp_class_type_as := ast_factory.new_class_type_as ($3, Void)
2585 if temp_class_type_as /= Void then
2586 temp_class_type_as.set_lcurly_symbol ($2)
2587 temp_class_type_as.set_rcurly_symbol ($4)
2588 end
2589 $$ := ast_factory.new_precursor_as ($1, temp_class_type_as, $5)
2590 }
2591 ;
2592
2593 A_static_call: New_a_static_call
2594 { $$ := $1 }
2595 | Old_a_static_call
2596 { $$ := $1 }
2597 ;
2598
2599 New_a_static_call:
2600 Typed TE_DOT Identifier_as_lower Parameters
2601 { $$ := ast_factory.new_static_access_as ($1, $3, $4, Void, $2); }
2602 ;
2603
2604 Old_a_static_call:
2605 TE_FEATURE Typed TE_DOT Identifier_as_lower Parameters
2606 {
2607 $$ := ast_factory.new_static_access_as ($2, $4, $5, $1, $3);
2608 if has_syntax_warning and ($1 /= Void or $2 /= Void) then
2609 if $1 /= Void then
2610 ast_location := $1.start_location
2611 else
2612 ast_location := $2.start_location
2613 end
2614 Error_handler.insert_warning (
2615 create {SYNTAX_WARNING}.make (ast_location.line,
2616 ast_location.column, filename, once "Remove the `feature' keyword."))
2617 end
2618 }
2619 ;
2620
2621 Remote_call: Call_on_feature_access
2622 { $$ := $1 }
2623 | Feature_access
2624 { $$ := $1 }
2625 ;
2626
2627 Call_on_feature_access: Feature_access TE_DOT Feature_access
2628 { $$ := ast_factory.new_nested_as ($1, $3, $2) }
2629 | Feature_access TE_DOT Call_on_feature_access
2630 { $$ := ast_factory.new_nested_as ($1, $3, $2) }
2631 ;
2632
2633 Feature_name_for_call: Identifier_as_lower
2634 { $$ := $1}
2635 | Infix
2636 {
2637 if $1 /= Void then
2638 $$ := $1.internal_name
2639 end
2640 }
2641 | Prefix
2642 {
2643 if $1 /= Void then
2644 $$ := $1.internal_name
2645 end
2646 }
2647 ;
2648
2649 A_feature: Feature_name_for_call Parameters
2650 {
2651 inspect id_level
2652 when Normal_level then
2653 $$ := ast_factory.new_access_id_as ($1, $2)
2654 when Assert_level then
2655 $$ := ast_factory.new_access_assert_as ($1, $2)
2656 when Invariant_level then
2657 $$ := ast_factory.new_access_inv_as ($1, $2, Void)
2658 end
2659 }
2660 ;
2661
2662 Feature_access: Feature_name_for_call Parameters
2663 { $$ := ast_factory.new_access_feat_as ($1, $2) }
2664 ;
2665
2666 Bracket_target:
2667 Expression_constant
2668 { $$ := $1; has_type := True }
2669 | Manifest_tuple
2670 { $$ := $1; has_type := True }
2671 | TE_CURRENT
2672 { $$ := ast_factory.new_expr_call_as ($1); has_type := True }
2673 | TE_RESULT
2674 { $$ := ast_factory.new_expr_call_as ($1); has_type := True }
2675 | Call
2676 { $$ := ast_factory.new_expr_call_as ($1); has_type := False }
2677 | Creation_expression
2678 { $$ := ast_factory.new_expr_call_as ($1); has_type := True }
2679 | TE_LPARAN Expression TE_RPARAN
2680 { $$ := ast_factory.new_paran_as ($2, $1, $3); has_type := True }
2681 ;
2682
2683 Parameters: -- Empty
2684 -- { $$ := Void }
2685 | TE_LPARAN TE_RPARAN
2686 { $$ := ast_factory.new_parameter_list_as (Void, $1, $2) }
2687 | TE_LPARAN Add_counter Expression_list Remove_counter TE_RPARAN
2688 { $$ := ast_factory.new_parameter_list_as ($3, $1, $5) }
2689 ;
2690
2691 Expression_list: Expression
2692 {
2693 $$ := ast_factory.new_eiffel_list_expr_as (counter_value + 1)
2694 if $$ /= Void and $1 /= Void then
2695 $$.reverse_extend ($1)
2696 end
2697 }
2698 | Expression TE_COMMA Increment_counter Expression_list
2699 {
2700 $$ := $4
2701 if $$ /= Void and $1 /= Void then
2702 $$.reverse_extend ($1)
2703 ast_factory.reverse_extend_separator ($$, $2)
2704 end
2705 }
2706 ;
2707
2708 Class_or_tuple_identifier: TE_TUPLE
2709 {
2710 if $1 /= Void then
2711 $1.to_upper
2712 end
2713 $$ := $1
2714 }
2715 | Class_identifier
2716 {
2717 $$ := $1;
2718 }
2719 ;
2720
2721 Class_identifier: TE_ID
2722 {
2723 if $1 /= Void then
2724 $1.to_upper
2725 end
2726 $$ := $1
2727 }
2728 | TE_ASSIGN
2729 {
2730 -- Keyword used as identifier
2731 process_id_as_with_existing_stub (last_keyword_as_id_index)
2732 if has_syntax_warning then
2733 Error_handler.insert_warning (
2734 create {SYNTAX_WARNING}.make (line, column, filename,
2735 once "Use of `assign', possibly a new keyword in future definition of `Eiffel'."))
2736 end
2737
2738 if last_id_as_value /= Void then
2739 last_id_as_value.to_upper
2740 end
2741 $$ := last_id_as_value
2742 }
2743 ;
2744
2745 Identifier_as_lower: TE_ID
2746 {
2747 if $1 /= Void then
2748 $1.to_lower
2749 end
2750 $$ := $1
2751 }
2752 | TE_TUPLE
2753 {
2754 if $1 /= Void then
2755 $1.to_lower
2756 end
2757 $$ := $1
2758 }
2759 | TE_ASSIGN
2760 {
2761 -- Keyword used as identifier
2762 process_id_as_with_existing_stub (last_keyword_as_id_index)
2763 if has_syntax_warning then
2764 Error_handler.insert_warning (
2765 create {SYNTAX_WARNING}.make (line, column, filename,
2766 once "Use of `assign', possibly a new keyword in future definition of `Eiffel'."))
2767 end
2768 if last_id_as_value /= Void then
2769 last_id_as_value.to_lower
2770 end
2771 $$ := last_id_as_value
2772 }
2773 ;
2774
2775 Manifest_constant: Boolean_constant
2776 { $$ := $1 }
2777 | Character_constant
2778 { $$ := $1 }
2779 | Integer_constant
2780 { $$ := $1 }
2781 | Real_constant
2782 { $$ := $1 }
2783 | Bit_constant
2784 { $$ := $1 }
2785 | Manifest_string
2786 { $$ := $1 }
2787 ;
2788
2789 -- It contains all constants except the Integer/Real one without a sign mark.
2790 Expression_constant:
2791 Boolean_constant
2792 { $$ := $1 }
2793 | Signed_integer
2794 { $$ := $1 }
2795 | Typed_signed_integer
2796 { $$ := $1 }
2797 | Signed_real
2798 { $$ := $1 }
2799 | Typed_signed_real
2800 { $$ := $1 }
2801 | Character_constant
2802 { $$ := $1 }
2803 | Bit_constant
2804 { $$ := $1 }
2805 | Manifest_string
2806 { $$ := $1 }
2807 | TE_ONCE_STRING Manifest_string
2808 {
2809 if $2 /= Void then
2810 $2.set_is_once_string (True)
2811 $2.set_once_string_keyword ($1)
2812 end
2813 once_manifest_string_count := once_manifest_string_count + 1
2814 $$ := $2
2815 }
2816 ;
2817
2818 Boolean_constant: TE_FALSE
2819 { $$ := $1 }
2820 | TE_TRUE
2821 { $$ := $1 }
2822 ;
2823
2824 Character_constant: TE_CHAR
2825 {
2826 check is_character: not token_buffer.is_empty end
2827
2828 $$ := ast_factory.new_character_value (Current, Void, token_buffer, token_buffer2)
2829
2830 }
2831 | Typed TE_CHAR
2832 {
2833 check is_character: not token_buffer.is_empty end
2834 fixme (once "We should handle `Type' instead of ignoring it.")
2835
2836 $$ := ast_factory.new_character_value (Current, $1, token_buffer, token_buffer2)
2837 }
2838 ;
2839
2840 --###################################################################
2841 --# Integer constants
2842 --###################################################################
2843 Integer_constant:
2844 Signed_integer
2845 { $$ := $1 }
2846 | Nosigned_integer
2847 { $$ := $1 }
2848 | Typed_integer
2849 { $$ := $1 }
2850 ;
2851
2852 Signed_integer: TE_PLUS TE_INTEGER
2853 {
2854 $$ := ast_factory.new_integer_value (Current, '+', Void, token_buffer, $1)
2855 }
2856 | TE_MINUS TE_INTEGER
2857 {
2858 $$ := ast_factory.new_integer_value (Current, '-', Void, token_buffer, $1)
2859 }
2860 ;
2861
2862 Nosigned_integer: TE_INTEGER
2863 {
2864 $$ := ast_factory.new_integer_value (Current, '%U', Void, token_buffer, Void)
2865 }
2866 ;
2867
2868 Typed_integer: Typed_nosigned_integer
2869 { $$ := $1 }
2870 | Typed_signed_integer
2871 { $$ := $1 }
2872 ;
2873
2874 Typed_nosigned_integer: Typed TE_INTEGER
2875 {
2876 $$ := ast_factory.new_integer_value (Current, '%U', $1, token_buffer, Void)
2877 }
2878 ;
2879
2880 Typed_signed_integer: Typed TE_PLUS TE_INTEGER
2881 {
2882 $$ := ast_factory.new_integer_value (Current, '+', $1, token_buffer, $2)
2883 }
2884 | Typed TE_MINUS TE_INTEGER
2885 {
2886 $$ := ast_factory.new_integer_value (Current, '-', $1, token_buffer, $2)
2887 }
2888 ;
2889
2890 --###################################################################
2891 --# Real constants
2892 --###################################################################
2893 Real_constant: Signed_real
2894 { $$ := $1 }
2895 | Nosigned_real
2896 { $$ := $1 }
2897 | Typed_real
2898 { $$ := $1 }
2899 ;
2900
2901 Nosigned_real: TE_REAL
2902 {
2903 $$ := ast_factory.new_real_value (Current, False, '%U', Void, token_buffer, Void)
2904 }
2905 ;
2906
2907 Signed_real: TE_PLUS TE_REAL
2908 {
2909 $$ := ast_factory.new_real_value (Current, True, '+', Void, token_buffer, $1)
2910 }
2911 | TE_MINUS TE_REAL
2912 {
2913 $$ := ast_factory.new_real_value (Current, True, '-', Void, token_buffer, $1)
2914 }
2915 ;
2916
2917 Typed_real: Typed_nosigned_real
2918 { $$ := $1 }
2919 | Typed_signed_real
2920 { $$ := $1 }
2921 ;
2922
2923 Typed_nosigned_real: Typed TE_REAL
2924 {
2925 $$ := ast_factory.new_real_value (Current, False, '%U', $1, token_buffer, Void)
2926 }
2927 ;
2928
2929 Typed_signed_real: Typed TE_PLUS TE_REAL
2930 {
2931 $$ := ast_factory.new_real_value (Current, True, '+', $1, token_buffer, $2)
2932 }
2933 | Typed TE_MINUS TE_REAL
2934 {
2935 $$ := ast_factory.new_real_value (Current, True, '-', $1, token_buffer, $2)
2936 }
2937 ;
2938
2939 --###################################################################
2940 --# Bit constants
2941 --###################################################################
2942 Bit_constant: TE_A_BIT
2943 { $$ := ast_factory.new_bit_const_as ($1) }
2944 ;
2945
2946 --###################################################################
2947 --# Manifest string constants
2948 --###################################################################
2949 Manifest_string: Default_manifest_string
2950 { $$ := $1 }
2951 | Typed_manifest_string
2952 { $$ := $1 }
2953 ;
2954
2955 Default_manifest_string: Non_empty_string
2956 { $$ := $1 }
2957 | TE_EMPTY_STRING
2958 {
2959 $$ := ast_factory.new_string_as ("", line, column, string_position, position + text_count - string_position, token_buffer2)
2960 }
2961 | TE_EMPTY_VERBATIM_STRING
2962 {
2963 $$ := ast_factory.new_verbatim_string_as ("", verbatim_marker.substring (2, verbatim_marker.count), not has_old_verbatim_strings and then verbatim_marker.item (1) = ']', line, column, string_position, position + text_count - string_position, token_buffer2)
2964 }
2965 ;
2966
2967 Typed_manifest_string: TE_RCURLY Type TE_RCURLY Default_manifest_string
2968 {
2969 fixme (once "We should handle `Type' instead of ignoring it.")
2970 $$ := $4
2971 if $2 /= Void then
2972 $2.set_lcurly_symbol ($1)
2973 $2.set_rcurly_symbol ($3)
2974 end
2975 if $$ /= Void then
2976 $$.set_type ($2)
2977 end
2978 }
2979 ;
2980
2981 Non_empty_string: TE_STRING
2982 {
2983 $$ := ast_factory.new_string_as (cloned_string (token_buffer), line, column, string_position, position + text_count - string_position, token_buffer2)
2984 }
2985 | TE_VERBATIM_STRING
2986 {
2987 $$ := ast_factory.new_verbatim_string_as (cloned_string (token_buffer), verbatim_marker.substring (2, verbatim_marker.count), not has_old_verbatim_strings and then verbatim_marker.item (1) = ']', line, column, string_position, position + text_count - string_position, token_buffer2)
2988 }
2989 | TE_STR_LT
2990 {
2991 $$ := ast_factory.new_string_as ("<", line, column, position, 3, token_buffer2)
2992 }
2993 | TE_STR_LE
2994 {
2995 $$ := ast_factory.new_string_as ("<=", line, column, position, 4, token_buffer2)
2996 }
2997 | TE_STR_GT
2998 {
2999 $$ := ast_factory.new_string_as (">", line, column, position, 3, token_buffer2)
3000 }
3001 | TE_STR_GE
3002 {
3003 $$ := ast_factory.new_string_as (">=", line, column, position, 4, token_buffer2)
3004 }
3005 | TE_STR_MINUS
3006 {
3007 $$ := ast_factory.new_string_as ("-", line, column, position, 3, token_buffer2)
3008 }
3009 | TE_STR_PLUS
3010 {
3011 $$ := ast_factory.new_string_as ("+", line, column, position, 3, token_buffer2)
3012 }
3013 | TE_STR_STAR
3014 {
3015 $$ := ast_factory.new_string_as ("*", line, column, position, 3, token_buffer2)
3016 }
3017 | TE_STR_SLASH
3018 {
3019 $$ := ast_factory.new_string_as ("/", line, column, position, 3, token_buffer2)
3020 }
3021 | TE_STR_MOD
3022 {
3023 $$ := ast_factory.new_string_as ("\\", line, column, position, 4, token_buffer2)
3024 }
3025 | TE_STR_DIV
3026 {
3027 $$ := ast_factory.new_string_as ("//", line, column, position, 4, token_buffer2)
3028 }
3029 | TE_STR_POWER
3030 {
3031 $$ := ast_factory.new_string_as ("^", line, column, position, 3, token_buffer2)
3032 }
3033 | TE_STR_BRACKET
3034 {
3035 $$ := ast_factory.new_string_as ("[]", line, column, position, 4, token_buffer2)
3036 }
3037 | TE_STR_AND
3038 {
3039 $$ := ast_factory.new_string_as (cloned_string (token_buffer), line, column, position, 5, token_buffer2)
3040 }
3041 | TE_STR_AND_THEN
3042 {
3043 $$ := ast_factory.new_string_as (cloned_string (token_buffer), line, column, position, 10, token_buffer2)
3044 }
3045 | TE_STR_IMPLIES
3046 {
3047 $$ := ast_factory.new_string_as (cloned_string (token_buffer), line, column, position, 9, token_buffer2)
3048 }
3049 | TE_STR_OR
3050 {
3051 $$ := ast_factory.new_string_as (cloned_string (token_buffer), line, column, position, 4, token_buffer2)
3052 }
3053 | TE_STR_OR_ELSE
3054 {
3055 $$ := ast_factory.new_string_as (cloned_string (token_buffer), line, column, position, 9, token_buffer2)
3056 }
3057 | TE_STR_XOR
3058 {
3059 $$ := ast_factory.new_string_as (cloned_string (token_buffer), line, column, position, 5, token_buffer2)
3060 }
3061 | TE_STR_NOT
3062 {
3063 $$ := ast_factory.new_string_as (cloned_string (token_buffer), line, column, position, 5, token_buffer2)
3064 }
3065 | TE_STR_FREE
3066 {
3067 $$ := ast_factory.new_string_as (cloned_string (token_buffer), line, column, position, token_buffer.count + 2, token_buffer2)
3068 }
3069 ;
3070
3071 Prefix_operator: TE_STR_MINUS
3072 {
3073 $$ := ast_factory.new_string_as ("-", line, column, position, 3, token_buffer2)
3074 }
3075 | TE_STR_PLUS
3076 {
3077 $$ := ast_factory.new_string_as ("+", line, column, position, 3, token_buffer2)
3078 }
3079 | TE_STR_NOT
3080 {
3081 $$ := ast_factory.new_string_as ("not", line, column, position, 5, token_buffer2)
3082 }
3083 | TE_STR_FREE
3084 {
3085 $$ := ast_factory.new_string_as (cloned_lower_string (token_buffer), line, column, position, token_buffer.count + 2, token_buffer2)
3086 }
3087 ;
3088
3089 Infix_operator: TE_STR_LT
3090 {
3091 $$ := ast_factory.new_string_as ("<", line, column, position, 3, token_buffer2)
3092 }
3093 | TE_STR_LE
3094 {
3095 $$ := ast_factory.new_string_as ("<=", line, column, position, 4, token_buffer2)
3096 }
3097 | TE_STR_GT
3098 {
3099 $$ := ast_factory.new_string_as (">", line, column, position, 3, token_buffer2)
3100 }
3101 | TE_STR_GE
3102 {
3103 $$ := ast_factory.new_string_as (">=", line, column, position, 4, token_buffer2)
3104 }
3105 | TE_STR_MINUS
3106 {
3107 $$ := ast_factory.new_string_as ("-", line, column, position, 3, token_buffer2)
3108 }
3109 | TE_STR_PLUS
3110 {
3111 $$ := ast_factory.new_string_as ("+", line, column, position, 3, token_buffer2)
3112 }
3113 | TE_STR_STAR
3114 {
3115 $$ := ast_factory.new_string_as ("*", line, column, position, 3, token_buffer2)
3116 }
3117 | TE_STR_SLASH
3118 {
3119 $$ := ast_factory.new_string_as ("/", line, column, position, 3, token_buffer2)
3120 }
3121 | TE_STR_MOD
3122 {
3123 $$ := ast_factory.new_string_as ("\\", line, column, position, 4, token_buffer2)
3124 }
3125 | TE_STR_DIV
3126 {
3127 $$ := ast_factory.new_string_as ("//", line, column, position, 4, token_buffer2)
3128 }
3129 | TE_STR_POWER
3130 {
3131 $$ := ast_factory.new_string_as ("^", line, column, position, 3, token_buffer2)
3132 }
3133 | TE_STR_AND
3134 {
3135 $$ := ast_factory.new_string_as ("and", line, column, position, 5, token_buffer2)
3136 }
3137 | TE_STR_AND_THEN
3138 {
3139 $$ := ast_factory.new_string_as ("and then", line, column, position, 10, token_buffer2)
3140 }
3141 | TE_STR_IMPLIES
3142 {
3143 $$ := ast_factory.new_string_as ("implies", line, column, position, 9, token_buffer2)
3144 }
3145 | TE_STR_OR
3146 {
3147 $$ := ast_factory.new_string_as ("or", line, column, position, 4, token_buffer2)
3148 }
3149 | TE_STR_OR_ELSE
3150 {
3151 $$ := ast_factory.new_string_as ("or else", line, column, position, 9, token_buffer2)
3152 }
3153 | TE_STR_XOR
3154 {
3155 $$ := ast_factory.new_string_as ("xor", line, column, position, 5, token_buffer2)
3156 }
3157 | TE_STR_FREE
3158 {
3159 $$ := ast_factory.new_string_as (cloned_lower_string (token_buffer), line, column, position, token_buffer.count + 2, token_buffer2)
3160 }
3161 ;
3162
3163 Manifest_array: TE_LARRAY TE_RARRAY
3164 {
3165 $$ := ast_factory.new_array_as (ast_factory.new_eiffel_list_expr_as (0), $1, $2)
3166 }
3167 | TE_LARRAY Add_counter Expression_list Remove_counter TE_RARRAY
3168 { $$ := ast_factory.new_array_as ($3, $1, $5) }
3169 ;
3170
3171 Manifest_tuple: TE_LSQURE TE_RSQURE
3172 { $$ := ast_factory.new_tuple_as (ast_factory.new_eiffel_list_expr_as (0), $1, $2) }
3173 | TE_LSQURE Add_counter Expression_list Remove_counter TE_RSQURE
3174 { $$ := ast_factory.new_tuple_as ($3, $1, $5) }
3175 ;
3176
3177 Add_indexing_counter:
3178 {
3179 initial_has_old_verbatim_strings_warning := has_old_verbatim_strings_warning
3180 set_has_old_verbatim_strings_warning (false)
3181 add_counter
3182 }
3183 ;
3184
3185 Add_counter: { add_counter }
3186 ;
3187
3188 Add_counter2: { add_counter2 }
3189 ;
3190
3191 Increment_counter: { increment_counter }
3192 ;
3193
3194 Increment_counter2: { increment_counter2 }
3195 ;
3196
3197 Remove_counter: { remove_counter }
3198 ;
3199
3200
3201 %%
3202
3203 indexing
3204 copyright: "Copyright (c) 1984-2006, Eiffel Software"
3205 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
3206 licensing_options: "http://www.eiffel.com/licensing"
3207 copying: "[
3208 This file is part of Eiffel Software's Eiffel Development Environment.
3209
3210 Eiffel Software's Eiffel Development Environment is free
3211 software; you can redistribute it and/or modify it under
3212 the terms of the GNU General Public License as published
3213 by the Free Software Foundation, version 2 of the License
3214 (available at the URL listed under "license" above).
3215
3216 Eiffel Software's Eiffel Development Environment is
3217 distributed in the hope that it will be useful, but
3218 WITHOUT ANY WARRANTY; without even the implied warranty
3219 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
3220 See the GNU General Public License for more details.
3221
3222 You should have received a copy of the GNU General Public
3223 License along with Eiffel Software's Eiffel Development
3224 Environment; if not, write to the Free Software Foundation,
3225 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3226 ]"
3227 source: "[
3228 Eiffel Software
3229 356 Storke Road, Goleta, CA 93117 USA
3230 Telephone 805-685-1006, Fax 805-685-6869
3231 Website http://www.eiffel.com
3232 Customer support http://support.eiffel.com
3233 ]"
3234
3235 end -- class EIFFEL_PARSER

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23