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