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