1 # Production AST nodes full definition.
2 # This file was generated by SableCC (http://www.sablecc.org/).
6 intrude import parser_nodes
10 # Parent of the node in the AST
11 var _parent
: nullable ANode
12 fun parent
: nullable ANode do return _parent
13 fun parent
=(p
: nullable ANode) do _parent
= p
15 # Remove a child from the AST
16 fun remove_child
(child
: ANode)
18 replace_child
(child
, null)
21 # Replace a child with an other node in the AST
22 fun replace_child
(old_child
: ANode, new_child
: nullable ANode) is abstract
24 # Replace itself with an other node in the AST
25 fun replace_with
(node
: ANode)
27 if _parent
!= null then
28 _parent
.replace_child
(self, node
)
32 # Visit all nodes in order.
33 # Thus, call "v.visit(e)" for each node e
34 fun visit_all
(v
: Visitor) is abstract
38 redef fun visit_all
(v
: Visitor) do end
39 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode) do end
43 redef fun replace_with
(n
: ANode)
51 # Abstract standard visitor
52 abstract class Visitor
53 # What the visitor do when a node is visited
54 # Concrete visitors should redefine this method.
55 protected fun visit
(e
: nullable ANode) is abstract
57 # Ask the visitor to visit a given node.
58 # Usually automatically called by visit_all* methods.
59 # This methos should not be redefined
60 fun enter_visit
(e
: nullable ANode)
62 var old
= current_node
68 # The current visited node
69 var current_node
: nullable ANode = null
73 private init empty_init
do end
76 n_lines
: Collection[Object], # Should be Collection[ALine]
77 n_label_decl
: nullable ALabelDecl,
78 n_end_block
: nullable TEndBlock
87 _n_label_decl
= n_label_decl
88 if n_label_decl
!= null then
89 n_label_decl
.parent
= self
91 _n_end_block
= n_end_block
.as(not null)
92 n_end_block
.parent
= self
95 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
97 for i
in [0.._n_lines
.length
[ do
98 if _n_lines
[i
] == old_child
then
99 if new_child
!= null then
100 assert new_child
isa ALine
101 _n_lines
[i
] = new_child
102 new_child
.parent
= self
104 _n_lines
.remove_at
(i
)
109 if _n_label_decl
== old_child
then
110 if new_child
!= null then
111 new_child
.parent
= self
112 assert new_child
isa ALabelDecl
113 _n_label_decl
= new_child
119 if _n_end_block
== old_child
then
120 if new_child
!= null then
121 new_child
.parent
= self
122 assert new_child
isa TEndBlock
123 _n_end_block
= new_child
131 redef fun visit_all
(v
: Visitor)
136 if _n_label_decl
!= null then
137 v
.enter_visit
(_n_label_decl
.as(not null))
139 v
.enter_visit
(_n_end_block
)
142 redef class AEmptyLine
143 private init empty_init
do end
145 init init_aemptyline
(
146 n_label_decl
: nullable ALabelDecl,
147 n_comment
: nullable TComment,
152 _n_label_decl
= n_label_decl
153 if n_label_decl
!= null then
154 n_label_decl
.parent
= self
156 _n_comment
= n_comment
157 if n_comment
!= null then
158 n_comment
.parent
= self
160 _n_eol
= n_eol
.as(not null)
164 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
166 if _n_label_decl
== old_child
then
167 if new_child
!= null then
168 new_child
.parent
= self
169 assert new_child
isa ALabelDecl
170 _n_label_decl
= new_child
176 if _n_comment
== old_child
then
177 if new_child
!= null then
178 new_child
.parent
= self
179 assert new_child
isa TComment
180 _n_comment
= new_child
186 if _n_eol
== old_child
then
187 if new_child
!= null then
188 new_child
.parent
= self
189 assert new_child
isa TEol
198 redef fun visit_all
(v
: Visitor)
200 if _n_label_decl
!= null then
201 v
.enter_visit
(_n_label_decl
.as(not null))
203 if _n_comment
!= null then
204 v
.enter_visit
(_n_comment
.as(not null))
206 v
.enter_visit
(_n_eol
)
209 redef class AInstructionLine
210 private init empty_init
do end
212 init init_ainstructionline
(
213 n_label_decl
: nullable ALabelDecl,
214 n_instruction
: nullable AInstruction,
215 n_comment
: nullable TComment,
220 _n_label_decl
= n_label_decl
221 if n_label_decl
!= null then
222 n_label_decl
.parent
= self
224 _n_instruction
= n_instruction
.as(not null)
225 n_instruction
.parent
= self
226 _n_comment
= n_comment
227 if n_comment
!= null then
228 n_comment
.parent
= self
230 _n_eol
= n_eol
.as(not null)
234 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
236 if _n_label_decl
== old_child
then
237 if new_child
!= null then
238 new_child
.parent
= self
239 assert new_child
isa ALabelDecl
240 _n_label_decl
= new_child
246 if _n_instruction
== old_child
then
247 if new_child
!= null then
248 new_child
.parent
= self
249 assert new_child
isa AInstruction
250 _n_instruction
= new_child
256 if _n_comment
== old_child
then
257 if new_child
!= null then
258 new_child
.parent
= self
259 assert new_child
isa TComment
260 _n_comment
= new_child
266 if _n_eol
== old_child
then
267 if new_child
!= null then
268 new_child
.parent
= self
269 assert new_child
isa TEol
278 redef fun visit_all
(v
: Visitor)
280 if _n_label_decl
!= null then
281 v
.enter_visit
(_n_label_decl
.as(not null))
283 v
.enter_visit
(_n_instruction
)
284 if _n_comment
!= null then
285 v
.enter_visit
(_n_comment
.as(not null))
287 v
.enter_visit
(_n_eol
)
290 redef class ADirectiveLine
291 private init empty_init
do end
293 init init_adirectiveline
(
294 n_label_decl
: nullable ALabelDecl,
295 n_directive
: nullable ADirective,
296 n_comment
: nullable TComment,
301 _n_label_decl
= n_label_decl
302 if n_label_decl
!= null then
303 n_label_decl
.parent
= self
305 _n_directive
= n_directive
.as(not null)
306 n_directive
.parent
= self
307 _n_comment
= n_comment
308 if n_comment
!= null then
309 n_comment
.parent
= self
311 _n_eol
= n_eol
.as(not null)
315 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
317 if _n_label_decl
== old_child
then
318 if new_child
!= null then
319 new_child
.parent
= self
320 assert new_child
isa ALabelDecl
321 _n_label_decl
= new_child
327 if _n_directive
== old_child
then
328 if new_child
!= null then
329 new_child
.parent
= self
330 assert new_child
isa ADirective
331 _n_directive
= new_child
337 if _n_comment
== old_child
then
338 if new_child
!= null then
339 new_child
.parent
= self
340 assert new_child
isa TComment
341 _n_comment
= new_child
347 if _n_eol
== old_child
then
348 if new_child
!= null then
349 new_child
.parent
= self
350 assert new_child
isa TEol
359 redef fun visit_all
(v
: Visitor)
361 if _n_label_decl
!= null then
362 v
.enter_visit
(_n_label_decl
.as(not null))
364 v
.enter_visit
(_n_directive
)
365 if _n_comment
!= null then
366 v
.enter_visit
(_n_comment
.as(not null))
368 v
.enter_visit
(_n_eol
)
371 redef class ALabelDecl
372 private init empty_init
do end
374 init init_alabeldecl
(
376 n_colon
: nullable TColon
380 _n_id
= n_id
.as(not null)
382 _n_colon
= n_colon
.as(not null)
383 n_colon
.parent
= self
386 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
388 if _n_id
== old_child
then
389 if new_child
!= null then
390 new_child
.parent
= self
391 assert new_child
isa TId
398 if _n_colon
== old_child
then
399 if new_child
!= null then
400 new_child
.parent
= self
401 assert new_child
isa TColon
410 redef fun visit_all
(v
: Visitor)
413 v
.enter_visit
(_n_colon
)
416 redef class AUnaryInstruction
417 private init empty_init
do end
419 init init_aunaryinstruction
(
424 _n_id
= n_id
.as(not null)
428 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
430 if _n_id
== old_child
then
431 if new_child
!= null then
432 new_child
.parent
= self
433 assert new_child
isa TId
442 redef fun visit_all
(v
: Visitor)
447 redef class ABinaryInstruction
448 private init empty_init
do end
450 init init_abinaryinstruction
(
452 n_operand
: nullable AOperand
456 _n_id
= n_id
.as(not null)
458 _n_operand
= n_operand
.as(not null)
459 n_operand
.parent
= self
462 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
464 if _n_id
== old_child
then
465 if new_child
!= null then
466 new_child
.parent
= self
467 assert new_child
isa TId
474 if _n_operand
== old_child
then
475 if new_child
!= null then
476 new_child
.parent
= self
477 assert new_child
isa AOperand
478 _n_operand
= new_child
486 redef fun visit_all
(v
: Visitor)
489 v
.enter_visit
(_n_operand
)
492 redef class AImmediateOperand
493 private init empty_init
do end
495 init init_aimmediateoperand
(
496 n_value
: nullable AValue
500 _n_value
= n_value
.as(not null)
501 n_value
.parent
= self
504 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
506 if _n_value
== old_child
then
507 if new_child
!= null then
508 new_child
.parent
= self
509 assert new_child
isa AValue
518 redef fun visit_all
(v
: Visitor)
520 v
.enter_visit
(_n_value
)
523 redef class AAnyOperand
524 private init empty_init
do end
526 init init_aanyoperand
(
527 n_value
: nullable AValue,
528 n_comma
: nullable TComma,
533 _n_value
= n_value
.as(not null)
534 n_value
.parent
= self
535 _n_comma
= n_comma
.as(not null)
536 n_comma
.parent
= self
537 _n_id
= n_id
.as(not null)
541 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
543 if _n_value
== old_child
then
544 if new_child
!= null then
545 new_child
.parent
= self
546 assert new_child
isa AValue
553 if _n_comma
== old_child
then
554 if new_child
!= null then
555 new_child
.parent
= self
556 assert new_child
isa TComma
563 if _n_id
== old_child
then
564 if new_child
!= null then
565 new_child
.parent
= self
566 assert new_child
isa TId
575 redef fun visit_all
(v
: Visitor)
577 v
.enter_visit
(_n_value
)
578 v
.enter_visit
(_n_comma
)
582 redef class ALabelValue
583 private init empty_init
do end
585 init init_alabelvalue
(
590 _n_id
= n_id
.as(not null)
594 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
596 if _n_id
== old_child
then
597 if new_child
!= null then
598 new_child
.parent
= self
599 assert new_child
isa TId
608 redef fun visit_all
(v
: Visitor)
613 redef class ANumberValue
614 private init empty_init
do end
616 init init_anumbervalue
(
617 n_number
: nullable TNumber
621 _n_number
= n_number
.as(not null)
622 n_number
.parent
= self
625 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
627 if _n_number
== old_child
then
628 if new_child
!= null then
629 new_child
.parent
= self
630 assert new_child
isa TNumber
631 _n_number
= new_child
639 redef fun visit_all
(v
: Visitor)
641 v
.enter_visit
(_n_number
)
644 redef class ACharValue
645 private init empty_init
do end
647 init init_acharvalue
(
648 n_char
: nullable TChar
652 _n_char
= n_char
.as(not null)
656 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
658 if _n_char
== old_child
then
659 if new_child
!= null then
660 new_child
.parent
= self
661 assert new_child
isa TChar
670 redef fun visit_all
(v
: Visitor)
672 v
.enter_visit
(_n_char
)
675 redef class AStringValue
676 private init empty_init
do end
678 init init_astringvalue
(
679 n_string
: nullable TString
683 _n_string
= n_string
.as(not null)
684 n_string
.parent
= self
687 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
689 if _n_string
== old_child
then
690 if new_child
!= null then
691 new_child
.parent
= self
692 assert new_child
isa TString
693 _n_string
= new_child
701 redef fun visit_all
(v
: Visitor)
703 v
.enter_visit
(_n_string
)
706 redef class AHexValue
707 private init empty_init
do end
709 init init_ahexvalue
(
714 _n_hex
= n_hex
.as(not null)
718 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
720 if _n_hex
== old_child
then
721 if new_child
!= null then
722 new_child
.parent
= self
723 assert new_child
isa THex
732 redef fun visit_all
(v
: Visitor)
734 v
.enter_visit
(_n_hex
)
737 redef class AByteDirective
738 private init empty_init
do end
740 init init_abytedirective
(
741 n_tk_byte
: nullable TTkByte,
742 n_value
: nullable AValue
746 _n_tk_byte
= n_tk_byte
.as(not null)
747 n_tk_byte
.parent
= self
748 _n_value
= n_value
.as(not null)
749 n_value
.parent
= self
752 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
754 if _n_tk_byte
== old_child
then
755 if new_child
!= null then
756 new_child
.parent
= self
757 assert new_child
isa TTkByte
758 _n_tk_byte
= new_child
764 if _n_value
== old_child
then
765 if new_child
!= null then
766 new_child
.parent
= self
767 assert new_child
isa AValue
776 redef fun visit_all
(v
: Visitor)
778 v
.enter_visit
(_n_tk_byte
)
779 v
.enter_visit
(_n_value
)
782 redef class AWordDirective
783 private init empty_init
do end
785 init init_aworddirective
(
786 n_tk_word
: nullable TTkWord,
787 n_value
: nullable AValue
791 _n_tk_word
= n_tk_word
.as(not null)
792 n_tk_word
.parent
= self
793 _n_value
= n_value
.as(not null)
794 n_value
.parent
= self
797 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
799 if _n_tk_word
== old_child
then
800 if new_child
!= null then
801 new_child
.parent
= self
802 assert new_child
isa TTkWord
803 _n_tk_word
= new_child
809 if _n_value
== old_child
then
810 if new_child
!= null then
811 new_child
.parent
= self
812 assert new_child
isa AValue
821 redef fun visit_all
(v
: Visitor)
823 v
.enter_visit
(_n_tk_word
)
824 v
.enter_visit
(_n_value
)
827 redef class ABlockDirective
828 private init empty_init
do end
830 init init_ablockdirective
(
831 n_tk_block
: nullable TTkBlock,
832 n_value
: nullable AValue
836 _n_tk_block
= n_tk_block
.as(not null)
837 n_tk_block
.parent
= self
838 _n_value
= n_value
.as(not null)
839 n_value
.parent
= self
842 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
844 if _n_tk_block
== old_child
then
845 if new_child
!= null then
846 new_child
.parent
= self
847 assert new_child
isa TTkBlock
848 _n_tk_block
= new_child
854 if _n_value
== old_child
then
855 if new_child
!= null then
856 new_child
.parent
= self
857 assert new_child
isa AValue
866 redef fun visit_all
(v
: Visitor)
868 v
.enter_visit
(_n_tk_block
)
869 v
.enter_visit
(_n_value
)
872 redef class AAsciiDirective
873 private init empty_init
do end
875 init init_aasciidirective
(
876 n_tk_ascii
: nullable TTkAscii,
877 n_value
: nullable AValue
881 _n_tk_ascii
= n_tk_ascii
.as(not null)
882 n_tk_ascii
.parent
= self
883 _n_value
= n_value
.as(not null)
884 n_value
.parent
= self
887 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
889 if _n_tk_ascii
== old_child
then
890 if new_child
!= null then
891 new_child
.parent
= self
892 assert new_child
isa TTkAscii
893 _n_tk_ascii
= new_child
899 if _n_value
== old_child
then
900 if new_child
!= null then
901 new_child
.parent
= self
902 assert new_child
isa AValue
911 redef fun visit_all
(v
: Visitor)
913 v
.enter_visit
(_n_tk_ascii
)
914 v
.enter_visit
(_n_value
)
917 redef class AAddrssDirective
918 private init empty_init
do end
920 init init_aaddrssdirective
(
921 n_tk_addrss
: nullable TTkAddrss,
922 n_value
: nullable AValue
926 _n_tk_addrss
= n_tk_addrss
.as(not null)
927 n_tk_addrss
.parent
= self
928 _n_value
= n_value
.as(not null)
929 n_value
.parent
= self
932 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
934 if _n_tk_addrss
== old_child
then
935 if new_child
!= null then
936 new_child
.parent
= self
937 assert new_child
isa TTkAddrss
938 _n_tk_addrss
= new_child
944 if _n_value
== old_child
then
945 if new_child
!= null then
946 new_child
.parent
= self
947 assert new_child
isa AValue
956 redef fun visit_all
(v
: Visitor)
958 v
.enter_visit
(_n_tk_addrss
)
959 v
.enter_visit
(_n_value
)
962 redef class AEquateDirective
963 private init empty_init
do end
965 init init_aequatedirective
(
966 n_tk_equate
: nullable TTkEquate,
967 n_value
: nullable AValue
971 _n_tk_equate
= n_tk_equate
.as(not null)
972 n_tk_equate
.parent
= self
973 _n_value
= n_value
.as(not null)
974 n_value
.parent
= self
977 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
979 if _n_tk_equate
== old_child
then
980 if new_child
!= null then
981 new_child
.parent
= self
982 assert new_child
isa TTkEquate
983 _n_tk_equate
= new_child
989 if _n_value
== old_child
then
990 if new_child
!= null then
991 new_child
.parent
= self
992 assert new_child
isa AValue
1001 redef fun visit_all
(v
: Visitor)
1003 v
.enter_visit
(_n_tk_equate
)
1004 v
.enter_visit
(_n_value
)
1007 redef class ABurnDirective
1008 private init empty_init
do end
1010 init init_aburndirective
(
1011 n_tk_burn
: nullable TTkBurn,
1012 n_value
: nullable AValue
1016 _n_tk_burn
= n_tk_burn
.as(not null)
1017 n_tk_burn
.parent
= self
1018 _n_value
= n_value
.as(not null)
1019 n_value
.parent
= self
1022 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
1024 if _n_tk_burn
== old_child
then
1025 if new_child
!= null then
1026 new_child
.parent
= self
1027 assert new_child
isa TTkBurn
1028 _n_tk_burn
= new_child
1034 if _n_value
== old_child
then
1035 if new_child
!= null then
1036 new_child
.parent
= self
1037 assert new_child
isa AValue
1038 _n_value
= new_child
1046 redef fun visit_all
(v
: Visitor)
1048 v
.enter_visit
(_n_tk_burn
)
1049 v
.enter_visit
(_n_value
)
1054 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode)
1056 if _n_base
== old_child
then
1057 if new_child
== null then
1059 new_child
.parent
= self
1060 assert new_child
isa AListing
1063 old_child
.parent
= null
1068 redef fun visit_all
(v
: Visitor)
1070 if _n_base
!= null then
1071 v
.enter_visit
(_n_base
.as(not null))
1073 v
.enter_visit
(_n_eof
)