6bf5eacb1fbc988f5d280a5ebcf9fad92a63ab53
[nit.git] / src / parser / parser_nodes.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # AST nodes of the Nit language
16 # Was previously based on parser_abs.nit.
17 module parser_nodes
18
19 import location
20
21 # Root of the AST class-hierarchy
22 abstract class ANode
23 # Location is set during AST building. Once built, location cannon be null.
24 # However, manual instantiated nodes may need more care.
25 var location: Location is writable, noinit
26
27 # The location of the important part of the node (identifier or whatever)
28 fun hot_location: Location do return location
29
30 # Display a message for the colored location of the node
31 fun debug(message: String)
32 do
33 sys.stderr.write "{hot_location} {self.class_name}: {message}\n{hot_location.colored_line("0;32")}\n"
34 end
35
36 # Parent of the node in the AST
37 var parent: nullable ANode = null
38
39 # The topmost ancestor of the element
40 # This just apply `parent` until the first one
41 fun root: ANode
42 do
43 var res = self
44 loop
45 var p = res.parent
46 if p == null then return res
47 res = p
48 end
49 end
50
51 # The most specific common parent between `self` and `other`
52 # Return null if the two node are unrelated (distinct root)
53 fun common_parent(other: ANode): nullable ANode
54 do
55 # First, get the same depth
56 var s: nullable ANode = self
57 var o: nullable ANode = other
58 var d = s.depth - o.depth
59 while d > 0 do
60 s = s.parent
61 d -= 1
62 end
63 while d < 0 do
64 o = o.parent
65 d += 1
66 end
67 assert o.depth == s.depth
68 # Second, go up until same in found
69 while s != o do
70 s = s.parent
71 o = o.parent
72 end
73 return s
74 end
75
76 # Number of nodes between `self` and the `root` of the AST
77 # ENSURE `self == self.root implies result == 0 `
78 # ENSURE `self != self.root implies result == self.parent.depth + 1`
79 fun depth: Int
80 do
81 var n = self
82 var res = 0
83 loop
84 var p = n.parent
85 if p == null then return res
86 n = p
87 res += 1
88 end
89 end
90
91 # Replace a child with an other node in the AST
92 private fun replace_child(old_child: ANode, new_child: nullable ANode) is abstract
93
94 # Detach a node from its parent
95 # Aborts if the node is not detachable. use `replace_with` instead
96 # REQUIRE: parent != null
97 # REQUIRE: is_detachable
98 # ENDURE: parent == null
99 fun detach
100 do
101 assert parent != null
102 parent.replace_child(self, null)
103 parent = null
104 end
105
106 # Replace itself with an other node in the AST
107 # REQUIRE: parent != null
108 # ENSURE: node.parent == old(parent)
109 # ENSURE: parent == null
110 fun replace_with(node: ANode)
111 do
112 assert parent != null
113 parent.replace_child(self, node)
114 parent = null
115 end
116
117 # Visit all nodes in order.
118 # Thus, call `v.enter_visit(e)` for each child `e`
119 fun visit_all(v: Visitor) is abstract
120 end
121
122 # A sequence of nodes
123 # It is a specific class (instead of using a Array) to track the parent/child relation when nodes are added or removed
124 class ANodes[E: ANode]
125 super Sequence[E]
126 private var parent: ANode
127 private var items = new Array[E]
128 redef fun iterator do return items.iterator
129 redef fun length do return items.length
130 redef fun is_empty do return items.is_empty
131 redef fun push(e)
132 do
133 hook_add(e)
134 items.push(e)
135 end
136 redef fun pop
137 do
138 var res = items.pop
139 hook_remove(res)
140 return res
141 end
142 redef fun unshift(e)
143 do
144 hook_add(e)
145 items.unshift(e)
146 end
147 redef fun shift
148 do
149 var res = items.shift
150 hook_remove(res)
151 return res
152 end
153 redef fun has(e)
154 do
155 return items.has(e)
156 end
157 redef fun [](index)
158 do
159 return items[index]
160 end
161 redef fun []=(index, e)
162 do
163 hook_remove(self[index])
164 hook_add(e)
165 items[index]=e
166 end
167 redef fun remove_at(index)
168 do
169 hook_remove(items[index])
170 items.remove_at(index)
171 end
172 private fun hook_add(e: E)
173 do
174 #assert e.parent == null
175 e.parent = parent
176 end
177 private fun hook_remove(e: E)
178 do
179 assert e.parent == parent
180 e.parent = null
181 end
182
183 # Used in parent constructor to fill elements
184 private fun unsafe_add_all(nodes: Collection[Object])
185 do
186 var parent = self.parent
187 for n in nodes do
188 assert n isa E
189 add n
190 n.parent = parent
191 end
192 end
193
194 private fun replace_child(old_child: ANode, new_child: nullable ANode): Bool
195 do
196 var parent = self.parent
197 for i in [0..length[ do
198 if self[i] == old_child then
199 if new_child != null then
200 assert new_child isa E
201 self[i] = new_child
202 new_child.parent = parent
203 else
204 self.remove_at(i)
205 end
206 return true
207 end
208 end
209 return false
210 end
211
212 private fun visit_all(v: Visitor)
213 do
214 for n in self do v.enter_visit(n)
215 end
216 end
217
218 # Ancestor of all tokens
219 # A token is a node that has a `text` but no children.
220 abstract class Token
221 super ANode
222
223 # The raw content on the token
224 fun text: String is abstract
225
226 # The raw content on the token
227 fun text=(text: String) is abstract
228
229 # The previous token in the Lexer.
230 # May have disappeared in the AST
231 var prev_token: nullable Token = null
232
233 # The next token in the Lexer.
234 # May have disappeared in the AST
235 var next_token: nullable Token = null
236
237 # The verbatim blank text between `prev_token` and `self`
238 fun blank_before: String
239 do
240 if prev_token == null then return ""
241 var from = prev_token.location.pend+1
242 var to = location.pstart
243 return location.file.string.substring(from,to-from)
244 end
245
246 redef fun to_s: String do
247 return "'{text}'"
248 end
249
250 redef fun visit_all(v: Visitor) do end
251 redef fun replace_child(old_child: ANode, new_child: nullable ANode) do end
252 end
253
254 redef class SourceFile
255 # The first token parser by the lexer
256 # May have disappeared in the final AST
257 var first_token: nullable Token = null
258
259 # The first token parser by the lexer
260 # May have disappeared in the final AST
261 var last_token: nullable Token = null
262 end
263
264 # Ancestor of all productions
265 # A production is a node without text but that usually has children.
266 abstract class Prod
267 super ANode
268
269 # All the annotations attached directly to the node
270 var n_annotations: nullable AAnnotations = null is writable
271
272 redef fun replace_with(n: ANode)
273 do
274 super
275 assert n isa Prod
276 if not isset n._location and isset _location then n._location = _location
277 end
278 end
279
280 # Abstract standard visitor on the AST
281 abstract class Visitor
282 # What the visitor do when a node is visited
283 # Concrete visitors should implement this method.
284 # @toimplement
285 protected fun visit(e: ANode) is abstract
286
287 # Ask the visitor to visit a given node.
288 # Usually automatically called by visit_all* methods.
289 # This method should not be redefined
290 fun enter_visit(e: nullable ANode)
291 do
292 if e == null then return
293 var old = _current_node
294 _current_node = e
295 visit(e)
296 _current_node = old
297 end
298
299 # The current visited node
300 var current_node: nullable ANode = null is writable
301 end
302
303 # Token of end of line (basically `\n`)
304 class TEol
305 super Token
306 redef fun to_s
307 do
308 return "end of line"
309 end
310 end
311
312 # Token of a line of comments
313 # Starts with the `#` and contains the final end-of-line (if any)
314 class TComment
315 super Token
316 end
317
318 # A token associated with a keyword
319 abstract class TokenKeyword
320 super Token
321 redef fun to_s
322 do
323 return "keyword '{text}'"
324 end
325 end
326
327 # The deprecated keyword `package`.
328 class TKwpackage
329 super TokenKeyword
330 end
331
332 # The keyword `module`
333 class TKwmodule
334 super TokenKeyword
335 end
336
337 # The keyword `import`
338 class TKwimport
339 super TokenKeyword
340 end
341
342 # The keyword `class`
343 class TKwclass
344 super TokenKeyword
345 end
346
347 # The keyword `abstract`
348 class TKwabstract
349 super TokenKeyword
350 end
351
352 # The keyword `interface`
353 class TKwinterface
354 super TokenKeyword
355 end
356
357 # The keywords `enum` ane `universal`
358 class TKwenum
359 super TokenKeyword
360 end
361
362 # The keyword `end`
363 class TKwend
364 super TokenKeyword
365 end
366
367 # The keyword `fun`
368 class TKwmeth
369 super TokenKeyword
370 end
371
372 # The keyword `type`
373 class TKwtype
374 super TokenKeyword
375 end
376
377 # The keyword `init`
378 class TKwinit
379 super TokenKeyword
380 end
381
382 # The keyword `redef`
383 class TKwredef
384 super TokenKeyword
385 end
386
387 # The keyword `is`
388 class TKwis
389 super TokenKeyword
390 end
391
392 # The keyword `do`
393 class TKwdo
394 super TokenKeyword
395 end
396
397 # The keyword `var`
398 class TKwvar
399 super TokenKeyword
400 end
401
402 # The keyword `extern`
403 class TKwextern
404 super TokenKeyword
405 end
406
407 # The keyword `public`
408 class TKwpublic
409 super TokenKeyword
410 end
411
412 # The keyword `protected`
413 class TKwprotected
414 super TokenKeyword
415 end
416
417 # The keyword `private`
418 class TKwprivate
419 super TokenKeyword
420 end
421
422 # The keyword `intrude`
423 class TKwintrude
424 super TokenKeyword
425 end
426
427 # The keyword `if`
428 class TKwif
429 super TokenKeyword
430 end
431
432 # The keyword `then`
433 class TKwthen
434 super TokenKeyword
435 end
436
437 # The keyword `else`
438 class TKwelse
439 super TokenKeyword
440 end
441
442 # The keyword `while`
443 class TKwwhile
444 super TokenKeyword
445 end
446
447 # The keyword `loop`
448 class TKwloop
449 super TokenKeyword
450 end
451
452 # The keyword `for`
453 class TKwfor
454 super TokenKeyword
455 end
456
457 # The keyword `in`
458 class TKwin
459 super TokenKeyword
460 end
461
462 # The keyword `and`
463 class TKwand
464 super TokenKeyword
465 end
466
467 # The keyword `or`
468 class TKwor
469 super TokenKeyword
470 end
471
472 # The keyword `implies`
473 class TKwimplies
474 super TokenKeyword
475 end
476
477 # The keyword `not`
478 class TKwnot
479 super TokenKeyword
480 end
481
482 # The keyword `return`
483 class TKwreturn
484 super TokenKeyword
485 end
486
487 # The keyword `continue`
488 class TKwcontinue
489 super TokenKeyword
490 end
491
492 # The keyword `break`
493 class TKwbreak
494 super TokenKeyword
495 end
496
497 # The keyword `abort`
498 class TKwabort
499 super TokenKeyword
500 end
501
502 # The keyword `assert`
503 class TKwassert
504 super TokenKeyword
505 end
506
507 # The keyword `new`
508 class TKwnew
509 super TokenKeyword
510 end
511
512 # The keyword `isa`
513 class TKwisa
514 super TokenKeyword
515 end
516
517 # The keyword `once`
518 class TKwonce
519 super TokenKeyword
520 end
521
522 # The keyword `super`
523 class TKwsuper
524 super TokenKeyword
525 end
526
527 # The keyword `self`
528 class TKwself
529 super TokenKeyword
530 end
531
532 # The keyword `true`
533 class TKwtrue
534 super TokenKeyword
535 end
536
537 # The keyword `false`
538 class TKwfalse
539 super TokenKeyword
540 end
541
542 # The keyword `null`
543 class TKwnull
544 super TokenKeyword
545 end
546
547 # The keyword `as`
548 class TKwas
549 super TokenKeyword
550 end
551
552 # The keyword `nullable`
553 class TKwnullable
554 super TokenKeyword
555 end
556
557 # The keyword `isset`
558 class TKwisset
559 super TokenKeyword
560 end
561
562 # The keyword `label`
563 class TKwlabel
564 super TokenKeyword
565 end
566
567 # The special keyword `__DEBUG__`
568 class TKwdebug
569 super Token
570 end
571
572 # The symbol `(`
573 class TOpar
574 super Token
575 end
576
577 # The symbol `)`
578 class TCpar
579 super Token
580 end
581
582 # The symbol `[`
583 class TObra
584 super Token
585 end
586
587 # The symbol `]`
588 class TCbra
589 super Token
590 end
591
592 # The symbol `,`
593 class TComma
594 super Token
595 end
596
597 # The symbol `:`
598 class TColumn
599 super Token
600 end
601
602 # The symbol `::`
603 class TQuad
604 super Token
605 end
606
607 # The symbol `=`
608 class TAssign
609 super Token
610 end
611
612 # A token associated with an operator (and other lookalike symbols)
613 abstract class TokenOperator
614 super Token
615 redef fun to_s
616 do
617 return "operator '{text}'"
618 end
619 end
620
621 # The operator `+=`
622 class TPluseq
623 super TokenOperator
624 end
625
626 # The operator `-=`
627 class TMinuseq
628 super TokenOperator
629 end
630
631 # The symbol `...`
632 class TDotdotdot
633 super Token
634 end
635
636 # The symbol `..`
637 class TDotdot
638 super Token
639 end
640
641 # The symbol `.`
642 class TDot
643 super Token
644 end
645
646 # The operator `+`
647 class TPlus
648 super TokenOperator
649 end
650
651 # The operator `-`
652 class TMinus
653 super TokenOperator
654 end
655
656 # The operator `*`
657 class TStar
658 super TokenOperator
659 end
660
661 # The operator `**`
662 class TStarstar
663 super TokenOperator
664 end
665
666 # The operator `/`
667 class TSlash
668 super TokenOperator
669 end
670
671 # The operator `+%
672 class TPercent
673 super TokenOperator
674 end
675
676 # The operator `==`
677 class TEq
678 super TokenOperator
679 end
680
681 # The operator `!=`
682 class TNe
683 super TokenOperator
684 end
685
686 # The operator `<`
687 class TLt
688 super TokenOperator
689 end
690
691 # The operator `<=`
692 class TLe
693 super TokenOperator
694 end
695
696 # The operator `<<`
697 class TLl
698 super TokenOperator
699 end
700
701 # The operator `>`
702 class TGt
703 super TokenOperator
704 end
705
706 # The operator `>=`
707 class TGe
708 super TokenOperator
709 end
710
711 # The operator `>>`
712 class TGg
713 super TokenOperator
714 end
715
716 # The operator `<=>`
717 class TStarship
718 super TokenOperator
719 end
720
721 # The operator `!`
722 class TBang
723 super TokenOperator
724 end
725
726 # The symbol `@`
727 class TAt
728 super Token
729 end
730
731 # A class (or formal type) identifier. They start with an uppercase.
732 class TClassid
733 super Token
734 redef fun to_s
735 do
736 do return "type identifier '{text}'"
737 end
738 end
739
740 # A standard identifier (variable, method...). They start with a lowercase.
741 class TId
742 super Token
743 redef fun to_s
744 do
745 do return "identifier '{text}'"
746 end
747 end
748
749 # An attribute identifier. They start with an underscore.
750 class TAttrid
751 super Token
752 redef fun to_s
753 do
754 do return "attribute '{text}'"
755 end
756 end
757
758 # A token of a literal value (string, integer, etc).
759 abstract class TokenLiteral
760 super Token
761 redef fun to_s
762 do
763 do return "literal value '{text}'"
764 end
765 end
766
767 # A literal decimal integer
768 class TNumber
769 super TokenLiteral
770 end
771
772 # A literal hexadecimal integer
773 class THexNumber
774 super TokenLiteral
775 end
776
777 # A literal floating point number
778 class TFloat
779 super TokenLiteral
780 end
781
782 # A literal character
783 class TChar
784 super TokenLiteral
785 end
786
787 # A literal string
788 class TString
789 super TokenLiteral
790 end
791
792 # The starting part of a super string (between `"` and `{`)
793 class TStartString
794 super TokenLiteral
795 end
796
797 # The middle part of a super string (between `}` and `{`)
798 class TMidString
799 super TokenLiteral
800 end
801
802 # The final part of a super string (between `}` and `"`)
803 class TEndString
804 super TokenLiteral
805 end
806
807 # A malformed string
808 class TBadString
809 super Token
810 redef fun to_s
811 do
812 do return "malformed string {text}"
813 end
814 end
815
816 # A malformed char
817 class TBadChar
818 super Token
819 redef fun to_s
820 do
821 do return "malformed character {text}"
822 end
823 end
824
825 # A extern code block
826 class TExternCodeSegment
827 super Token
828 end
829
830 # A end of file
831 class EOF
832 super Token
833 redef fun to_s
834 do
835 return "end of file"
836 end
837 end
838
839 # A mark of an error
840 class AError
841 super EOF
842 end
843 # A lexical error (unexpected character)
844 class ALexerError
845 super AError
846 end
847 # A syntactic error (unexpected token)
848 class AParserError
849 super AError
850 end
851
852 # The main node of a Nit source-file
853 class AModule
854 super Prod
855
856 var n_moduledecl: nullable AModuledecl = null is writable
857 var n_imports = new ANodes[AImport](self)
858 var n_extern_code_blocks = new ANodes[AExternCodeBlock](self)
859 var n_classdefs = new ANodes[AClassdef](self)
860 end
861
862 # Abstract class for definition of entities
863 abstract class ADefinition
864 super Prod
865 var n_doc: nullable ADoc = null is writable
866 var n_kwredef: nullable TKwredef = null is writable
867 var n_visibility: nullable AVisibility = null is writable
868 end
869
870 # The declaration of the module with the documentation, name, and annotations
871 class AModuledecl
872 super ADefinition
873 var n_kwmodule: TKwmodule is writable, noinit
874 var n_name: AModuleName is writable, noinit
875 end
876
877 # A import clause of a module
878 abstract class AImport
879 super Prod
880 var n_visibility: AVisibility is writable, noinit
881 var n_kwimport: TKwimport is writable, noinit
882 end
883
884 # A standard import clause. eg `import x`
885 class AStdImport
886 super AImport
887 var n_name: AModuleName is writable, noinit
888 end
889
890 # The special import clause of the kernel module. eg `import end`
891 class ANoImport
892 super AImport
893 var n_kwend: TKwend is writable, noinit
894 end
895
896 # A visibility modifier
897 #
898 # The public visibility is an empty production (no keyword).
899 #
900 # Note: even if some visibilities are only valid on some placse (for instance, no `protected` class or no `intrude` method)
901 # the parser has no such a restriction, therefore the semantic phases has to check that the visibilities make sense.
902 abstract class AVisibility
903 super Prod
904 end
905
906 # An implicit or explicit public visibility modifier
907 class APublicVisibility
908 super AVisibility
909 var n_kwpublic: nullable TKwpublic is writable
910 end
911 # An explicit private visibility modifier
912 class APrivateVisibility
913 super AVisibility
914 var n_kwprivate: TKwprivate is writable, noinit
915 end
916 # An explicit protected visibility modifier
917 class AProtectedVisibility
918 super AVisibility
919 var n_kwprotected: TKwprotected is writable, noinit
920 end
921 # An explicit intrude visibility modifier
922 class AIntrudeVisibility
923 super AVisibility
924 var n_kwintrude: TKwintrude is writable, noinit
925 end
926
927 # A class definition
928 # While most definition are `AStdClassdef`
929 # There is tow special case of class definition
930 abstract class AClassdef
931 super Prod
932 var n_propdefs = new ANodes[APropdef](self)
933 end
934
935 # A standard class definition with a name, superclasses and properties
936 class AStdClassdef
937 super AClassdef
938 super ADefinition
939 var n_classkind: AClasskind is writable, noinit
940 var n_id: nullable TClassid = null is writable
941 var n_formaldefs = new ANodes[AFormaldef](self)
942 var n_extern_code_block: nullable AExternCodeBlock = null is writable
943 var n_superclasses = new ANodes[ASuperclass](self)
944 var n_kwend: TKwend is writable, noinit
945 redef fun hot_location do return n_id.location
946 end
947
948 # The implicit class definition of the implicit main method
949 class ATopClassdef
950 super AClassdef
951 end
952
953 # The implicit class definition of the top-level methods
954 class AMainClassdef
955 super AClassdef
956 end
957
958 # The modifier for the kind of class (abstract, interface, etc.)
959 abstract class AClasskind
960 super Prod
961 end
962
963 # A default, or concrete class modifier (just `class`)
964 class AConcreteClasskind
965 super AClasskind
966 var n_kwclass: TKwclass is writable, noinit
967 end
968
969 # An abstract class modifier (`abstract class`)
970 class AAbstractClasskind
971 super AClasskind
972 var n_kwabstract: TKwabstract is writable, noinit
973 var n_kwclass: TKwclass is writable, noinit
974 end
975
976 # An interface class modifier (`interface`)
977 class AInterfaceClasskind
978 super AClasskind
979 var n_kwinterface: TKwinterface is writable, noinit
980 end
981
982 # An enum/universal class modifier (`enum class`)
983 class AEnumClasskind
984 super AClasskind
985 var n_kwenum: TKwenum is writable, noinit
986 end
987
988 # An extern class modifier (`extern class`)
989 class AExternClasskind
990 super AClasskind
991 var n_kwextern: TKwextern is writable, noinit
992 var n_kwclass: nullable TKwclass = null is writable
993 end
994
995 # The definition of a formal generic parameter type. eg `X: Y`
996 class AFormaldef
997 super Prod
998 var n_id: TClassid is writable, noinit
999 # The bound of the parameter type
1000 var n_type: nullable AType = null is writable
1001 end
1002
1003 # A super-class. eg `super X`
1004 class ASuperclass
1005 super Prod
1006 var n_kwsuper: TKwsuper is writable, noinit
1007 var n_type: AType is writable, noinit
1008 end
1009
1010 # The definition of a property
1011 abstract class APropdef
1012 super ADefinition
1013 end
1014
1015 # A definition of an attribute
1016 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
1017 class AAttrPropdef
1018 super APropdef
1019 var n_kwvar: TKwvar is writable, noinit
1020
1021 # The identifier for a new-style attribute (null if old-style)
1022 var n_id2: TId is writable, noinit
1023
1024 var n_type: nullable AType = null is writable
1025
1026 # The initial value, if any
1027 var n_expr: nullable AExpr = null is writable
1028
1029 var n_block: nullable AExpr = null is writable
1030
1031 redef fun hot_location
1032 do
1033 return n_id2.location
1034 end
1035 end
1036
1037 # A definition of all kind of method (including constructors)
1038 class AMethPropdef
1039 super APropdef
1040 var n_kwmeth: nullable TKwmeth = null is writable
1041 var n_kwinit: nullable TKwinit = null is writable
1042 var n_kwnew: nullable TKwnew = null is writable
1043 var n_methid: nullable AMethid = null is writable
1044 var n_signature: nullable ASignature = null is writable
1045 var n_block: nullable AExpr = null is writable
1046 var n_extern_calls: nullable AExternCalls = null is writable
1047 var n_extern_code_block: nullable AExternCodeBlock = null is writable
1048 redef fun hot_location
1049 do
1050 if n_methid != null then
1051 return n_methid.location
1052 else if n_kwinit != null then
1053 return n_kwinit.location
1054 else if n_kwnew != null then
1055 return n_kwnew.location
1056 else
1057 return location
1058 end
1059 end
1060 end
1061
1062 # The implicit main method
1063 class AMainMethPropdef
1064 super AMethPropdef
1065 end
1066
1067 # Declaration of callbacks for extern methods
1068 class AExternCalls
1069 super Prod
1070 var n_kwimport: TKwimport is writable, noinit
1071 var n_extern_calls: ANodes[AExternCall] = new ANodes[AExternCall](self)
1072 end
1073
1074 # A single callback declaration
1075 abstract class AExternCall
1076 super Prod
1077 end
1078
1079 # A single callback declaration on a method
1080 abstract class APropExternCall
1081 super AExternCall
1082 end
1083
1084 # A single callback declaration on a method on the current receiver
1085 class ALocalPropExternCall
1086 super APropExternCall
1087 var n_methid: AMethid is writable, noinit
1088 end
1089
1090 # A single callback declaration on a method on an explicit receiver type.
1091 class AFullPropExternCall
1092 super APropExternCall
1093 var n_type: AType is writable, noinit
1094 var n_dot: nullable TDot = null is writable
1095 var n_methid: AMethid is writable, noinit
1096 end
1097
1098 # A single callback declaration on a method on a constructor
1099 class AInitPropExternCall
1100 super APropExternCall
1101 var n_type: AType is writable, noinit
1102 end
1103
1104 # A single callback declaration on a `super` call
1105 class ASuperExternCall
1106 super AExternCall
1107 var n_kwsuper: TKwsuper is writable, noinit
1108 end
1109
1110 # A single callback declaration on a cast
1111 abstract class ACastExternCall
1112 super AExternCall
1113 end
1114
1115 # A single callback declaration on a cast to a given type
1116 class ACastAsExternCall
1117 super ACastExternCall
1118 var n_from_type: AType is writable, noinit
1119 var n_dot: nullable TDot = null is writable
1120 var n_kwas: TKwas is writable, noinit
1121 var n_to_type: AType is writable, noinit
1122 end
1123
1124 # A single callback declaration on a cast to a nullable type
1125 class AAsNullableExternCall
1126 super ACastExternCall
1127 var n_type: AType is writable, noinit
1128 var n_kwas: TKwas is writable, noinit
1129 var n_kwnullable: TKwnullable is writable, noinit
1130 end
1131
1132 # A single callback declaration on a cast to a non-nullable type
1133 class AAsNotNullableExternCall
1134 super ACastExternCall
1135 var n_type: AType is writable, noinit
1136 var n_kwas: TKwas is writable, noinit
1137 var n_kwnot: TKwnot is writable, noinit
1138 var n_kwnullable: TKwnullable is writable, noinit
1139 end
1140
1141 # A definition of a virtual type
1142 class ATypePropdef
1143 super APropdef
1144 var n_kwtype: TKwtype is writable, noinit
1145 var n_id: TClassid is writable, noinit
1146 var n_type: AType is writable, noinit
1147 end
1148
1149 # The identifier of a method in a method declaration.
1150 # There is a specific class because of operator and setters.
1151 abstract class AMethid
1152 super Prod
1153 end
1154
1155 # A method name with a simple identifier
1156 class AIdMethid
1157 super AMethid
1158 var n_id: TId is writable, noinit
1159 end
1160
1161 # A method name `+`
1162 class APlusMethid
1163 super AMethid
1164 var n_plus: TPlus is writable, noinit
1165 end
1166
1167 # A method name `-`
1168 class AMinusMethid
1169 super AMethid
1170 var n_minus: TMinus is writable, noinit
1171 end
1172
1173 # A method name `*`
1174 class AStarMethid
1175 super AMethid
1176 var n_star: TStar is writable, noinit
1177 end
1178
1179 # A method name `**`
1180 class AStarstarMethid
1181 super AMethid
1182 var n_starstar: TStarstar is writable, noinit
1183 end
1184
1185 # A method name `/`
1186 class ASlashMethid
1187 super AMethid
1188 var n_slash: TSlash is writable, noinit
1189 end
1190
1191 # A method name `%`
1192 class APercentMethid
1193 super AMethid
1194 var n_percent: TPercent is writable, noinit
1195 end
1196
1197 # A method name `==`
1198 class AEqMethid
1199 super AMethid
1200 var n_eq: TEq is writable, noinit
1201 end
1202
1203 # A method name `!=`
1204 class ANeMethid
1205 super AMethid
1206 var n_ne: TNe is writable, noinit
1207 end
1208
1209 # A method name `<=`
1210 class ALeMethid
1211 super AMethid
1212 var n_le: TLe is writable, noinit
1213 end
1214
1215 # A method name `>=`
1216 class AGeMethid
1217 super AMethid
1218 var n_ge: TGe is writable, noinit
1219 end
1220
1221 # A method name `<`
1222 class ALtMethid
1223 super AMethid
1224 var n_lt: TLt is writable, noinit
1225 end
1226
1227 # A method name `>`
1228 class AGtMethid
1229 super AMethid
1230 var n_gt: TGt is writable, noinit
1231 end
1232
1233 # A method name `<<`
1234 class ALlMethid
1235 super AMethid
1236 var n_ll: TLl is writable, noinit
1237 end
1238
1239 # A method name `>>`
1240 class AGgMethid
1241 super AMethid
1242 var n_gg: TGg is writable, noinit
1243 end
1244
1245 # A method name `[]`
1246 class ABraMethid
1247 super AMethid
1248 var n_obra: TObra is writable, noinit
1249 var n_cbra: TCbra is writable, noinit
1250 end
1251
1252 # A method name `<=>`
1253 class AStarshipMethid
1254 super AMethid
1255 var n_starship: TStarship is writable, noinit
1256 end
1257
1258 # A setter method name with a simple identifier (with a `=`)
1259 class AAssignMethid
1260 super AMethid
1261 var n_id: TId is writable, noinit
1262 var n_assign: TAssign is writable, noinit
1263 end
1264
1265 # A method name `[]=`
1266 class ABraassignMethid
1267 super AMethid
1268 var n_obra: TObra is writable, noinit
1269 var n_cbra: TCbra is writable, noinit
1270 var n_assign: TAssign is writable, noinit
1271 end
1272
1273 # A signature in a method definition. eg `(x,y:X,z:Z):T`
1274 class ASignature
1275 super Prod
1276 var n_opar: nullable TOpar = null is writable
1277 var n_params = new ANodes[AParam](self)
1278 var n_cpar: nullable TCpar = null is writable
1279 var n_type: nullable AType = null is writable
1280 end
1281
1282 # A parameter definition in a signature. eg `x:X`
1283 class AParam
1284 super Prod
1285 var n_id: TId is writable, noinit
1286 var n_type: nullable AType = null is writable
1287 var n_dotdotdot: nullable TDotdotdot = null is writable
1288 end
1289
1290 # A static type. eg `nullable X[Y]`
1291 class AType
1292 super Prod
1293 var n_kwnullable: nullable TKwnullable = null is writable
1294
1295 # The name of the class or of the formal type
1296 var n_id: TClassid is writable, noinit
1297
1298 # Type arguments for a generic type
1299 var n_types = new ANodes[AType](self)
1300 end
1301
1302 # A label at the end of a block or in a break/continue statement. eg `label x`
1303 class ALabel
1304 super Prod
1305 var n_kwlabel: TKwlabel is writable, noinit
1306 var n_id: nullable TId is writable
1307 end
1308
1309 # Expression and statements
1310 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1311 abstract class AExpr
1312 super Prod
1313 end
1314
1315 # A sequence of `AExpr` (usually statements)
1316 # The last `AExpr` gives the value of the whole block
1317 class ABlockExpr
1318 super AExpr
1319 var n_expr = new ANodes[AExpr](self)
1320 var n_kwend: nullable TKwend = null is writable
1321 end
1322
1323 # A declaration of a local variable. eg `var x: X = y`
1324 class AVardeclExpr
1325 super AExpr
1326 var n_kwvar: TKwvar is writable, noinit
1327 var n_id: TId is writable, noinit
1328 var n_type: nullable AType = null is writable
1329 var n_assign: nullable TAssign = null is writable
1330
1331 # The initial value, if any
1332 var n_expr: nullable AExpr = null is writable
1333 end
1334
1335 # A `return` statement. eg `return x`
1336 class AReturnExpr
1337 super AExpr
1338 var n_kwreturn: nullable TKwreturn = null is writable
1339 var n_expr: nullable AExpr = null is writable
1340 end
1341
1342 # Something that has a label.
1343 abstract class ALabelable
1344 super Prod
1345 var n_label: nullable ALabel = null is writable
1346 end
1347
1348 # A `break` or a `continue`
1349 abstract class AEscapeExpr
1350 super AExpr
1351 super ALabelable
1352 var n_expr: nullable AExpr = null is writable
1353 end
1354
1355 # A `break` statement.
1356 class ABreakExpr
1357 super AEscapeExpr
1358 var n_kwbreak: TKwbreak is writable, noinit
1359 end
1360
1361 # An `abort` statement
1362 class AAbortExpr
1363 super AExpr
1364 var n_kwabort: TKwabort is writable, noinit
1365 end
1366
1367 # A `continue` statement
1368 class AContinueExpr
1369 super AEscapeExpr
1370 var n_kwcontinue: nullable TKwcontinue = null is writable
1371 end
1372
1373 # A `do` statement
1374 class ADoExpr
1375 super AExpr
1376 super ALabelable
1377 var n_kwdo: TKwdo is writable, noinit
1378 var n_block: nullable AExpr = null is writable
1379 end
1380
1381 # A `if` statement
1382 class AIfExpr
1383 super AExpr
1384 var n_kwif: TKwif is writable, noinit
1385 var n_expr: AExpr is writable, noinit
1386 var n_then: nullable AExpr = null is writable
1387 var n_else: nullable AExpr = null is writable
1388 end
1389
1390 # A `if` expression
1391 class AIfexprExpr
1392 super AExpr
1393 var n_kwif: TKwif is writable, noinit
1394 var n_expr: AExpr is writable, noinit
1395 var n_kwthen: TKwthen is writable, noinit
1396 var n_then: AExpr is writable, noinit
1397 var n_kwelse: TKwelse is writable, noinit
1398 var n_else: AExpr is writable, noinit
1399 end
1400
1401 # A `while` statement
1402 class AWhileExpr
1403 super AExpr
1404 super ALabelable
1405 var n_kwwhile: TKwwhile is writable, noinit
1406 var n_expr: AExpr is writable, noinit
1407 var n_kwdo: TKwdo is writable, noinit
1408 var n_block: nullable AExpr = null is writable
1409 end
1410
1411 # A `loop` statement
1412 class ALoopExpr
1413 super AExpr
1414 super ALabelable
1415 var n_kwloop: TKwloop is writable, noinit
1416 var n_block: nullable AExpr = null is writable
1417 end
1418
1419 # A `for` statement
1420 class AForExpr
1421 super AExpr
1422 super ALabelable
1423 var n_kwfor: TKwfor is writable, noinit
1424 var n_ids = new ANodes[TId](self)
1425 var n_expr: AExpr is writable, noinit
1426 var n_kwdo: TKwdo is writable, noinit
1427 var n_block: nullable AExpr = null is writable
1428 end
1429
1430 # An `assert` statement
1431 class AAssertExpr
1432 super AExpr
1433 var n_kwassert: TKwassert is writable, noinit
1434 var n_id: nullable TId = null is writable
1435 var n_expr: AExpr is writable, noinit
1436 var n_else: nullable AExpr = null is writable
1437 end
1438
1439 # Whatever is a simple assignment. eg `= something`
1440 abstract class AAssignFormExpr
1441 super AExpr
1442 var n_assign: TAssign is writable, noinit
1443 var n_value: AExpr is writable, noinit
1444 end
1445
1446 # Whatever is a combined assignment. eg `+= something`
1447 abstract class AReassignFormExpr
1448 super AExpr
1449 var n_assign_op: AAssignOp is writable, noinit
1450 var n_value: AExpr is writable, noinit
1451 end
1452
1453 # A `once` expression. eg `once x`
1454 class AOnceExpr
1455 super AExpr
1456 var n_kwonce: TKwonce is writable, noinit
1457 var n_expr: AExpr is writable, noinit
1458 end
1459
1460 # A polymorphic invocation of a method
1461 # The form of the invocation (name, arguments, etc.) are specific
1462 abstract class ASendExpr
1463 super AExpr
1464 # The receiver of the method invocation
1465 var n_expr: AExpr is writable, noinit
1466 end
1467
1468 # A binary operation on a method
1469 abstract class ABinopExpr
1470 super ASendExpr
1471 # The second operand of the operation
1472 # Note: the receiver (`n_expr`) is the first operand
1473 var n_expr2: AExpr is writable, noinit
1474 end
1475
1476 # Something that is boolean expression
1477 abstract class ABoolExpr
1478 super AExpr
1479 end
1480
1481 # Something that is binary boolean expression
1482 abstract class ABinBoolExpr
1483 super ABoolExpr
1484 var n_expr: AExpr is writable, noinit
1485 var n_expr2: AExpr is writable, noinit
1486 end
1487
1488 # A `or` expression
1489 class AOrExpr
1490 super ABinBoolExpr
1491 end
1492
1493 # A `and` expression
1494 class AAndExpr
1495 super ABinBoolExpr
1496 end
1497
1498 # A `or else` expression
1499 class AOrElseExpr
1500 super ABinBoolExpr
1501 end
1502
1503 # A `implies` expression
1504 class AImpliesExpr
1505 super ABinBoolExpr
1506 end
1507
1508 # A `not` expression
1509 class ANotExpr
1510 super ABoolExpr
1511 var n_kwnot: TKwnot is writable, noinit
1512 var n_expr: AExpr is writable, noinit
1513 end
1514
1515 # A `==` expression
1516 class AEqExpr
1517 super ABinopExpr
1518 end
1519
1520 # A `!=` expression
1521 class ANeExpr
1522 super ABinopExpr
1523 end
1524
1525 # A `<` expression
1526 class ALtExpr
1527 super ABinopExpr
1528 end
1529
1530 # A `<=` expression
1531 class ALeExpr
1532 super ABinopExpr
1533 end
1534
1535 # A `<<` expression
1536 class ALlExpr
1537 super ABinopExpr
1538 end
1539
1540 # A `>` expression
1541 class AGtExpr
1542 super ABinopExpr
1543 end
1544
1545 # A `>=` expression
1546 class AGeExpr
1547 super ABinopExpr
1548 end
1549
1550 # A `>>` expression
1551 class AGgExpr
1552 super ABinopExpr
1553 end
1554
1555 # A type-ckeck expression. eg `x isa T`
1556 class AIsaExpr
1557 super ABoolExpr
1558 var n_expr: AExpr is writable, noinit
1559 var n_type: AType is writable, noinit
1560 end
1561
1562 # A `+` expression
1563 class APlusExpr
1564 super ABinopExpr
1565 end
1566
1567 # A `-` expression
1568 class AMinusExpr
1569 super ABinopExpr
1570 end
1571
1572 # A `<=>` expression
1573 class AStarshipExpr
1574 super ABinopExpr
1575 end
1576
1577 # A `*` expression
1578 class AStarExpr
1579 super ABinopExpr
1580 end
1581
1582 # A `**` expression
1583 class AStarstarExpr
1584 super ABinopExpr
1585 end
1586
1587 # A `/` expression
1588 class ASlashExpr
1589 super ABinopExpr
1590 end
1591
1592 # A `%` expression
1593 class APercentExpr
1594 super ABinopExpr
1595 end
1596
1597 # A unary minus expression. eg `-x`
1598 class AUminusExpr
1599 super ASendExpr
1600 var n_minus: TMinus is writable, noinit
1601 end
1602
1603 # An explicit instantiation. eg `new T`
1604 class ANewExpr
1605 super AExpr
1606 var n_kwnew: TKwnew is writable, noinit
1607 var n_type: AType is writable, noinit
1608
1609 # The name of the named-constructor, if any
1610 var n_id: nullable TId = null is writable
1611 var n_args: AExprs is writable, noinit
1612 end
1613
1614 # Whatever is a old-style attribute access
1615 abstract class AAttrFormExpr
1616 super AExpr
1617
1618 # The receiver of the attribute
1619 var n_expr: AExpr is writable, noinit
1620
1621 # The name of the attribute
1622 var n_id: TAttrid is writable, noinit
1623
1624 end
1625
1626 # The read of an attribute. eg `x._a`
1627 class AAttrExpr
1628 super AAttrFormExpr
1629 end
1630
1631 # The assignment of an attribute. eg `x._a=y`
1632 class AAttrAssignExpr
1633 super AAttrFormExpr
1634 super AAssignFormExpr
1635 end
1636
1637 # Whatever looks-like a call with a standard method and any number of arguments.
1638 abstract class ACallFormExpr
1639 super ASendExpr
1640
1641 # The name of the method
1642 var n_id: TId is writable, noinit
1643
1644 # The arguments of the call
1645 var n_args: AExprs is writable, noinit
1646 end
1647
1648 # A complex setter call (standard or brackets)
1649 abstract class ASendReassignFormExpr
1650 super ASendExpr
1651 super AReassignFormExpr
1652 end
1653
1654 # A complex attribute assignment. eg `x._a+=y`
1655 class AAttrReassignExpr
1656 super AAttrFormExpr
1657 super AReassignFormExpr
1658 end
1659
1660 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
1661 # Note: because the parser cannot distinguish a variable read with a method call with an implicit receiver and no arguments, it always returns a `ACallExpr`.
1662 # Semantic analysis have to transform them to instance of `AVarExpr`.
1663 class ACallExpr
1664 super ACallFormExpr
1665 end
1666
1667 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
1668 # Note: because the parser cannot distinguish a variable write with a setter call with an implicit receiver and no arguments, it always returns a `ACallAssignExpr`.
1669 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
1670 class ACallAssignExpr
1671 super ACallFormExpr
1672 super AAssignFormExpr
1673 end
1674
1675 # A complex setter call with a standard method-name and any number of arguments. eg `x.m(y)+=z`. OR just a simple complex assignment.
1676 # Note: because the parser cannot distinguish a variable write with a complex setter call with an implicit receiver and no arguments, it always returns a `ACallReassignExpr`.
1677 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
1678 class ACallReassignExpr
1679 super ACallFormExpr
1680 super ASendReassignFormExpr
1681 end
1682
1683 # A call to `super`. OR a call of a super-constructor
1684 class ASuperExpr
1685 super AExpr
1686 var n_qualified: nullable AQualified = null is writable
1687 var n_kwsuper: TKwsuper is writable, noinit
1688 var n_args: AExprs is writable, noinit
1689 end
1690
1691 # A call to the `init` constructor.
1692 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a `ACallFormExpr`.
1693 class AInitExpr
1694 super ASendExpr
1695 var n_kwinit: TKwinit is writable, noinit
1696 var n_args: AExprs is writable, noinit
1697 end
1698
1699 # Whatever looks-like a call of the brackets `[]` operator.
1700 abstract class ABraFormExpr
1701 super ASendExpr
1702 var n_args: AExprs is writable, noinit
1703 end
1704
1705 # A call of the brackets operator. eg `x[y,z]`
1706 class ABraExpr
1707 super ABraFormExpr
1708 end
1709
1710 # A setter call of the bracket operator. eg `x[y,z]=t`
1711 class ABraAssignExpr
1712 super ABraFormExpr
1713 super AAssignFormExpr
1714 end
1715
1716 # Whatever is an access to a local variable
1717 abstract class AVarFormExpr
1718 super AExpr
1719 var n_id: TId is writable, noinit
1720 end
1721
1722 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
1723 class ABraReassignExpr
1724 super ABraFormExpr
1725 super ASendReassignFormExpr
1726 end
1727
1728 # A local variable read access.
1729 # The parser cannot instantiate them, see `ACallExpr`.
1730 class AVarExpr
1731 super AVarFormExpr
1732 end
1733
1734 # A local variable simple assignment access
1735 # The parser cannot instantiate them, see `ACallAssignExpr`.
1736 class AVarAssignExpr
1737 super AVarFormExpr
1738 super AAssignFormExpr
1739 end
1740
1741 # A local variable complex assignment access
1742 # The parser cannot instantiate them, see `ACallReassignExpr`.
1743 class AVarReassignExpr
1744 super AVarFormExpr
1745 super AReassignFormExpr
1746 end
1747
1748 # A literal range, open or closed
1749 abstract class ARangeExpr
1750 super AExpr
1751 var n_expr: AExpr is writable, noinit
1752 var n_expr2: AExpr is writable, noinit
1753 end
1754
1755 # A closed literal range. eg `[x..y]`
1756 class ACrangeExpr
1757 super ARangeExpr
1758 var n_obra: TObra is writable, noinit
1759 var n_cbra: TCbra is writable, noinit
1760 end
1761
1762 # An open literal range. eg `[x..y[`
1763 class AOrangeExpr
1764 super ARangeExpr
1765 var n_obra: TObra is writable, noinit
1766 var n_cbra: TObra is writable, noinit
1767 end
1768
1769 # A literal array. eg. `[x,y,z]`
1770 class AArrayExpr
1771 super AExpr
1772 var n_obra: TObra is writable, noinit
1773 var n_exprs = new ANodes[AExpr](self)
1774 var n_type: nullable AType = null is writable
1775 var n_cbra: TCbra is writable, noinit
1776 end
1777
1778 # A read of `self`
1779 class ASelfExpr
1780 super AExpr
1781 var n_kwself: nullable TKwself is writable
1782 end
1783
1784 # When there is no explicit receiver, `self` is implicit
1785 class AImplicitSelfExpr
1786 super ASelfExpr
1787 end
1788
1789 # A `true` boolean literal constant
1790 class ATrueExpr
1791 super ABoolExpr
1792 var n_kwtrue: TKwtrue is writable, noinit
1793 end
1794 # A `false` boolean literal constant
1795 class AFalseExpr
1796 super ABoolExpr
1797 var n_kwfalse: TKwfalse is writable, noinit
1798 end
1799 # A `null` literal constant
1800 class ANullExpr
1801 super AExpr
1802 var n_kwnull: TKwnull is writable, noinit
1803 end
1804 # An integer literal
1805 class AIntExpr
1806 super AExpr
1807 end
1808 # An integer literal in decimal format
1809 class ADecIntExpr
1810 super AIntExpr
1811 var n_number: TNumber is writable, noinit
1812 end
1813 # An integer literal in hexadecimal format
1814 class AHexIntExpr
1815 super AIntExpr
1816 var n_hex_number: THexNumber is writable, noinit
1817 end
1818 # A float literal
1819 class AFloatExpr
1820 super AExpr
1821 var n_float: TFloat is writable, noinit
1822 end
1823 # A character literal
1824 class ACharExpr
1825 super AExpr
1826 var n_char: TChar is writable, noinit
1827 end
1828 # A string literal
1829 abstract class AStringFormExpr
1830 super AExpr
1831 var n_string: Token is writable, noinit
1832 end
1833
1834 # A simple string. eg. `"abc"`
1835 class AStringExpr
1836 super AStringFormExpr
1837 end
1838
1839 # The start of a superstring. eg `"abc{`
1840 class AStartStringExpr
1841 super AStringFormExpr
1842 end
1843
1844 # The middle of a superstring. eg `}abc{`
1845 class AMidStringExpr
1846 super AStringFormExpr
1847 end
1848
1849 # The end of a superstrng. eg `}abc"`
1850 class AEndStringExpr
1851 super AStringFormExpr
1852 end
1853
1854 # A superstring literal. eg `"a{x}b{y}c"`
1855 # Each part is modeled a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
1856 class ASuperstringExpr
1857 super AExpr
1858 var n_exprs = new ANodes[AExpr](self)
1859 end
1860
1861 # A simple parenthesis. eg `(x)`
1862 class AParExpr
1863 super AExpr
1864 var n_opar: TOpar is writable, noinit
1865 var n_expr: AExpr is writable, noinit
1866 var n_cpar: TCpar is writable, noinit
1867 end
1868
1869 # A cast, against a type or `not null`
1870 class AAsCastForm
1871 super AExpr
1872 var n_expr: AExpr is writable, noinit
1873 var n_kwas: TKwas is writable, noinit
1874 var n_opar: nullable TOpar = null is writable
1875 var n_cpar: nullable TCpar = null is writable
1876 end
1877
1878 # A type cast. eg `x.as(T)`
1879 class AAsCastExpr
1880 super AAsCastForm
1881 var n_type: AType is writable, noinit
1882 end
1883
1884 # A as-not-null cast. eg `x.as(not null)`
1885 class AAsNotnullExpr
1886 super AAsCastForm
1887 var n_kwnot: TKwnot is writable, noinit
1888 var n_kwnull: TKwnull is writable, noinit
1889 end
1890
1891 # A is-set check of old-style attributes. eg `isset x._a`
1892 class AIssetAttrExpr
1893 super AAttrFormExpr
1894 var n_kwisset: TKwisset is writable, noinit
1895 end
1896
1897 # An ellipsis notation used to pass an expression as it, in a vararg parameter
1898 class AVarargExpr
1899 super AExpr
1900 var n_expr: AExpr is writable, noinit
1901 var n_dotdotdot: TDotdotdot is writable, noinit
1902 end
1903
1904 # A list of expression separated with commas (arguments for instance)
1905 class AManyExpr
1906 super AExpr
1907 var n_exprs = new ANodes[AExpr](self)
1908 end
1909
1910 # A special expression that encapsulates a static type
1911 # Can only be found in special construction like arguments of annotations.
1912 class ATypeExpr
1913 super AExpr
1914 var n_type: AType is writable, noinit
1915 end
1916
1917 # A special expression that encapsulates a method identifier
1918 # Can only be found in special construction like arguments of annotations.
1919 class AMethidExpr
1920 super AExpr
1921 # The receiver, is any
1922 var n_expr: AExpr is writable, noinit
1923 var n_id: AMethid is writable, noinit
1924 end
1925
1926 # A special expression that encapsulate an annotation
1927 # Can only be found in special construction like arguments of annotations.
1928 class AAtExpr
1929 super AExpr
1930 end
1931
1932 # A special expression to debug types
1933 class ADebugTypeExpr
1934 super AExpr
1935 var n_kwdebug: TKwdebug is writable, noinit
1936 var n_kwtype: TKwtype is writable, noinit
1937 var n_expr: AExpr is writable, noinit
1938 var n_type: AType is writable, noinit
1939 end
1940
1941 # A list of expression separated with commas (arguments for instance)
1942 abstract class AExprs
1943 super Prod
1944 var n_exprs = new ANodes[AExpr](self)
1945 end
1946
1947 # A simple list of expressions
1948 class AListExprs
1949 super AExprs
1950 end
1951
1952 # A list of expressions enclosed in parentheses
1953 class AParExprs
1954 super AExprs
1955 var n_opar: TOpar is writable, noinit
1956 var n_cpar: TCpar is writable, noinit
1957 end
1958
1959 # A list of expressions enclosed in brackets
1960 class ABraExprs
1961 super AExprs
1962 var n_obra: TObra is writable, noinit
1963 var n_cbra: TCbra is writable, noinit
1964 end
1965
1966 # A complex assignment operator. (`+=` and `-=`)
1967 abstract class AAssignOp
1968 super Prod
1969 end
1970
1971 # The `+=` assignment operation
1972 class APlusAssignOp
1973 super AAssignOp
1974 var n_pluseq: TPluseq is writable, noinit
1975 end
1976
1977 # The `-=` assignment operator
1978 class AMinusAssignOp
1979 super AAssignOp
1980 var n_minuseq: TMinuseq is writable, noinit
1981 end
1982
1983 # A possibly fully-qualified module identifier
1984 class AModuleName
1985 super Prod
1986 var n_quad: nullable TQuad = null is writable
1987 var n_path = new ANodes[TId](self)
1988 var n_id: TId is writable, noinit
1989 end
1990
1991 # A language declaration for an extern block
1992 class AInLanguage
1993 super Prod
1994 var n_kwin: TKwin is writable, noinit
1995 var n_string: TString is writable, noinit
1996 end
1997
1998 # An full extern block
1999 class AExternCodeBlock
2000 super Prod
2001 var n_in_language: nullable AInLanguage = null is writable
2002 var n_extern_code_segment: TExternCodeSegment is writable, noinit
2003 end
2004
2005 # A possible full method qualifier.
2006 class AQualified
2007 super Prod
2008 var n_quad: nullable TQuad = null is writable
2009 var n_id = new ANodes[TId](self)
2010 var n_classid: nullable TClassid = null is writable
2011 end
2012
2013 # A documentation of a definition
2014 # It contains the block of comments just above the declaration
2015 class ADoc
2016 super Prod
2017 var n_comment = new ANodes[TComment](self)
2018 end
2019
2020 # A group of annotation on a node
2021 class AAnnotations
2022 super Prod
2023 var n_at: nullable TAt = null is writable
2024 var n_opar: nullable TOpar = null is writable
2025 var n_items = new ANodes[AAnnotation](self)
2026 var n_cpar: nullable TCpar = null is writable
2027 end
2028
2029 # A single annotation
2030 class AAnnotation
2031 super ADefinition
2032 var n_atid: AAtid is writable, noinit
2033 var n_opar: nullable TOpar = null is writable
2034 var n_args = new ANodes[AExpr](self)
2035 var n_cpar: nullable TCpar = null is writable
2036 end
2037
2038 # An annotation name
2039 abstract class AAtid
2040 super Prod
2041 var n_id: Token is writable, noinit
2042 end
2043
2044 # An annotation name based on an identifier
2045 class AIdAtid
2046 super AAtid
2047 end
2048
2049 # An annotation name based on the keyword `extern`
2050 class AKwexternAtid
2051 super AAtid
2052 end
2053
2054 # An annotation name based on the keyword `import`
2055 class AKwimportAtid
2056 super AAtid
2057 end
2058
2059 # An annotation name based on the keyword `abstract`
2060 class AKwabstractAtid
2061 super AAtid
2062 end
2063
2064 # The root of the AST
2065 class Start
2066 super Prod
2067 var n_base: nullable AModule is writable
2068 var n_eof: EOF is writable
2069 end