1 # Production AST nodes full definition.
2 # This file was generated by SableCC (http://www.sablecc.org/).
3 module parser_prod
is no_warning
("missing-doc")
6 intrude import parser_nodes
10 # Parent of the node in the AST
11 var parent
: nullable ANode is writable
13 # Remove a child from the AST
14 fun remove_child
(child
: ANode)
16 replace_child
(child
, null)
19 # Replace a child with an other node in the AST
20 fun replace_child
(old_child
: ANode, new_child
: nullable ANode) is abstract
22 # Replace itself with an other node in the AST
23 fun replace_with
(node
: ANode)
25 if _parent
!= null then
26 _parent
.replace_child
(self, node
)
30 # Visit all nodes in order.
31 # Thus, call "v.visit(e)" for each node e
32 fun visit_all
(v
: Visitor) is abstract
36 redef fun visit_all
(v
: Visitor) do end
37 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode) do end
41 redef fun replace_with
(n
: ANode)
49 # Abstract standard visitor
50 abstract class Visitor
51 # What the visitor do when a node is visited
52 # Concrete visitors should redefine this method.
53 protected fun visit
(e
: nullable ANode) is abstract
55 # Ask the visitor to visit a given node.
56 # Usually automatically called by visit_all* methods.
57 # This methos should not be redefined
58 fun enter_visit
(e
: nullable ANode)
60 var old
= current_node
66 # The current visited node
67 var current_node
: nullable ANode = null
71 private init empty_init
do end
74 n_lines
: Collection[Object], # Should be Collection[ALine]
75 n_label_decl
: nullable ALabelDecl,
76 n_end_block
: nullable TEndBlock
85 _n_label_decl
= n_label_decl
86 if n_label_decl
!= null then
87 n_label_decl
.parent
= self
89 _n_end_block
= n_end_block
.as(not null)
90 n_end_block
.parent
= self
93 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
95 for i
in [0.._n_lines
.length
[ do
96 if _n_lines
[i
] == old_child
then
97 if new_child
!= null then
98 assert new_child
isa ALine
99 _n_lines
[i
] = new_child
100 new_child
.parent
= self
102 _n_lines
.remove_at
(i
)
107 if _n_label_decl
== old_child
then
108 if new_child
!= null then
109 new_child
.parent
= self
110 assert new_child
isa ALabelDecl
111 _n_label_decl
= new_child
117 if _n_end_block
== old_child
then
118 if new_child
!= null then
119 new_child
.parent
= self
120 assert new_child
isa TEndBlock
121 _n_end_block
= new_child
129 redef fun visit_all
(v
: Visitor)
134 if _n_label_decl
!= null then
135 v
.enter_visit
(_n_label_decl
.as(not null))
137 v
.enter_visit
(_n_end_block
)
140 redef class AEmptyLine
141 private init empty_init
do end
143 init init_aemptyline
(
144 n_label_decl
: nullable ALabelDecl,
145 n_comment
: nullable TComment,
150 _n_label_decl
= n_label_decl
151 if n_label_decl
!= null then
152 n_label_decl
.parent
= self
154 _n_comment
= n_comment
155 if n_comment
!= null then
156 n_comment
.parent
= self
158 _n_eol
= n_eol
.as(not null)
162 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
164 if _n_label_decl
== old_child
then
165 if new_child
!= null then
166 new_child
.parent
= self
167 assert new_child
isa ALabelDecl
168 _n_label_decl
= new_child
174 if _n_comment
== old_child
then
175 if new_child
!= null then
176 new_child
.parent
= self
177 assert new_child
isa TComment
178 _n_comment
= new_child
184 if _n_eol
== old_child
then
185 if new_child
!= null then
186 new_child
.parent
= self
187 assert new_child
isa TEol
196 redef fun visit_all
(v
: Visitor)
198 if _n_label_decl
!= null then
199 v
.enter_visit
(_n_label_decl
.as(not null))
201 if _n_comment
!= null then
202 v
.enter_visit
(_n_comment
.as(not null))
204 v
.enter_visit
(_n_eol
)
207 redef class AInstructionLine
208 private init empty_init
do end
210 init init_ainstructionline
(
211 n_label_decl
: nullable ALabelDecl,
212 n_instruction
: nullable AInstruction,
213 n_comment
: nullable TComment,
218 _n_label_decl
= n_label_decl
219 if n_label_decl
!= null then
220 n_label_decl
.parent
= self
222 _n_instruction
= n_instruction
.as(not null)
223 n_instruction
.parent
= self
224 _n_comment
= n_comment
225 if n_comment
!= null then
226 n_comment
.parent
= self
228 _n_eol
= n_eol
.as(not null)
232 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
234 if _n_label_decl
== old_child
then
235 if new_child
!= null then
236 new_child
.parent
= self
237 assert new_child
isa ALabelDecl
238 _n_label_decl
= new_child
244 if _n_instruction
== old_child
then
245 if new_child
!= null then
246 new_child
.parent
= self
247 assert new_child
isa AInstruction
248 _n_instruction
= new_child
254 if _n_comment
== old_child
then
255 if new_child
!= null then
256 new_child
.parent
= self
257 assert new_child
isa TComment
258 _n_comment
= new_child
264 if _n_eol
== old_child
then
265 if new_child
!= null then
266 new_child
.parent
= self
267 assert new_child
isa TEol
276 redef fun visit_all
(v
: Visitor)
278 if _n_label_decl
!= null then
279 v
.enter_visit
(_n_label_decl
.as(not null))
281 v
.enter_visit
(_n_instruction
)
282 if _n_comment
!= null then
283 v
.enter_visit
(_n_comment
.as(not null))
285 v
.enter_visit
(_n_eol
)
288 redef class ADirectiveLine
289 private init empty_init
do end
291 init init_adirectiveline
(
292 n_label_decl
: nullable ALabelDecl,
293 n_directive
: nullable ADirective,
294 n_comment
: nullable TComment,
299 _n_label_decl
= n_label_decl
300 if n_label_decl
!= null then
301 n_label_decl
.parent
= self
303 _n_directive
= n_directive
.as(not null)
304 n_directive
.parent
= self
305 _n_comment
= n_comment
306 if n_comment
!= null then
307 n_comment
.parent
= self
309 _n_eol
= n_eol
.as(not null)
313 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
315 if _n_label_decl
== old_child
then
316 if new_child
!= null then
317 new_child
.parent
= self
318 assert new_child
isa ALabelDecl
319 _n_label_decl
= new_child
325 if _n_directive
== old_child
then
326 if new_child
!= null then
327 new_child
.parent
= self
328 assert new_child
isa ADirective
329 _n_directive
= new_child
335 if _n_comment
== old_child
then
336 if new_child
!= null then
337 new_child
.parent
= self
338 assert new_child
isa TComment
339 _n_comment
= new_child
345 if _n_eol
== old_child
then
346 if new_child
!= null then
347 new_child
.parent
= self
348 assert new_child
isa TEol
357 redef fun visit_all
(v
: Visitor)
359 if _n_label_decl
!= null then
360 v
.enter_visit
(_n_label_decl
.as(not null))
362 v
.enter_visit
(_n_directive
)
363 if _n_comment
!= null then
364 v
.enter_visit
(_n_comment
.as(not null))
366 v
.enter_visit
(_n_eol
)
369 redef class ALabelDecl
370 private init empty_init
do end
372 init init_alabeldecl
(
374 n_colon
: nullable TColon
378 _n_id
= n_id
.as(not null)
380 _n_colon
= n_colon
.as(not null)
381 n_colon
.parent
= self
384 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
386 if _n_id
== old_child
then
387 if new_child
!= null then
388 new_child
.parent
= self
389 assert new_child
isa TId
396 if _n_colon
== old_child
then
397 if new_child
!= null then
398 new_child
.parent
= self
399 assert new_child
isa TColon
408 redef fun visit_all
(v
: Visitor)
411 v
.enter_visit
(_n_colon
)
414 redef class AUnaryInstruction
415 private init empty_init
do end
417 init init_aunaryinstruction
(
422 _n_id
= n_id
.as(not null)
426 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
428 if _n_id
== old_child
then
429 if new_child
!= null then
430 new_child
.parent
= self
431 assert new_child
isa TId
440 redef fun visit_all
(v
: Visitor)
445 redef class ABinaryInstruction
446 private init empty_init
do end
448 init init_abinaryinstruction
(
450 n_operand
: nullable AOperand
454 _n_id
= n_id
.as(not null)
456 _n_operand
= n_operand
.as(not null)
457 n_operand
.parent
= self
460 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
462 if _n_id
== old_child
then
463 if new_child
!= null then
464 new_child
.parent
= self
465 assert new_child
isa TId
472 if _n_operand
== old_child
then
473 if new_child
!= null then
474 new_child
.parent
= self
475 assert new_child
isa AOperand
476 _n_operand
= new_child
484 redef fun visit_all
(v
: Visitor)
487 v
.enter_visit
(_n_operand
)
490 redef class AImmediateOperand
491 private init empty_init
do end
493 init init_aimmediateoperand
(
494 n_value
: nullable AValue
498 _n_value
= n_value
.as(not null)
499 n_value
.parent
= self
502 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
504 if _n_value
== old_child
then
505 if new_child
!= null then
506 new_child
.parent
= self
507 assert new_child
isa AValue
516 redef fun visit_all
(v
: Visitor)
518 v
.enter_visit
(_n_value
)
521 redef class AAnyOperand
522 private init empty_init
do end
524 init init_aanyoperand
(
525 n_value
: nullable AValue,
526 n_comma
: nullable TComma,
531 _n_value
= n_value
.as(not null)
532 n_value
.parent
= self
533 _n_comma
= n_comma
.as(not null)
534 n_comma
.parent
= self
535 _n_id
= n_id
.as(not null)
539 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
541 if _n_value
== old_child
then
542 if new_child
!= null then
543 new_child
.parent
= self
544 assert new_child
isa AValue
551 if _n_comma
== old_child
then
552 if new_child
!= null then
553 new_child
.parent
= self
554 assert new_child
isa TComma
561 if _n_id
== old_child
then
562 if new_child
!= null then
563 new_child
.parent
= self
564 assert new_child
isa TId
573 redef fun visit_all
(v
: Visitor)
575 v
.enter_visit
(_n_value
)
576 v
.enter_visit
(_n_comma
)
580 redef class ALabelValue
581 private init empty_init
do end
583 init init_alabelvalue
(
588 _n_id
= n_id
.as(not null)
592 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
594 if _n_id
== old_child
then
595 if new_child
!= null then
596 new_child
.parent
= self
597 assert new_child
isa TId
606 redef fun visit_all
(v
: Visitor)
611 redef class ANumberValue
612 private init empty_init
do end
614 init init_anumbervalue
(
615 n_number
: nullable TNumber
619 _n_number
= n_number
.as(not null)
620 n_number
.parent
= self
623 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
625 if _n_number
== old_child
then
626 if new_child
!= null then
627 new_child
.parent
= self
628 assert new_child
isa TNumber
629 _n_number
= new_child
637 redef fun visit_all
(v
: Visitor)
639 v
.enter_visit
(_n_number
)
642 redef class ACharValue
643 private init empty_init
do end
645 init init_acharvalue
(
646 n_char
: nullable TChar
650 _n_char
= n_char
.as(not null)
654 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
656 if _n_char
== old_child
then
657 if new_child
!= null then
658 new_child
.parent
= self
659 assert new_child
isa TChar
668 redef fun visit_all
(v
: Visitor)
670 v
.enter_visit
(_n_char
)
673 redef class AStringValue
674 private init empty_init
do end
676 init init_astringvalue
(
677 n_string
: nullable TString
681 _n_string
= n_string
.as(not null)
682 n_string
.parent
= self
685 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
687 if _n_string
== old_child
then
688 if new_child
!= null then
689 new_child
.parent
= self
690 assert new_child
isa TString
691 _n_string
= new_child
699 redef fun visit_all
(v
: Visitor)
701 v
.enter_visit
(_n_string
)
704 redef class AHexValue
705 private init empty_init
do end
707 init init_ahexvalue
(
712 _n_hex
= n_hex
.as(not null)
716 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
718 if _n_hex
== old_child
then
719 if new_child
!= null then
720 new_child
.parent
= self
721 assert new_child
isa THex
730 redef fun visit_all
(v
: Visitor)
732 v
.enter_visit
(_n_hex
)
735 redef class AByteDirective
736 private init empty_init
do end
738 init init_abytedirective
(
739 n_tk_byte
: nullable TTkByte,
740 n_value
: nullable AValue
744 _n_tk_byte
= n_tk_byte
.as(not null)
745 n_tk_byte
.parent
= self
746 _n_value
= n_value
.as(not null)
747 n_value
.parent
= self
750 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
752 if _n_tk_byte
== old_child
then
753 if new_child
!= null then
754 new_child
.parent
= self
755 assert new_child
isa TTkByte
756 _n_tk_byte
= new_child
762 if _n_value
== old_child
then
763 if new_child
!= null then
764 new_child
.parent
= self
765 assert new_child
isa AValue
774 redef fun visit_all
(v
: Visitor)
776 v
.enter_visit
(_n_tk_byte
)
777 v
.enter_visit
(_n_value
)
780 redef class AWordDirective
781 private init empty_init
do end
783 init init_aworddirective
(
784 n_tk_word
: nullable TTkWord,
785 n_value
: nullable AValue
789 _n_tk_word
= n_tk_word
.as(not null)
790 n_tk_word
.parent
= self
791 _n_value
= n_value
.as(not null)
792 n_value
.parent
= self
795 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
797 if _n_tk_word
== old_child
then
798 if new_child
!= null then
799 new_child
.parent
= self
800 assert new_child
isa TTkWord
801 _n_tk_word
= new_child
807 if _n_value
== old_child
then
808 if new_child
!= null then
809 new_child
.parent
= self
810 assert new_child
isa AValue
819 redef fun visit_all
(v
: Visitor)
821 v
.enter_visit
(_n_tk_word
)
822 v
.enter_visit
(_n_value
)
825 redef class ABlockDirective
826 private init empty_init
do end
828 init init_ablockdirective
(
829 n_tk_block
: nullable TTkBlock,
830 n_value
: nullable AValue
834 _n_tk_block
= n_tk_block
.as(not null)
835 n_tk_block
.parent
= self
836 _n_value
= n_value
.as(not null)
837 n_value
.parent
= self
840 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
842 if _n_tk_block
== old_child
then
843 if new_child
!= null then
844 new_child
.parent
= self
845 assert new_child
isa TTkBlock
846 _n_tk_block
= new_child
852 if _n_value
== old_child
then
853 if new_child
!= null then
854 new_child
.parent
= self
855 assert new_child
isa AValue
864 redef fun visit_all
(v
: Visitor)
866 v
.enter_visit
(_n_tk_block
)
867 v
.enter_visit
(_n_value
)
870 redef class AAsciiDirective
871 private init empty_init
do end
873 init init_aasciidirective
(
874 n_tk_ascii
: nullable TTkAscii,
875 n_value
: nullable AValue
879 _n_tk_ascii
= n_tk_ascii
.as(not null)
880 n_tk_ascii
.parent
= self
881 _n_value
= n_value
.as(not null)
882 n_value
.parent
= self
885 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
887 if _n_tk_ascii
== old_child
then
888 if new_child
!= null then
889 new_child
.parent
= self
890 assert new_child
isa TTkAscii
891 _n_tk_ascii
= new_child
897 if _n_value
== old_child
then
898 if new_child
!= null then
899 new_child
.parent
= self
900 assert new_child
isa AValue
909 redef fun visit_all
(v
: Visitor)
911 v
.enter_visit
(_n_tk_ascii
)
912 v
.enter_visit
(_n_value
)
915 redef class AAddrssDirective
916 private init empty_init
do end
918 init init_aaddrssdirective
(
919 n_tk_addrss
: nullable TTkAddrss,
920 n_value
: nullable AValue
924 _n_tk_addrss
= n_tk_addrss
.as(not null)
925 n_tk_addrss
.parent
= self
926 _n_value
= n_value
.as(not null)
927 n_value
.parent
= self
930 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
932 if _n_tk_addrss
== old_child
then
933 if new_child
!= null then
934 new_child
.parent
= self
935 assert new_child
isa TTkAddrss
936 _n_tk_addrss
= new_child
942 if _n_value
== old_child
then
943 if new_child
!= null then
944 new_child
.parent
= self
945 assert new_child
isa AValue
954 redef fun visit_all
(v
: Visitor)
956 v
.enter_visit
(_n_tk_addrss
)
957 v
.enter_visit
(_n_value
)
960 redef class AEquateDirective
961 private init empty_init
do end
963 init init_aequatedirective
(
964 n_tk_equate
: nullable TTkEquate,
965 n_value
: nullable AValue
969 _n_tk_equate
= n_tk_equate
.as(not null)
970 n_tk_equate
.parent
= self
971 _n_value
= n_value
.as(not null)
972 n_value
.parent
= self
975 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
977 if _n_tk_equate
== old_child
then
978 if new_child
!= null then
979 new_child
.parent
= self
980 assert new_child
isa TTkEquate
981 _n_tk_equate
= new_child
987 if _n_value
== old_child
then
988 if new_child
!= null then
989 new_child
.parent
= self
990 assert new_child
isa AValue
999 redef fun visit_all
(v
: Visitor)
1001 v
.enter_visit
(_n_tk_equate
)
1002 v
.enter_visit
(_n_value
)
1005 redef class ABurnDirective
1006 private init empty_init
do end
1008 init init_aburndirective
(
1009 n_tk_burn
: nullable TTkBurn,
1010 n_value
: nullable AValue
1014 _n_tk_burn
= n_tk_burn
.as(not null)
1015 n_tk_burn
.parent
= self
1016 _n_value
= n_value
.as(not null)
1017 n_value
.parent
= self
1020 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
1022 if _n_tk_burn
== old_child
then
1023 if new_child
!= null then
1024 new_child
.parent
= self
1025 assert new_child
isa TTkBurn
1026 _n_tk_burn
= new_child
1032 if _n_value
== old_child
then
1033 if new_child
!= null then
1034 new_child
.parent
= self
1035 assert new_child
isa AValue
1036 _n_value
= new_child
1044 redef fun visit_all
(v
: Visitor)
1046 v
.enter_visit
(_n_tk_burn
)
1047 v
.enter_visit
(_n_value
)
1052 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
1054 if _n_base
== old_child
then
1055 if new_child
== null then
1057 new_child
.parent
= self
1058 assert new_child
isa AListing
1061 old_child
.parent
= null
1066 redef fun visit_all
(v
: Visitor)
1068 if _n_base
!= null then
1069 v
.enter_visit
(_n_base
.as(not null))
1071 v
.enter_visit
(_n_eof
)