src/parser: Regenerated parser
[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 import ordered_tree
21
22 # Root of the AST class-hierarchy
23 abstract class ANode
24 # Location is set during AST building. Once built, location cannon be null.
25 # However, manual instantiated nodes may need more care.
26 var location: Location is writable, noinit
27
28 # The location of the important part of the node (identifier or whatever)
29 fun hot_location: Location do return location
30
31 # Display a message for the colored location of the node
32 fun debug(message: String)
33 do
34 sys.stderr.write "{hot_location} {self.class_name}: {message}\n{hot_location.colored_line("0;32")}\n"
35 end
36
37 # Write the subtree on stdout.
38 # See `ASTDump`
39 fun dump_tree
40 do
41 var d = new ASTDump
42 d.enter_visit(self)
43 d.write_to(sys.stdout)
44 end
45
46 # Parent of the node in the AST
47 var parent: nullable ANode = null
48
49 # The topmost ancestor of the element
50 # This just apply `parent` until the first one
51 fun root: ANode
52 do
53 var res = self
54 loop
55 var p = res.parent
56 if p == null then return res
57 res = p
58 end
59 end
60
61 # The most specific common parent between `self` and `other`
62 # Return null if the two node are unrelated (distinct root)
63 fun common_parent(other: ANode): nullable ANode
64 do
65 # First, get the same depth
66 var s: nullable ANode = self
67 var o: nullable ANode = other
68 var d = s.depth - o.depth
69 while d > 0 do
70 s = s.parent
71 d -= 1
72 end
73 while d < 0 do
74 o = o.parent
75 d += 1
76 end
77 assert o.depth == s.depth
78 # Second, go up until same in found
79 while s != o do
80 s = s.parent
81 o = o.parent
82 end
83 return s
84 end
85
86 # Number of nodes between `self` and the `root` of the AST
87 # ENSURE `self == self.root implies result == 0 `
88 # ENSURE `self != self.root implies result == self.parent.depth + 1`
89 fun depth: Int
90 do
91 var n = self
92 var res = 0
93 loop
94 var p = n.parent
95 if p == null then return res
96 n = p
97 res += 1
98 end
99 end
100
101 # Replace a child with an other node in the AST
102 private fun replace_child(old_child: ANode, new_child: nullable ANode) is abstract
103
104 # Detach a node from its parent
105 # Aborts if the node is not detachable. use `replace_with` instead
106 # REQUIRE: parent != null
107 # REQUIRE: is_detachable
108 # ENDURE: parent == null
109 fun detach
110 do
111 assert parent != null
112 parent.replace_child(self, null)
113 parent = null
114 end
115
116 # Replace itself with an other node in the AST
117 # REQUIRE: parent != null
118 # ENSURE: node.parent == old(parent)
119 # ENSURE: parent == null
120 fun replace_with(node: ANode)
121 do
122 assert parent != null
123 parent.replace_child(self, node)
124 parent = null
125 end
126
127 # Visit all nodes in order.
128 # Thus, call `v.enter_visit(e)` for each child `e`
129 fun visit_all(v: Visitor) is abstract
130
131 # Do a deep search and return an array of tokens that match a given text
132 fun collect_tokens_by_text(text: String): Array[Token]
133 do
134 var v = new CollectTokensByTextVisitor(text)
135 v.enter_visit(self)
136 return v.result
137 end
138
139 # Do a deep search and return an array of node that are annotated
140 # The attached node can be retrieved by two invocations of parent
141 fun collect_annotations_by_name(name: String): Array[AAnnotation]
142 do
143 var v = new CollectAnnotationsByNameVisitor(name)
144 v.enter_visit(self)
145 return v.result
146 end
147 end
148
149 private class CollectTokensByTextVisitor
150 super Visitor
151 var text: String
152 var result = new Array[Token]
153 redef fun visit(node)
154 do
155 node.visit_all(self)
156 if node isa Token and node.text == text then result.add(node)
157 end
158 end
159
160 private class CollectAnnotationsByNameVisitor
161 super Visitor
162 var name: String
163 var result = new Array[AAnnotation]
164 redef fun visit(node)
165 do
166 node.visit_all(self)
167 if node isa AAnnotation and node.n_atid.n_id.text == name then result.add(node)
168 end
169 end
170
171 # A helper class to handle (print) Nit AST as an OrderedTree
172 class ASTDump
173 super Visitor
174 super OrderedTree[ANode]
175
176 # Reference to the last parent in the Ordered Tree
177 # Is used to handle the initial node parent and workaround possible inconsistent `ANode::parent`
178 private var last_parent: nullable ANode = null
179
180 redef fun visit(n)
181 do
182 var p = last_parent
183 add(p, n)
184 last_parent = n
185 n.visit_all(self)
186 last_parent = p
187 end
188
189 redef fun display(n)
190 do
191 if n isa Token then
192 return "{n.class_name} \"{n.text.escape_to_c}\" @{n.location}"
193 else
194 return "{n.class_name} @{n.location}"
195 end
196 end
197 end
198
199 # A sequence of nodes
200 # It is a specific class (instead of using a Array) to track the parent/child relation when nodes are added or removed
201 class ANodes[E: ANode]
202 super Sequence[E]
203 private var parent: ANode
204 private var items = new Array[E]
205 redef fun iterator do return items.iterator
206 redef fun length do return items.length
207 redef fun is_empty do return items.is_empty
208 redef fun push(e)
209 do
210 hook_add(e)
211 items.push(e)
212 end
213 redef fun pop
214 do
215 var res = items.pop
216 hook_remove(res)
217 return res
218 end
219 redef fun unshift(e)
220 do
221 hook_add(e)
222 items.unshift(e)
223 end
224 redef fun shift
225 do
226 var res = items.shift
227 hook_remove(res)
228 return res
229 end
230 redef fun has(e)
231 do
232 return items.has(e)
233 end
234 redef fun [](index)
235 do
236 return items[index]
237 end
238 redef fun []=(index, e)
239 do
240 hook_remove(self[index])
241 hook_add(e)
242 items[index]=e
243 end
244 redef fun remove_at(index)
245 do
246 hook_remove(items[index])
247 items.remove_at(index)
248 end
249 private fun hook_add(e: E)
250 do
251 #assert e.parent == null
252 e.parent = parent
253 end
254 private fun hook_remove(e: E)
255 do
256 assert e.parent == parent
257 e.parent = null
258 end
259
260 # Used in parent constructor to fill elements
261 private fun unsafe_add_all(nodes: Collection[Object])
262 do
263 var parent = self.parent
264 for n in nodes do
265 assert n isa E
266 add n
267 n.parent = parent
268 end
269 end
270
271 private fun replace_child(old_child: ANode, new_child: nullable ANode): Bool
272 do
273 var parent = self.parent
274 for i in [0..length[ do
275 if self[i] == old_child then
276 if new_child != null then
277 assert new_child isa E
278 self[i] = new_child
279 new_child.parent = parent
280 else
281 self.remove_at(i)
282 end
283 return true
284 end
285 end
286 return false
287 end
288
289 private fun visit_all(v: Visitor)
290 do
291 for n in self do v.enter_visit(n)
292 end
293 end
294
295 # Ancestor of all tokens
296 # A token is a node that has a `text` but no children.
297 abstract class Token
298 super ANode
299
300 # The raw content on the token
301 fun text: String is abstract
302
303 # The raw content on the token
304 fun text=(text: String) is abstract
305
306 # The previous token in the Lexer.
307 # May have disappeared in the AST
308 var prev_token: nullable Token = null
309
310 # The next token in the Lexer.
311 # May have disappeared in the AST
312 var next_token: nullable Token = null
313
314 # The verbatim blank text between `prev_token` and `self`
315 fun blank_before: String
316 do
317 if prev_token == null then return ""
318 var from = prev_token.location.pend+1
319 var to = location.pstart
320 return location.file.string.substring(from,to-from)
321 end
322
323 redef fun to_s: String do
324 return "'{text}'"
325 end
326
327 redef fun visit_all(v: Visitor) do end
328 redef fun replace_child(old_child: ANode, new_child: nullable ANode) do end
329 end
330
331 redef class SourceFile
332 # The first token parser by the lexer
333 # May have disappeared in the final AST
334 var first_token: nullable Token = null
335
336 # The first token parser by the lexer
337 # May have disappeared in the final AST
338 var last_token: nullable Token = null
339 end
340
341 # Ancestor of all productions
342 # A production is a node without text but that usually has children.
343 abstract class Prod
344 super ANode
345
346 # All the annotations attached directly to the node
347 var n_annotations: nullable AAnnotations = null is writable
348
349 # Return all its annotations of a given name in the order of their declaration
350 # Retun an empty array if no such an annotation.
351 fun get_annotations(name: String): Array[AAnnotation]
352 do
353 var res = new Array[AAnnotation]
354 var nas = n_annotations
355 if nas != null then for na in nas.n_items do
356 if na.name != name then continue
357 res.add(na)
358 end
359 if self isa AClassdef then for na in n_propdefs do
360 if na isa AAnnotPropdef then
361 if na.name != name then continue
362 res.add na
363 end
364 end
365
366 return res
367 end
368
369 redef fun replace_with(n: ANode)
370 do
371 super
372 assert n isa Prod
373 if not isset n._location and isset _location then n._location = _location
374 end
375 end
376
377 # Abstract standard visitor on the AST
378 abstract class Visitor
379 # What the visitor do when a node is visited
380 # Concrete visitors should implement this method.
381 # @toimplement
382 protected fun visit(e: ANode) is abstract
383
384 # Ask the visitor to visit a given node.
385 # Usually automatically called by visit_all* methods.
386 # This method should not be redefined
387 fun enter_visit(e: nullable ANode)
388 do
389 if e == null then return
390 var old = _current_node
391 _current_node = e
392 visit(e)
393 _current_node = old
394 end
395
396 # The current visited node
397 var current_node: nullable ANode = null is writable
398 end
399
400 # Token of end of line (basically `\n`)
401 class TEol
402 super Token
403 redef fun to_s
404 do
405 return "end of line"
406 end
407 end
408
409 # Token of a line of comments
410 # Starts with the `#` and contains the final end-of-line (if any)
411 class TComment
412 super Token
413 end
414
415 # A token associated with a keyword
416 abstract class TokenKeyword
417 super Token
418 redef fun to_s
419 do
420 return "keyword '{text}'"
421 end
422 end
423
424 # The deprecated keyword `package`.
425 class TKwpackage
426 super TokenKeyword
427 end
428
429 # The keyword `module`
430 class TKwmodule
431 super TokenKeyword
432 end
433
434 # The keyword `import`
435 class TKwimport
436 super TokenKeyword
437 end
438
439 # The keyword `class`
440 class TKwclass
441 super TokenKeyword
442 end
443
444 # The keyword `abstract`
445 class TKwabstract
446 super TokenKeyword
447 end
448
449 # The keyword `interface`
450 class TKwinterface
451 super TokenKeyword
452 end
453
454 # The keywords `enum` ane `universal`
455 class TKwenum
456 super TokenKeyword
457 end
458
459 # The keyword `end`
460 class TKwend
461 super TokenKeyword
462 end
463
464 # The keyword `fun`
465 class TKwmeth
466 super TokenKeyword
467 end
468
469 # The keyword `type`
470 class TKwtype
471 super TokenKeyword
472 end
473
474 # The keyword `init`
475 class TKwinit
476 super TokenKeyword
477 end
478
479 # The keyword `redef`
480 class TKwredef
481 super TokenKeyword
482 end
483
484 # The keyword `is`
485 class TKwis
486 super TokenKeyword
487 end
488
489 # The keyword `do`
490 class TKwdo
491 super TokenKeyword
492 end
493
494 # The keyword `var`
495 class TKwvar
496 super TokenKeyword
497 end
498
499 # The keyword `extern`
500 class TKwextern
501 super TokenKeyword
502 end
503
504 # The keyword `public`
505 class TKwpublic
506 super TokenKeyword
507 end
508
509 # The keyword `protected`
510 class TKwprotected
511 super TokenKeyword
512 end
513
514 # The keyword `private`
515 class TKwprivate
516 super TokenKeyword
517 end
518
519 # The keyword `intrude`
520 class TKwintrude
521 super TokenKeyword
522 end
523
524 # The keyword `if`
525 class TKwif
526 super TokenKeyword
527 end
528
529 # The keyword `then`
530 class TKwthen
531 super TokenKeyword
532 end
533
534 # The keyword `else`
535 class TKwelse
536 super TokenKeyword
537 end
538
539 # The keyword `while`
540 class TKwwhile
541 super TokenKeyword
542 end
543
544 # The keyword `loop`
545 class TKwloop
546 super TokenKeyword
547 end
548
549 # The keyword `for`
550 class TKwfor
551 super TokenKeyword
552 end
553
554 # The keyword `in`
555 class TKwin
556 super TokenKeyword
557 end
558
559 # The keyword `and`
560 class TKwand
561 super TokenKeyword
562 end
563
564 # The keyword `or`
565 class TKwor
566 super TokenKeyword
567 end
568
569 # The keyword `implies`
570 class TKwimplies
571 super TokenKeyword
572 end
573
574 # The keyword `not`
575 class TKwnot
576 super TokenKeyword
577 end
578
579 # The keyword `return`
580 class TKwreturn
581 super TokenKeyword
582 end
583
584 # The keyword `continue`
585 class TKwcontinue
586 super TokenKeyword
587 end
588
589 # The keyword `break`
590 class TKwbreak
591 super TokenKeyword
592 end
593
594 # The keyword `abort`
595 class TKwabort
596 super TokenKeyword
597 end
598
599 # The keyword `assert`
600 class TKwassert
601 super TokenKeyword
602 end
603
604 # The keyword `new`
605 class TKwnew
606 super TokenKeyword
607 end
608
609 # The keyword `isa`
610 class TKwisa
611 super TokenKeyword
612 end
613
614 # The keyword `once`
615 class TKwonce
616 super TokenKeyword
617 end
618
619 # The keyword `super`
620 class TKwsuper
621 super TokenKeyword
622 end
623
624 # The keyword `self`
625 class TKwself
626 super TokenKeyword
627 end
628
629 # The keyword `true`
630 class TKwtrue
631 super TokenKeyword
632 end
633
634 # The keyword `false`
635 class TKwfalse
636 super TokenKeyword
637 end
638
639 # The keyword `null`
640 class TKwnull
641 super TokenKeyword
642 end
643
644 # The keyword `as`
645 class TKwas
646 super TokenKeyword
647 end
648
649 # The keyword `nullable`
650 class TKwnullable
651 super TokenKeyword
652 end
653
654 # The keyword `isset`
655 class TKwisset
656 super TokenKeyword
657 end
658
659 # The keyword `label`
660 class TKwlabel
661 super TokenKeyword
662 end
663
664 # The keyword `with`
665 class TKwwith
666 super TokenKeyword
667 end
668
669 # The special keyword `__DEBUG__`
670 class TKwdebug
671 super Token
672 end
673
674 # The symbol `(`
675 class TOpar
676 super Token
677 end
678
679 # The symbol `)`
680 class TCpar
681 super Token
682 end
683
684 # The symbol `[`
685 class TObra
686 super Token
687 end
688
689 # The symbol `]`
690 class TCbra
691 super Token
692 end
693
694 # The symbol `,`
695 class TComma
696 super Token
697 end
698
699 # The symbol `:`
700 class TColumn
701 super Token
702 end
703
704 # The symbol `::`
705 class TQuad
706 super Token
707 end
708
709 # The symbol `=`
710 class TAssign
711 super Token
712 end
713
714 # A token associated with an operator (and other lookalike symbols)
715 abstract class TokenOperator
716 super Token
717 redef fun to_s
718 do
719 return "operator '{text}'"
720 end
721 end
722
723 # The operator `+=`
724 class TPluseq
725 super TokenOperator
726 end
727
728 # The operator `-=`
729 class TMinuseq
730 super TokenOperator
731 end
732
733 # The operator `*=`
734 class TStareq
735 super TokenOperator
736 end
737
738 # The operator `/=`
739 class TSlasheq
740 super TokenOperator
741 end
742
743 # The operator `%=`
744 class TPercenteq
745 super TokenOperator
746 end
747
748 # The operator `**=`
749 class TStarstareq
750 super TokenOperator
751 end
752
753 # The operator `|=`
754 class TPipeeq
755 super TokenOperator
756 end
757
758 # The operator `^=`
759 class TCareteq
760 super TokenOperator
761 end
762
763 # The operator `&=`
764 class TAmpeq
765 super TokenOperator
766 end
767
768 # The operator `<<=`
769 class TLleq
770 super TokenOperator
771 end
772
773 # The operator `>>=`
774 class TGgeq
775 super TokenOperator
776 end
777
778 # The symbol `...`
779 class TDotdotdot
780 super Token
781 end
782
783 # The symbol `..`
784 class TDotdot
785 super Token
786 end
787
788 # The symbol `.`
789 class TDot
790 super Token
791 end
792
793 # The operator `+`
794 class TPlus
795 super TokenOperator
796 end
797
798 # The operator `-`
799 class TMinus
800 super TokenOperator
801 end
802
803 # The operator `*`
804 class TStar
805 super TokenOperator
806 end
807
808 # The operator `**`
809 class TStarstar
810 super TokenOperator
811 end
812
813 # The operator `/`
814 class TSlash
815 super TokenOperator
816 end
817
818 # The operator `%`
819 class TPercent
820 super TokenOperator
821 end
822
823 # The operator `|`
824 class TPipe
825 super TokenOperator
826 end
827
828 # The operator `^`
829 class TCaret
830 super TokenOperator
831 end
832
833 # The operator `&`
834 class TAmp
835 super TokenOperator
836 end
837
838 # The operator `~`
839 class TTilde
840 super TokenOperator
841 end
842
843 # The operator `==`
844 class TEq
845 super TokenOperator
846 end
847
848 # The operator `!=`
849 class TNe
850 super TokenOperator
851 end
852
853 # The operator `<`
854 class TLt
855 super TokenOperator
856 end
857
858 # The operator `<=`
859 class TLe
860 super TokenOperator
861 end
862
863 # The operator `<<`
864 class TLl
865 super TokenOperator
866 end
867
868 # The operator `>`
869 class TGt
870 super TokenOperator
871 end
872
873 # The operator `>=`
874 class TGe
875 super TokenOperator
876 end
877
878 # The operator `>>`
879 class TGg
880 super TokenOperator
881 end
882
883 # The operator `<=>`
884 class TStarship
885 super TokenOperator
886 end
887
888 # The operator `!`
889 class TBang
890 super TokenOperator
891 end
892
893 # The symbol `@`
894 class TAt
895 super Token
896 end
897
898 # The symbol `;`
899 class TSemi
900 super Token
901 end
902
903 # A class (or formal type) identifier. They start with an uppercase.
904 class TClassid
905 super Token
906 redef fun to_s
907 do
908 do return "type identifier '{text}'"
909 end
910 end
911
912 # A standard identifier (variable, method...). They start with a lowercase.
913 class TId
914 super Token
915 redef fun to_s
916 do
917 do return "identifier '{text}'"
918 end
919 end
920
921 # An attribute identifier. They start with an underscore.
922 class TAttrid
923 super Token
924 redef fun to_s
925 do
926 do return "attribute '{text}'"
927 end
928 end
929
930 # A token of a literal value (string, integer, etc).
931 abstract class TokenLiteral
932 super Token
933 redef fun to_s
934 do
935 do return "literal value '{text}'"
936 end
937 end
938
939 # A literal decimal integer
940 class TNumber
941 super TokenLiteral
942 end
943
944 # A literal hexadecimal integer
945 class THexNumber
946 super TokenLiteral
947 end
948
949 # A literal binary integer
950 class TBinNumber
951 super TokenLiteral
952 end
953
954 # A literal octal integer
955 class TOctNumber
956 super TokenLiteral
957 end
958
959 # A literal floating point number
960 class TFloat
961 super TokenLiteral
962 end
963
964 # A literal character
965 class TChar
966 super TokenLiteral
967 end
968
969 # A literal string
970 class TString
971 super TokenLiteral
972 end
973
974 # The starting part of a super string (between `"` and `{`)
975 class TStartString
976 super TokenLiteral
977 end
978
979 # The middle part of a super string (between `}` and `{`)
980 class TMidString
981 super TokenLiteral
982 end
983
984 # The final part of a super string (between `}` and `"`)
985 class TEndString
986 super TokenLiteral
987 end
988
989 # A malformed string
990 class TBadString
991 super Token
992 redef fun to_s
993 do
994 do return "malformed string {text}"
995 end
996 end
997
998 # A malformed char
999 class TBadChar
1000 super Token
1001 redef fun to_s
1002 do
1003 do return "malformed character {text}"
1004 end
1005 end
1006
1007 # A extern code block
1008 class TExternCodeSegment
1009 super Token
1010 end
1011
1012 # A end of file
1013 class EOF
1014 super Token
1015 redef fun to_s
1016 do
1017 return "end of file"
1018 end
1019 end
1020
1021 # A mark of an error
1022 class AError
1023 super EOF
1024 end
1025 # A lexical error (unexpected character)
1026 class ALexerError
1027 super AError
1028 end
1029 # A syntactic error (unexpected token)
1030 class AParserError
1031 super AError
1032 end
1033
1034 # The main node of a Nit source-file
1035 class AModule
1036 super Prod
1037
1038 # The declaration part of the module
1039 var n_moduledecl: nullable AModuledecl = null is writable
1040
1041 # List of importation clauses
1042 var n_imports = new ANodes[AImport](self)
1043
1044 # List of extern blocks
1045 var n_extern_code_blocks = new ANodes[AExternCodeBlock](self)
1046
1047 # List of class definition (including top-level methods and the main)
1048 var n_classdefs = new ANodes[AClassdef](self)
1049 end
1050
1051 # Abstract class for definition of entities
1052 abstract class ADefinition
1053 super Prod
1054 # The documentation
1055 var n_doc: nullable ADoc = null is writable
1056
1057 # The `redef` keyword
1058 var n_kwredef: nullable TKwredef = null is writable
1059
1060 # The declared visibility
1061 var n_visibility: nullable AVisibility = null is writable
1062 end
1063
1064 # The declaration of the module with the documentation, name, and annotations
1065 class AModuledecl
1066 super ADefinition
1067
1068 # The `module` keyword
1069 var n_kwmodule: TKwmodule is writable, noinit
1070
1071 # The declared module name
1072 var n_name: AModuleName is writable, noinit
1073 end
1074
1075 # A import clause of a module
1076 abstract class AImport
1077 super Prod
1078
1079 # The declared visibility
1080 var n_visibility: AVisibility is writable, noinit
1081
1082 # The `import` keyword
1083 var n_kwimport: TKwimport is writable, noinit
1084 end
1085
1086 # A standard import clause. eg `import x`
1087 class AStdImport
1088 super AImport
1089 # The imported module name
1090 var n_name: AModuleName is writable, noinit
1091 end
1092
1093 # The special import clause of the kernel module. eg `import end`
1094 class ANoImport
1095 super AImport
1096 # The `end` keyword, that indicate the root module
1097 var n_kwend: TKwend is writable, noinit
1098 end
1099
1100 # A visibility modifier
1101 #
1102 # The public visibility is an empty production (no keyword).
1103 #
1104 # Note: even if some visibilities are only valid on some placse (for instance, no `protected` class or no `intrude` method)
1105 # the parser has no such a restriction, therefore the semantic phases has to check that the visibilities make sense.
1106 abstract class AVisibility
1107 super Prod
1108 end
1109
1110 # An implicit or explicit public visibility modifier
1111 class APublicVisibility
1112 super AVisibility
1113 # The `public` keyword, if any
1114 var n_kwpublic: nullable TKwpublic is writable
1115 end
1116 # An explicit private visibility modifier
1117 class APrivateVisibility
1118 super AVisibility
1119 # The `private` keyword
1120 var n_kwprivate: TKwprivate is writable, noinit
1121 end
1122 # An explicit protected visibility modifier
1123 class AProtectedVisibility
1124 super AVisibility
1125 # The `protected` keyword
1126 var n_kwprotected: TKwprotected is writable, noinit
1127 end
1128 # An explicit intrude visibility modifier
1129 class AIntrudeVisibility
1130 super AVisibility
1131 # The `intrude` keyword
1132 var n_kwintrude: TKwintrude is writable, noinit
1133 end
1134
1135 # A class definition
1136 # While most definition are `AStdClassdef`
1137 # There is tow special case of class definition
1138 abstract class AClassdef
1139 super Prod
1140 # All the declared properties (including the main method)
1141 var n_propdefs = new ANodes[APropdef](self)
1142 end
1143
1144 # A standard class definition with a name, superclasses and properties
1145 class AStdClassdef
1146 super AClassdef
1147 super ADefinition
1148
1149 # The class kind (interface, abstract class, etc.)
1150 var n_classkind: AClasskind is writable, noinit
1151
1152 # The name of the class
1153 var n_id: nullable TClassid = null is writable
1154
1155 # The `[` symbol
1156 var n_obra: nullable TObra = null is writable
1157
1158 # The list of formal parameter types
1159 var n_formaldefs = new ANodes[AFormaldef](self)
1160
1161 # The `]` symbol
1162 var n_cbra: nullable TCbra = null is writable
1163
1164 # The extern block code
1165 var n_extern_code_block: nullable AExternCodeBlock = null is writable
1166
1167 # The `end` keyword
1168 var n_kwend: TKwend is writable, noinit
1169
1170 fun n_superclasses: Array[ASuperPropdef] do
1171 return [for d in n_propdefs do if d isa ASuperPropdef then d]
1172 end
1173
1174 redef fun hot_location do return n_id.location
1175 end
1176
1177 # The implicit class definition of the implicit main method
1178 class ATopClassdef
1179 super AClassdef
1180 end
1181
1182 # The implicit class definition of the top-level methods
1183 class AMainClassdef
1184 super AClassdef
1185 end
1186
1187 # The modifier for the kind of class (abstract, interface, etc.)
1188 abstract class AClasskind
1189 super Prod
1190 end
1191
1192 # A default, or concrete class modifier (just `class`)
1193 class AConcreteClasskind
1194 super AClasskind
1195
1196 # The `class` keyword.
1197 var n_kwclass: TKwclass is writable, noinit
1198 end
1199
1200 # An abstract class modifier (`abstract class`)
1201 class AAbstractClasskind
1202 super AClasskind
1203
1204 # The `abstract` keyword.
1205 var n_kwabstract: TKwabstract is writable, noinit
1206
1207 # The `class` keyword.
1208 var n_kwclass: TKwclass is writable, noinit
1209 end
1210
1211 # An interface class modifier (`interface`)
1212 class AInterfaceClasskind
1213 super AClasskind
1214
1215 # The `interface` keyword.
1216 var n_kwinterface: TKwinterface is writable, noinit
1217 end
1218
1219 # An enum/universal class modifier (`enum class`)
1220 class AEnumClasskind
1221 super AClasskind
1222
1223 # The `enum` keyword.
1224 var n_kwenum: TKwenum is writable, noinit
1225 end
1226
1227 # An extern class modifier (`extern class`)
1228 class AExternClasskind
1229 super AClasskind
1230
1231 # The `extern` keyword.
1232 var n_kwextern: TKwextern is writable, noinit
1233
1234 # The `class` keyword.
1235 var n_kwclass: nullable TKwclass = null is writable
1236 end
1237
1238 # The definition of a formal generic parameter type. eg `X: Y`
1239 class AFormaldef
1240 super Prod
1241
1242 # The name of the parameter type
1243 var n_id: TClassid is writable, noinit
1244
1245 # The bound of the parameter type
1246 var n_type: nullable AType = null is writable
1247 end
1248
1249 # The definition of a property
1250 abstract class APropdef
1251 super ADefinition
1252 end
1253
1254 # A definition of an attribute
1255 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
1256 class AAttrPropdef
1257 super APropdef
1258
1259 # The `var` keyword
1260 var n_kwvar: TKwvar is writable, noinit
1261
1262 # The identifier for a new-style attribute
1263 var n_id2: TId is writable, noinit
1264
1265 # The declared type of the attribute
1266 var n_type: nullable AType = null is writable
1267
1268 # The `=` symbol
1269 var n_assign: nullable TAssign = null is writable
1270
1271 # The initial value, if any (set with `=`)
1272 var n_expr: nullable AExpr = null is writable
1273
1274 # The `do` keyword
1275 var n_kwdo: nullable TKwdo = null is writable
1276
1277 # The initial value, if any (set with `do return`)
1278 var n_block: nullable AExpr = null is writable
1279
1280 # The `end` keyword
1281 var n_kwend: nullable TKwend = null is writable
1282
1283 redef fun hot_location
1284 do
1285 return n_id2.location
1286 end
1287 end
1288
1289 # A definition of all kind of method (including constructors)
1290 class AMethPropdef
1291 super APropdef
1292
1293 # The `fun` keyword, if any
1294 var n_kwmeth: nullable TKwmeth = null is writable
1295
1296 # The `init` keyword, if any
1297 var n_kwinit: nullable TKwinit = null is writable
1298
1299 # The `new` keyword, if any
1300 var n_kwnew: nullable TKwnew = null is writable
1301
1302 # The name of the method, if any
1303 var n_methid: nullable AMethid = null is writable
1304
1305 # The signature of the method, if any
1306 var n_signature: nullable ASignature = null is writable
1307
1308 # The `do` keyword
1309 var n_kwdo: nullable TKwdo = null is writable
1310
1311 # The body (in Nit) of the method, if any
1312 var n_block: nullable AExpr = null is writable
1313
1314 # The `end` keyword
1315 var n_kwend: nullable TKwend = null is writable
1316
1317 # The list of declared callbacks (for extern methods)
1318 var n_extern_calls: nullable AExternCalls = null is writable
1319
1320 # The body (in extern code) of the method, if any
1321 var n_extern_code_block: nullable AExternCodeBlock = null is writable
1322
1323 redef fun hot_location
1324 do
1325 if n_methid != null then
1326 return n_methid.location
1327 else if n_kwinit != null then
1328 return n_kwinit.location
1329 else if n_kwnew != null then
1330 return n_kwnew.location
1331 else
1332 return location
1333 end
1334 end
1335 end
1336
1337 # The implicit main method
1338 class AMainMethPropdef
1339 super AMethPropdef
1340 end
1341
1342 class AAnnotPropdef
1343 super APropdef
1344 super AAnnotation
1345 end
1346
1347 # A super-class. eg `super X`
1348 class ASuperPropdef
1349 super APropdef
1350
1351 # The super keyword
1352 var n_kwsuper: TKwsuper is writable, noinit
1353
1354 # The super-class (indicated as a type)
1355 var n_type: AType is writable, noinit
1356 end
1357
1358
1359 # Declaration of callbacks for extern methods
1360 class AExternCalls
1361 super Prod
1362
1363 # The `import` keyword
1364 var n_kwimport: TKwimport is writable, noinit
1365
1366 # The list of declared callbacks
1367 var n_extern_calls: ANodes[AExternCall] = new ANodes[AExternCall](self)
1368 end
1369
1370 # A single callback declaration
1371 abstract class AExternCall
1372 super Prod
1373 end
1374
1375 # A single callback declaration on a method
1376 abstract class APropExternCall
1377 super AExternCall
1378 end
1379
1380 # A single callback declaration on a method on the current receiver
1381 class ALocalPropExternCall
1382 super APropExternCall
1383
1384 # The name of the called-back method
1385 var n_methid: AMethid is writable, noinit
1386 end
1387
1388 # A single callback declaration on a method on an explicit receiver type.
1389 class AFullPropExternCall
1390 super APropExternCall
1391
1392 # The type of the receiver of the called-back method
1393 var n_type: AType is writable, noinit
1394
1395 # The dot `.`
1396 var n_dot: nullable TDot = null is writable
1397
1398 # The name of the called-back method
1399 var n_methid: AMethid is writable, noinit
1400 end
1401
1402 # A single callback declaration on a method on a constructor
1403 class AInitPropExternCall
1404 super APropExternCall
1405
1406 # The allocated type
1407 var n_type: AType is writable, noinit
1408 end
1409
1410 # A single callback declaration on a `super` call
1411 class ASuperExternCall
1412 super AExternCall
1413
1414 # The `super` keyword
1415 var n_kwsuper: TKwsuper is writable, noinit
1416 end
1417
1418 # A single callback declaration on a cast
1419 abstract class ACastExternCall
1420 super AExternCall
1421 end
1422
1423 # A single callback declaration on a cast to a given type
1424 class ACastAsExternCall
1425 super ACastExternCall
1426
1427 # The origin type of the cast
1428 var n_from_type: AType is writable, noinit
1429
1430 # The dot (`.`)
1431 var n_dot: nullable TDot = null is writable
1432
1433 # The `as` keyword
1434 var n_kwas: TKwas is writable, noinit
1435
1436 # The destination of the cast
1437 var n_to_type: AType is writable, noinit
1438 end
1439
1440 # A single callback declaration on a cast to a nullable type
1441 class AAsNullableExternCall
1442 super ACastExternCall
1443
1444 # The origin type to cast as nullable
1445 var n_type: AType is writable, noinit
1446
1447 # The `as` keyword
1448 var n_kwas: TKwas is writable, noinit
1449
1450 # The `nullable` keyword
1451 var n_kwnullable: TKwnullable is writable, noinit
1452 end
1453
1454 # A single callback declaration on a cast to a non-nullable type
1455 class AAsNotNullableExternCall
1456 super ACastExternCall
1457
1458 # The destination type on a cast to not nullable
1459 var n_type: AType is writable, noinit
1460
1461 # The `as` keyword.
1462 var n_kwas: TKwas is writable, noinit
1463
1464 # The `not` keyword
1465 var n_kwnot: TKwnot is writable, noinit
1466
1467 # The `nullable` keyword
1468 var n_kwnullable: TKwnullable is writable, noinit
1469 end
1470
1471 # A definition of a virtual type
1472 class ATypePropdef
1473 super APropdef
1474
1475 # The `type` keyword
1476 var n_kwtype: TKwtype is writable, noinit
1477
1478 # The name of the virtual type
1479 var n_id: TClassid is writable, noinit
1480
1481 # The bound of the virtual type
1482 var n_type: AType is writable, noinit
1483 end
1484
1485 # The identifier of a method in a method declaration.
1486 # There is a specific class because of operator and setters.
1487 abstract class AMethid
1488 super Prod
1489 end
1490
1491 # A method name with a simple identifier
1492 class AIdMethid
1493 super AMethid
1494
1495 # The simple identifier
1496 var n_id: TId is writable, noinit
1497 end
1498
1499 # A method name for an operator
1500 class AOperatorMethid
1501 super AMethid
1502
1503 # The associated operator symbol
1504 var n_op: Token is writable, noinit
1505 end
1506 # A method name `+`
1507 class APlusMethid
1508 super AOperatorMethid
1509 end
1510
1511 # A method name `-`
1512 class AMinusMethid
1513 super AOperatorMethid
1514 end
1515
1516 # A method name `*`
1517 class AStarMethid
1518 super AOperatorMethid
1519 end
1520
1521 # A method name `**`
1522 class AStarstarMethid
1523 super AOperatorMethid
1524 end
1525
1526 # A method name `/`
1527 class ASlashMethid
1528 super AOperatorMethid
1529 end
1530
1531 # A method name `%`
1532 class APercentMethid
1533 super AOperatorMethid
1534 end
1535
1536 # A method name `|`
1537 class APipeMethid
1538 super AOperatorMethid
1539 end
1540
1541 # A method name `^`
1542 class ACaretMethid
1543 super AOperatorMethid
1544 end
1545
1546 # A method name `&`
1547 class AAmpMethid
1548 super AOperatorMethid
1549 end
1550
1551 # A method name `~`
1552 class ATildeMethid
1553 super AOperatorMethid
1554 end
1555
1556 # A method name `==`
1557 class AEqMethid
1558 super AOperatorMethid
1559 end
1560
1561 # A method name `!=`
1562 class ANeMethid
1563 super AOperatorMethid
1564 end
1565
1566 # A method name `<=`
1567 class ALeMethid
1568 super AOperatorMethid
1569 end
1570
1571 # A method name `>=`
1572 class AGeMethid
1573 super AOperatorMethid
1574 end
1575
1576 # A method name `<`
1577 class ALtMethid
1578 super AOperatorMethid
1579 end
1580
1581 # A method name `>`
1582 class AGtMethid
1583 super AOperatorMethid
1584 end
1585
1586 # A method name `<<`
1587 class ALlMethid
1588 super AOperatorMethid
1589 end
1590
1591 # A method name `>>`
1592 class AGgMethid
1593 super AOperatorMethid
1594 end
1595
1596 # A method name `<=>`
1597 class AStarshipMethid
1598 super AOperatorMethid
1599 end
1600
1601 # A method name `[]`
1602 class ABraMethid
1603 super AMethid
1604
1605 # The `[` symbol
1606 var n_obra: TObra is writable, noinit
1607
1608 # The `]` symbol
1609 var n_cbra: TCbra is writable, noinit
1610 end
1611
1612 # A setter method name with a simple identifier (with a `=`)
1613 class AAssignMethid
1614 super AMethid
1615
1616 # The base identifier
1617 var n_id: TId is writable, noinit
1618
1619 # The `=` symbol
1620 var n_assign: TAssign is writable, noinit
1621 end
1622
1623 # A method name `[]=`
1624 class ABraassignMethid
1625 super AMethid
1626
1627 # The `[` symbol
1628 var n_obra: TObra is writable, noinit
1629
1630 # The `]` symbol
1631 var n_cbra: TCbra is writable, noinit
1632
1633 # The `=` symbol
1634 var n_assign: TAssign is writable, noinit
1635 end
1636
1637 # A signature in a method definition. eg `(x,y:X,z:Z):T`
1638 class ASignature
1639 super Prod
1640
1641 # The `(` symbol
1642 var n_opar: nullable TOpar = null is writable
1643
1644 # The list of parameters
1645 var n_params = new ANodes[AParam](self)
1646
1647 # The `)` symbol
1648 var n_cpar: nullable TCpar = null is writable
1649
1650 # The return type
1651 var n_type: nullable AType = null is writable
1652 end
1653
1654 # A parameter definition in a signature. eg `x:X`
1655 class AParam
1656 super Prod
1657
1658 # The name of the parameter
1659 var n_id: TId is writable, noinit
1660
1661 # The type of the parameter, if any
1662 var n_type: nullable AType = null is writable
1663
1664 # The `...` symbol to indicate varargs
1665 var n_dotdotdot: nullable TDotdotdot = null is writable
1666 end
1667
1668 # A static type. eg `nullable X[Y]`
1669 class AType
1670 super Prod
1671 # The `nullable` keyword
1672 var n_kwnullable: nullable TKwnullable = null is writable
1673
1674 # The name of the class or of the formal type
1675 var n_id: TClassid is writable, noinit
1676
1677 # The opening bracket
1678 var n_obra: nullable TObra = null is writable
1679
1680 # Type arguments for a generic type
1681 var n_types = new ANodes[AType](self)
1682
1683 # The closing bracket
1684 var n_cbra: nullable TCbra = null is writable
1685 end
1686
1687 # A label at the end of a block or in a break/continue statement. eg `label x`
1688 class ALabel
1689 super Prod
1690
1691 # The `label` keyword
1692 var n_kwlabel: TKwlabel is writable, noinit
1693
1694 # The name of the label, if any
1695 var n_id: nullable TId is writable, noinit
1696 end
1697
1698 # Expression and statements
1699 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1700 abstract class AExpr
1701 super Prod
1702 end
1703
1704 # A sequence of `AExpr` (usually statements)
1705 # The last `AExpr` gives the value of the whole block
1706 class ABlockExpr
1707 super AExpr
1708
1709 # The list of statements in the bloc.
1710 # The last element is often considered as an expression that give the value of the whole block.
1711 var n_expr = new ANodes[AExpr](self)
1712
1713 # The `end` keyword
1714 var n_kwend: nullable TKwend = null is writable
1715 end
1716
1717 # A declaration of a local variable. eg `var x: X = y`
1718 class AVardeclExpr
1719 super AExpr
1720
1721 # The `var` keyword
1722 var n_kwvar: nullable TKwvar = null is writable
1723
1724 # The name of the local variable
1725 var n_id: TId is writable, noinit
1726
1727 # The declaration type of the local variable
1728 var n_type: nullable AType = null is writable
1729
1730 # The `=` symbol (for the initial value)
1731 var n_assign: nullable TAssign = null is writable
1732
1733 # The initial value, if any
1734 var n_expr: nullable AExpr = null is writable
1735 end
1736
1737 # A `return` statement. eg `return x`
1738 class AReturnExpr
1739 super AExpr
1740
1741 # The `return` keyword
1742 var n_kwreturn: nullable TKwreturn = null is writable
1743
1744 # The return value, if any
1745 var n_expr: nullable AExpr = null is writable
1746 end
1747
1748 # Something that has a label.
1749 abstract class ALabelable
1750 super Prod
1751
1752 # The associated label declatation
1753 var n_label: nullable ALabel = null is writable
1754 end
1755
1756 # A `break` or a `continue`
1757 abstract class AEscapeExpr
1758 super AExpr
1759 super ALabelable
1760
1761 # The return value, if nay (unused currently)
1762 var n_expr: nullable AExpr = null is writable
1763 end
1764
1765 # A `break` statement.
1766 class ABreakExpr
1767 super AEscapeExpr
1768
1769 # The `break` keyword
1770 var n_kwbreak: TKwbreak is writable, noinit
1771 end
1772
1773 # An `abort` statement
1774 class AAbortExpr
1775 super AExpr
1776
1777 # The `abort` keyword
1778 var n_kwabort: TKwabort is writable, noinit
1779 end
1780
1781 # A `continue` statement
1782 class AContinueExpr
1783 super AEscapeExpr
1784
1785 # The `continue` keyword.
1786 var n_kwcontinue: nullable TKwcontinue = null is writable
1787 end
1788
1789 # A `do` statement
1790 class ADoExpr
1791 super AExpr
1792 super ALabelable
1793
1794 # The `do` keyword
1795 var n_kwdo: TKwdo is writable, noinit
1796
1797 # The list of statements of the `do`.
1798 var n_block: nullable AExpr = null is writable
1799 end
1800
1801 # A `if` statement
1802 class AIfExpr
1803 super AExpr
1804
1805 # The `if` keyword
1806 var n_kwif: TKwif is writable, noinit
1807
1808 # The expression used as the condition of the `if`
1809 var n_expr: AExpr is writable, noinit
1810
1811 # The `then` keyword
1812 var n_kwthen: TKwthen is writable, noinit
1813
1814 # The body of the `then` part
1815 var n_then: nullable AExpr = null is writable
1816
1817 # The `else` keyword
1818 var n_kwelse: nullable TKwelse = null is writable
1819
1820 # The body of the `else` part
1821 var n_else: nullable AExpr = null is writable
1822 end
1823
1824 # A `if` expression (ternary conditional). eg. `if true then 1 else 0`
1825 class AIfexprExpr
1826 super AExpr
1827
1828 # The `if` keyword
1829 var n_kwif: TKwif is writable, noinit
1830
1831 # The expression used as the condition of the `if`
1832 var n_expr: AExpr is writable, noinit
1833
1834 # The `then` keyword
1835 var n_kwthen: TKwthen is writable, noinit
1836
1837 # The expression in the `then` part
1838 var n_then: AExpr is writable, noinit
1839
1840 # The `else` keyword
1841 var n_kwelse: TKwelse is writable, noinit
1842
1843 # The expression in the `else` part
1844 var n_else: AExpr is writable, noinit
1845 end
1846
1847 # A `while` statement
1848 class AWhileExpr
1849 super AExpr
1850 super ALabelable
1851
1852 # The `while` keyword
1853 var n_kwwhile: TKwwhile is writable, noinit
1854
1855 # The expression used as the condition of the `while`
1856 var n_expr: AExpr is writable, noinit
1857
1858 # The `do` keyword
1859 var n_kwdo: TKwdo is writable, noinit
1860
1861 # The body of the loop
1862 var n_block: nullable AExpr = null is writable
1863 end
1864
1865 # A `loop` statement
1866 class ALoopExpr
1867 super AExpr
1868 super ALabelable
1869
1870 # The `loop` keyword
1871 var n_kwloop: TKwloop is writable, noinit
1872
1873 # The body of the loop
1874 var n_block: nullable AExpr = null is writable
1875 end
1876
1877 # A `for` statement
1878 class AForExpr
1879 super AExpr
1880 super ALabelable
1881
1882 # The `for` keyword
1883 var n_kwfor: TKwfor is writable, noinit
1884
1885 # The list of name of the automatic variables
1886 var n_ids = new ANodes[TId](self)
1887
1888 # The `in` keyword
1889 var n_kwin: TKwin is writable, noinit
1890
1891 # The expression used as the collection to iterate on
1892 var n_expr: AExpr is writable, noinit
1893
1894 # The `do` keyword
1895 var n_kwdo: TKwdo is writable, noinit
1896
1897 # The body of the loop
1898 var n_block: nullable AExpr = null is writable
1899 end
1900
1901 # A `with` statement
1902 class AWithExpr
1903 super AExpr
1904 super ALabelable
1905
1906 # The `with` keyword
1907 var n_kwwith: TKwwith is writable, noinit
1908
1909 # The expression used to get the value to control
1910 var n_expr: AExpr is writable, noinit
1911
1912 # The `do` keyword
1913 var n_kwdo: TKwdo is writable, noinit
1914
1915 # The body of the loop
1916 var n_block: nullable AExpr = null is writable
1917 end
1918
1919 # An `assert` statement
1920 class AAssertExpr
1921 super AExpr
1922
1923 # The `assert` keyword
1924 var n_kwassert: TKwassert is writable, noinit
1925
1926 # The name of the assert, if any
1927 var n_id: nullable TId = null is writable
1928
1929 # The expression used as the condition of the `assert`
1930 var n_expr: AExpr is writable, noinit
1931
1932 # The `else` keyword
1933 var n_kwelse: nullable TKwelse = null is writable
1934
1935 # The body to execute when the assert fails
1936 var n_else: nullable AExpr = null is writable
1937 end
1938
1939 # Whatever is a simple assignment. eg `= something`
1940 abstract class AAssignFormExpr
1941 super AExpr
1942
1943 # The `=` symbol
1944 var n_assign: TAssign is writable, noinit
1945
1946 # The right-value to assign.
1947 var n_value: AExpr is writable, noinit
1948 end
1949
1950 # Whatever is a combined assignment. eg `+= something`
1951 abstract class AReassignFormExpr
1952 super AExpr
1953
1954 # The combined operator (eg. `+=`)
1955 var n_assign_op: AAssignOp is writable, noinit
1956
1957 # The right-value to apply on the combined operator.
1958 var n_value: AExpr is writable, noinit
1959 end
1960
1961 # A `once` expression. eg `once x`
1962 class AOnceExpr
1963 super AExpr
1964
1965 # The `once` keyword
1966 var n_kwonce: TKwonce is writable, noinit
1967
1968 # The expression to evaluate only one time
1969 var n_expr: AExpr is writable, noinit
1970 end
1971
1972 # A polymorphic invocation of a method
1973 # The form of the invocation (name, arguments, etc.) are specific
1974 abstract class ASendExpr
1975 super AExpr
1976 # The receiver of the method invocation
1977 var n_expr: AExpr is writable, noinit
1978 end
1979
1980 # A binary operation on a method
1981 abstract class ABinopExpr
1982 super ASendExpr
1983
1984 # The operator
1985 var n_op: Token is writable, noinit
1986
1987 # The second operand of the operation
1988 # Note: the receiver (`n_expr`) is the first operand
1989 var n_expr2: AExpr is writable, noinit
1990
1991 # The name of the operator (eg '+')
1992 fun operator: String is abstract
1993 end
1994
1995 # Something that is boolean expression
1996 abstract class ABoolExpr
1997 super AExpr
1998 end
1999
2000 # Something that is binary boolean expression
2001 abstract class ABinBoolExpr
2002 super ABoolExpr
2003
2004 # The first boolean operand
2005 var n_expr: AExpr is writable, noinit
2006
2007 # The operator
2008 var n_op: Token is writable, noinit
2009
2010 # The second boolean operand
2011 var n_expr2: AExpr is writable, noinit
2012 end
2013
2014 # A `or` expression
2015 class AOrExpr
2016 super ABinBoolExpr
2017 end
2018
2019 # A `and` expression
2020 class AAndExpr
2021 super ABinBoolExpr
2022 end
2023
2024 # A `or else` expression
2025 class AOrElseExpr
2026 super ABinBoolExpr
2027
2028 # The `else` keyword
2029 var n_kwelse: TKwelse is writable, noinit
2030 end
2031
2032 # A `implies` expression
2033 class AImpliesExpr
2034 super ABinBoolExpr
2035 end
2036
2037 # A `not` expression
2038 class ANotExpr
2039 super ABoolExpr
2040
2041 # The `not` keyword
2042 var n_kwnot: TKwnot is writable, noinit
2043
2044 # The boolean operand of the `not`
2045 var n_expr: AExpr is writable, noinit
2046 end
2047
2048 # A `==` expression
2049 class AEqExpr
2050 super ABinopExpr
2051 redef fun operator do return "=="
2052 end
2053
2054 # A `!=` expression
2055 class ANeExpr
2056 super ABinopExpr
2057 redef fun operator do return "!="
2058 end
2059
2060 # A `<` expression
2061 class ALtExpr
2062 super ABinopExpr
2063 redef fun operator do return "<"
2064 end
2065
2066 # A `<=` expression
2067 class ALeExpr
2068 super ABinopExpr
2069 redef fun operator do return "<="
2070 end
2071
2072 # A `<<` expression
2073 class ALlExpr
2074 super ABinopExpr
2075 redef fun operator do return "<<"
2076 end
2077
2078 # A `>` expression
2079 class AGtExpr
2080 super ABinopExpr
2081 redef fun operator do return ">"
2082 end
2083
2084 # A `>=` expression
2085 class AGeExpr
2086 super ABinopExpr
2087 redef fun operator do return ">="
2088 end
2089
2090 # A `>>` expression
2091 class AGgExpr
2092 super ABinopExpr
2093 redef fun operator do return ">>"
2094 end
2095
2096 # A type-ckeck expression. eg `x isa T`
2097 class AIsaExpr
2098 super ABoolExpr
2099
2100 # The expression to check
2101 var n_expr: AExpr is writable, noinit
2102
2103 # The `isa` keyword
2104 var n_kwisa: TKwisa is writable, noinit
2105
2106 # The destination type to check to
2107 var n_type: AType is writable, noinit
2108 end
2109
2110 # A `+` expression
2111 class APlusExpr
2112 super ABinopExpr
2113 redef fun operator do return "+"
2114 end
2115
2116 # A `-` expression
2117 class AMinusExpr
2118 super ABinopExpr
2119 redef fun operator do return "-"
2120 end
2121
2122 # A `<=>` expression
2123 class AStarshipExpr
2124 super ABinopExpr
2125 redef fun operator do return "<=>"
2126 end
2127
2128 # A `*` expression
2129 class AStarExpr
2130 super ABinopExpr
2131 redef fun operator do return "*"
2132 end
2133
2134 # A `**` expression
2135 class AStarstarExpr
2136 super ABinopExpr
2137 redef fun operator do return "**"
2138 end
2139
2140 # A `/` expression
2141 class ASlashExpr
2142 super ABinopExpr
2143 redef fun operator do return "/"
2144 end
2145
2146 # A `%` expression
2147 class APercentExpr
2148 super ABinopExpr
2149 redef fun operator do return "%"
2150 end
2151
2152 # A `|` expression
2153 class APipeExpr
2154 super ABinopExpr
2155 redef fun operator do return "|"
2156 end
2157
2158 # A `^` expression
2159 class ACaretExpr
2160 super ABinopExpr
2161 redef fun operator do return "^"
2162 end
2163
2164 # A `&` expression
2165 class AAmpExpr
2166 super ABinopExpr
2167 redef fun operator do return "&"
2168 end
2169
2170 # A unary operation on a method
2171 class AUnaryopExpr
2172 super ASendExpr
2173
2174 # The operator
2175 var n_op: Token is writable, noinit
2176
2177 # The name of the operator (eg '+')
2178 fun operator: String is abstract
2179 end
2180
2181 # A unary minus expression. eg `-x`
2182 class AUminusExpr
2183 super AUnaryopExpr
2184 redef fun operator do return "-"
2185 end
2186
2187 # A unary plus expression. eg `+x`
2188 class AUplusExpr
2189 super AUnaryopExpr
2190 redef fun operator do return "+"
2191 end
2192
2193 # A unary `~` expression
2194 class AUtildeExpr
2195 super AUnaryopExpr
2196 redef fun operator do return "~"
2197 end
2198
2199 # An explicit instantiation. eg `new T`
2200 class ANewExpr
2201 super AExpr
2202
2203 # The `new` keyword
2204 var n_kwnew: TKwnew is writable, noinit
2205
2206 # The `type` keyword
2207 var n_type: AType is writable, noinit
2208
2209 # The name of the named-constructor, if any
2210 var n_id: nullable TId = null is writable
2211
2212 # The arguments of the `new`
2213 var n_args: AExprs is writable, noinit
2214 end
2215
2216 # Whatever is a old-style attribute access
2217 abstract class AAttrFormExpr
2218 super AExpr
2219
2220 # The receiver of the attribute
2221 var n_expr: AExpr is writable, noinit
2222
2223 # The name of the attribute
2224 var n_id: TAttrid is writable, noinit
2225
2226 end
2227
2228 # The read of an attribute. eg `x._a`
2229 class AAttrExpr
2230 super AAttrFormExpr
2231 end
2232
2233 # The assignment of an attribute. eg `x._a=y`
2234 class AAttrAssignExpr
2235 super AAttrFormExpr
2236 super AAssignFormExpr
2237 end
2238
2239 # Whatever looks-like a call with a standard method and any number of arguments.
2240 abstract class ACallFormExpr
2241 super ASendExpr
2242
2243 # The name of the method
2244 var n_id: TId is writable, noinit
2245
2246 # The arguments of the call
2247 var n_args: AExprs is writable, noinit
2248 end
2249
2250 # A complex setter call (standard or brackets)
2251 abstract class ASendReassignFormExpr
2252 super ASendExpr
2253 super AReassignFormExpr
2254 end
2255
2256 # A complex attribute assignment. eg `x._a+=y`
2257 class AAttrReassignExpr
2258 super AAttrFormExpr
2259 super AReassignFormExpr
2260 end
2261
2262 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
2263 # 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`.
2264 # Semantic analysis have to transform them to instance of `AVarExpr`.
2265 class ACallExpr
2266 super ACallFormExpr
2267 end
2268
2269 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
2270 # 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`.
2271 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
2272 class ACallAssignExpr
2273 super ACallFormExpr
2274 super AAssignFormExpr
2275 end
2276
2277 # 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.
2278 # 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`.
2279 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
2280 class ACallReassignExpr
2281 super ACallFormExpr
2282 super ASendReassignFormExpr
2283 end
2284
2285 # A call to `super`. OR a call of a super-constructor
2286 class ASuperExpr
2287 super AExpr
2288
2289 # The qualifier part before the super (currenlty unused)
2290 var n_qualified: nullable AQualified = null is writable
2291
2292 # The `super` keyword
2293 var n_kwsuper: TKwsuper is writable, noinit
2294
2295 # The arguments of the super
2296 var n_args: AExprs is writable, noinit
2297 end
2298
2299 # A call to the `init` constructor.
2300 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a `ACallFormExpr`.
2301 class AInitExpr
2302 super ASendExpr
2303
2304 # The `init` keyword
2305 var n_kwinit: TKwinit is writable, noinit
2306
2307 # The arguments of the init
2308 var n_args: AExprs is writable, noinit
2309 end
2310
2311 # Whatever looks-like a call of the brackets `[]` operator.
2312 abstract class ABraFormExpr
2313 super ASendExpr
2314
2315 # The arguments inside the brackets
2316 var n_args: AExprs is writable, noinit
2317 end
2318
2319 # A call of the brackets operator. eg `x[y,z]`
2320 class ABraExpr
2321 super ABraFormExpr
2322 end
2323
2324 # A setter call of the bracket operator. eg `x[y,z]=t`
2325 class ABraAssignExpr
2326 super ABraFormExpr
2327 super AAssignFormExpr
2328 end
2329
2330 # Whatever is an access to a local variable
2331 abstract class AVarFormExpr
2332 super AExpr
2333
2334 # The name of the attribute
2335 var n_id: TId is writable, noinit
2336 end
2337
2338 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
2339 class ABraReassignExpr
2340 super ABraFormExpr
2341 super ASendReassignFormExpr
2342 end
2343
2344 # A local variable read access.
2345 # The parser cannot instantiate them, see `ACallExpr`.
2346 class AVarExpr
2347 super AVarFormExpr
2348 end
2349
2350 # A local variable simple assignment access
2351 # The parser cannot instantiate them, see `ACallAssignExpr`.
2352 class AVarAssignExpr
2353 super AVarFormExpr
2354 super AAssignFormExpr
2355 end
2356
2357 # A local variable complex assignment access
2358 # The parser cannot instantiate them, see `ACallReassignExpr`.
2359 class AVarReassignExpr
2360 super AVarFormExpr
2361 super AReassignFormExpr
2362 end
2363
2364 # A literal range, open or closed
2365 abstract class ARangeExpr
2366 super AExpr
2367
2368 # The left (lower) element of the range
2369 var n_expr: AExpr is writable, noinit
2370
2371 # The `..`
2372 var n_dotdot: TDotdot is writable, noinit
2373
2374 # The right (upper) element of the range
2375 var n_expr2: AExpr is writable, noinit
2376 end
2377
2378 # A closed literal range. eg `[x..y]`
2379 class ACrangeExpr
2380 super ARangeExpr
2381
2382 # The opening bracket `[`
2383 var n_obra: TObra is writable, noinit
2384
2385 # The closing bracket `]`
2386 var n_cbra: TCbra is writable, noinit
2387 end
2388
2389 # An open literal range. eg `[x..y[`
2390 class AOrangeExpr
2391 super ARangeExpr
2392
2393 # The opening bracket `[`
2394 var n_obra: TObra is writable, noinit
2395
2396 # The closing bracket `[` (because open range)
2397 var n_cbra: TObra is writable, noinit
2398 end
2399
2400 # A literal array. eg. `[x,y,z]`
2401 class AArrayExpr
2402 super AExpr
2403
2404 # The opening bracket `[`
2405 var n_obra: TObra is writable, noinit
2406
2407 # The elements of the array
2408 var n_exprs = new ANodes[AExpr](self)
2409
2410 # The type of the element of the array (if any)
2411 var n_type: nullable AType = null is writable
2412
2413 # The closing bracket `]`
2414 var n_cbra: TCbra is writable, noinit
2415 end
2416
2417 # A read of `self`
2418 class ASelfExpr
2419 super AExpr
2420
2421 # The `self` keyword
2422 var n_kwself: nullable TKwself = null is writable
2423 end
2424
2425 # When there is no explicit receiver, `self` is implicit
2426 class AImplicitSelfExpr
2427 super ASelfExpr
2428 end
2429
2430 # A `true` boolean literal constant
2431 class ATrueExpr
2432 super ABoolExpr
2433
2434 # The `true` keyword
2435 var n_kwtrue: TKwtrue is writable, noinit
2436 end
2437
2438 # A `false` boolean literal constant
2439 class AFalseExpr
2440 super ABoolExpr
2441
2442 # The `false` keyword
2443 var n_kwfalse: TKwfalse is writable, noinit
2444 end
2445
2446 # A `null` literal constant
2447 class ANullExpr
2448 super AExpr
2449
2450 # The `null` keyword
2451 var n_kwnull: TKwnull is writable, noinit
2452 end
2453
2454 # An integer literal
2455 class AIntExpr
2456 super AExpr
2457 end
2458
2459 # An integer literal in decimal format
2460 class ADecIntExpr
2461 super AIntExpr
2462
2463 # The decimal token
2464 var n_number: TNumber is writable, noinit
2465 end
2466
2467 # An integer literal in hexadecimal format
2468 class AHexIntExpr
2469 super AIntExpr
2470
2471 # The hexadecimal token
2472 var n_hex_number: THexNumber is writable, noinit
2473 end
2474
2475 # An integer literal in binary format
2476 class ABinIntExpr
2477 super AIntExpr
2478
2479 # The binary token
2480 var n_bin_number: TBinNumber is writable, noinit
2481 end
2482
2483 # An integer literal in octal format
2484 class AOctIntExpr
2485 super AIntExpr
2486
2487 # The octal token
2488 var n_oct_number: TOctNumber is writable, noinit
2489 end
2490
2491 # A float literal
2492 class AFloatExpr
2493 super AExpr
2494
2495 # The float token
2496 var n_float: TFloat is writable, noinit
2497 end
2498
2499 # A character literal
2500 class ACharExpr
2501 super AExpr
2502
2503 # The character token
2504 var n_char: TChar is writable, noinit
2505 end
2506
2507 # A string literal
2508 abstract class AStringFormExpr
2509 super AExpr
2510
2511 # The string token
2512 var n_string: Token is writable, noinit
2513 end
2514
2515 # A simple string. eg. `"abc"`
2516 class AStringExpr
2517 super AStringFormExpr
2518 end
2519
2520 # The start of a superstring. eg `"abc{`
2521 class AStartStringExpr
2522 super AStringFormExpr
2523 end
2524
2525 # The middle of a superstring. eg `}abc{`
2526 class AMidStringExpr
2527 super AStringFormExpr
2528 end
2529
2530 # The end of a superstrng. eg `}abc"`
2531 class AEndStringExpr
2532 super AStringFormExpr
2533 end
2534
2535 # A superstring literal. eg `"a{x}b{y}c"`
2536 # Each part is modeled a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
2537 class ASuperstringExpr
2538 super AExpr
2539
2540 # The list of the expressions of the superstring
2541 var n_exprs = new ANodes[AExpr](self)
2542 end
2543
2544 # A simple parenthesis. eg `(x)`
2545 class AParExpr
2546 super AExpr
2547
2548 # The opening parenthesis
2549 var n_opar: TOpar is writable, noinit
2550
2551 # The inner expression
2552 var n_expr: AExpr is writable, noinit
2553
2554 # The closing parenthesis
2555 var n_cpar: TCpar is writable, noinit
2556 end
2557
2558 # A cast, against a type or `not null`
2559 class AAsCastForm
2560 super AExpr
2561
2562 # The expression to cast
2563 var n_expr: AExpr is writable, noinit
2564
2565 # The `as` keyword
2566 var n_kwas: TKwas is writable, noinit
2567
2568 # The opening parenthesis
2569 var n_opar: nullable TOpar = null is writable
2570
2571 # The closing parenthesis
2572 var n_cpar: nullable TCpar = null is writable
2573 end
2574
2575 # A type cast. eg `x.as(T)`
2576 class AAsCastExpr
2577 super AAsCastForm
2578
2579 # The target type to cast to
2580 var n_type: AType is writable, noinit
2581 end
2582
2583 # A as-not-null cast. eg `x.as(not null)`
2584 class AAsNotnullExpr
2585 super AAsCastForm
2586
2587 # The `not` keyword
2588 var n_kwnot: TKwnot is writable, noinit
2589
2590 # The `null` keyword
2591 var n_kwnull: TKwnull is writable, noinit
2592 end
2593
2594 # A is-set check of old-style attributes. eg `isset x._a`
2595 class AIssetAttrExpr
2596 super AAttrFormExpr
2597
2598 # The `isset` keyword
2599 var n_kwisset: TKwisset is writable, noinit
2600 end
2601
2602 # An ellipsis notation used to pass an expression as it, in a vararg parameter
2603 class AVarargExpr
2604 super AExpr
2605
2606 # The passed expression
2607 var n_expr: AExpr is writable, noinit
2608
2609 # The `...` symbol
2610 var n_dotdotdot: TDotdotdot is writable, noinit
2611 end
2612
2613 # An named notation used to pass an expression by name in a parameter
2614 class ANamedargExpr
2615 super AExpr
2616
2617 # The name of the argument
2618 var n_id: TId is writable, noinit
2619
2620 # The `=` synbol
2621 var n_assign: TAssign is writable, noinit
2622
2623 # The passed expression
2624 var n_expr: AExpr is writable, noinit
2625 end
2626
2627 # A list of expression separated with commas (arguments for instance)
2628 class AManyExpr
2629 super AExpr
2630
2631 # The list of expressions
2632 var n_exprs = new ANodes[AExpr](self)
2633 end
2634
2635 # A special expression that encapsulates a static type
2636 # Can only be found in special construction like arguments of annotations.
2637 class ATypeExpr
2638 super AExpr
2639
2640 # The encapsulated type
2641 var n_type: AType is writable, noinit
2642 end
2643
2644 # A special expression that encapsulates a method identifier
2645 # Can only be found in special construction like arguments of annotations.
2646 class AMethidExpr
2647 super AExpr
2648
2649 # The receiver
2650 var n_expr: AExpr is writable, noinit
2651
2652 # The encapsulated method identifier
2653 var n_id: AMethid is writable, noinit
2654 end
2655
2656 # A special expression that encapsulate an annotation
2657 # Can only be found in special construction like arguments of annotations.
2658 #
2659 # The encapsulated annotations are in `n_annotations`
2660 class AAtExpr
2661 super AExpr
2662 end
2663
2664 # A special expression to debug types
2665 class ADebugTypeExpr
2666 super AExpr
2667
2668 # The `debug` keyword
2669 var n_kwdebug: TKwdebug is writable, noinit
2670
2671 # The `type` keyword
2672 var n_kwtype: TKwtype is writable, noinit
2673
2674 # The expression to check
2675 var n_expr: AExpr is writable, noinit
2676
2677 # The type to check
2678 var n_type: AType is writable, noinit
2679 end
2680
2681 # A list of expression separated with commas (arguments for instance)
2682 abstract class AExprs
2683 super Prod
2684
2685 # The list of expressions
2686 var n_exprs = new ANodes[AExpr](self)
2687 end
2688
2689 # A simple list of expressions
2690 class AListExprs
2691 super AExprs
2692 end
2693
2694 # A list of expressions enclosed in parentheses
2695 class AParExprs
2696 super AExprs
2697
2698 # The opening parenthesis
2699 var n_opar: TOpar is writable, noinit
2700
2701 # The closing parenthesis
2702 var n_cpar: TCpar is writable, noinit
2703 end
2704
2705 # A list of expressions enclosed in brackets
2706 class ABraExprs
2707 super AExprs
2708
2709 # The opening bracket
2710 var n_obra: TObra is writable, noinit
2711
2712 # The closing bracket
2713 var n_cbra: TCbra is writable, noinit
2714 end
2715
2716 # A complex assignment operator. (`+=` and `-=`)
2717 abstract class AAssignOp
2718 super Prod
2719
2720 # The combined assignment operator
2721 var n_op: Token is writable, noinit
2722
2723 # The name of the operator without the `=` (eg '+')
2724 fun operator: String is abstract
2725 end
2726
2727 # A `+=` assignment operation
2728 class APlusAssignOp
2729 super AAssignOp
2730
2731 redef fun operator do return "+"
2732 end
2733
2734 # A `-=` assignment operation
2735 class AMinusAssignOp
2736 super AAssignOp
2737
2738 redef fun operator do return "-"
2739 end
2740
2741 # A `*=` assignment operation
2742 class AStarAssignOp
2743 super AAssignOp
2744
2745 redef fun operator do return "*"
2746 end
2747
2748 # A `/=` assignment operation
2749 class ASlashAssignOp
2750 super AAssignOp
2751
2752 redef fun operator do return "/"
2753 end
2754
2755 # A `%=` assignment operation
2756 class APercentAssignOp
2757 super AAssignOp
2758
2759 redef fun operator do return "%"
2760 end
2761
2762 # A `**=` assignment operation
2763 class AStarstarAssignOp
2764 super AAssignOp
2765
2766 redef fun operator do return "**"
2767 end
2768
2769 # A `|=` assignment operation
2770 class APipeAssignOp
2771 super AAssignOp
2772
2773 redef fun operator do return "|"
2774 end
2775
2776 # A `^=` assignment operation
2777 class ACaretAssignOp
2778 super AAssignOp
2779
2780 redef fun operator do return "^"
2781 end
2782
2783 # A `&=` assignment operation
2784 class AAmpAssignOp
2785 super AAssignOp
2786
2787 redef fun operator do return "&"
2788 end
2789
2790 # A `<<=` assignment operation
2791 class ALlAssignOp
2792 super AAssignOp
2793
2794 redef fun operator do return "<<"
2795 end
2796
2797 # A `>>=` assignment operation
2798 class AGgAssignOp
2799 super AAssignOp
2800
2801 redef fun operator do return ">>"
2802 end
2803
2804 # A possibly fully-qualified module identifier
2805 class AModuleName
2806 super Prod
2807
2808 # The starting quad (`::`)
2809 var n_quad: nullable TQuad = null is writable
2810
2811 # The list of quad-separated project/group identifiers
2812 var n_path = new ANodes[TId](self)
2813
2814 # The final module identifier
2815 var n_id: TId is writable, noinit
2816 end
2817
2818 # A language declaration for an extern block
2819 class AInLanguage
2820 super Prod
2821
2822 # The `in` keyword
2823 var n_kwin: TKwin is writable, noinit
2824
2825 # The language name
2826 var n_string: TString is writable, noinit
2827 end
2828
2829 # An full extern block
2830 class AExternCodeBlock
2831 super Prod
2832
2833 # The language declration
2834 var n_in_language: nullable AInLanguage = null is writable
2835
2836 # The block of extern code
2837 var n_extern_code_segment: TExternCodeSegment is writable, noinit
2838 end
2839
2840 # A possible full method qualifier.
2841 class AQualified
2842 super Prod
2843
2844 # The starting quad (`::`)
2845 var n_quad: nullable TQuad = null is writable
2846
2847 # The list of quad-separated project/group/module identifiers
2848 var n_id = new ANodes[TId](self)
2849
2850 # A class identifier
2851 var n_classid: nullable TClassid = null is writable
2852 end
2853
2854 # A documentation of a definition
2855 # It contains the block of comments just above the declaration
2856 class ADoc
2857 super Prod
2858
2859 # A list of lines of comment
2860 var n_comment = new ANodes[TComment](self)
2861 end
2862
2863 # A group of annotation on a node
2864 #
2865 # This same class is used for the 3 kind of annotations:
2866 #
2867 # * *is* annotations. eg `module foo is bar`.
2868 # * *at* annotations. eg `foo@bar` or `foo@(bar,baz)`.
2869 # * *class* annotations, defined in classes.
2870 class AAnnotations
2871 super Prod
2872
2873 # The `is` keyword, for *is* annotations
2874 var n_kwis: nullable TKwis = null is writable
2875
2876 # The `@` symbol, for *at* annotations
2877 var n_at: nullable TAt = null is writable
2878
2879 # The opening parenthesis in *at* annotations
2880 var n_opar: nullable TOpar = null is writable
2881
2882 # The list of annotations
2883 var n_items = new ANodes[AAnnotation](self)
2884
2885 # The closing parenthesis in *at* annotations
2886 var n_cpar: nullable TCpar = null is writable
2887
2888 # The `end` keyword, for *is* annotations
2889 var n_kwend: nullable TKwend = null is writable
2890 end
2891
2892 # A single annotation
2893 class AAnnotation
2894 super ADefinition
2895
2896 # The name of the annotation
2897 var n_atid: AAtid is writable, noinit
2898
2899 # The opening parenthesis of the arguments
2900 var n_opar: nullable TOpar = null is writable
2901
2902 # The list of arguments
2903 var n_args = new ANodes[AExpr](self)
2904
2905 # The closing parenthesis
2906 var n_cpar: nullable TCpar = null is writable
2907
2908 # The name of the annotation
2909 fun name: String
2910 do
2911 return n_atid.n_id.text
2912 end
2913 end
2914
2915 # An annotation name
2916 abstract class AAtid
2917 super Prod
2918
2919 # The identifier of the annotation.
2920 # Can be a TId of a keyword
2921 var n_id: Token is writable, noinit
2922 end
2923
2924 # An annotation name based on an identifier
2925 class AIdAtid
2926 super AAtid
2927 end
2928
2929 # An annotation name based on the keyword `extern`
2930 class AKwexternAtid
2931 super AAtid
2932 end
2933
2934 # An annotation name based on the keyword `import`
2935 class AKwimportAtid
2936 super AAtid
2937 end
2938
2939 # An annotation name based on the keyword `abstract`
2940 class AKwabstractAtid
2941 super AAtid
2942 end
2943
2944 # The root of the AST
2945 class Start
2946 super Prod
2947
2948 # The main module
2949 var n_base: nullable AModule is writable
2950
2951 # The end of file (or error) token
2952 var n_eof: EOF is writable
2953 end