grammar: new power operator `**` (starstar)
[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 detashable. 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 # There is a specifc class (instead of a using 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 contructor 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 fun text=(text: String) is abstract
226
227 # The previous token in the Lexer.
228 # May have disapeared in the AST
229 var prev_token: nullable Token = null
230
231 # The next token in the Lexer.
232 # May have disapeared in the AST
233 var next_token: nullable Token = null
234
235 # The verbatim blank text between `prev_token` and `self`
236 fun blank_before: String
237 do
238 if prev_token == null then return ""
239 var from = prev_token.location.pend+1
240 var to = location.pstart
241 return location.file.string.substring(from,to-from)
242 end
243
244 redef fun to_s: String do
245 return "'{text}'"
246 end
247
248 redef fun visit_all(v: Visitor) do end
249 redef fun replace_child(old_child: ANode, new_child: nullable ANode) do end
250 end
251
252 redef class SourceFile
253 # The first token parser by the lexer
254 # May have disapeared in the final AST
255 var first_token: nullable Token = null
256
257 # The first token parser by the lexer
258 # May have disapeared in the final AST
259 var last_token: nullable Token = null
260 end
261
262 # Ancestor of all productions
263 # A production is a node without text but that usually has children.
264 abstract class Prod
265 super ANode
266
267 # All the annotations attached directly to the node
268 var n_annotations: nullable AAnnotations = null is writable
269
270 redef fun replace_with(n: ANode)
271 do
272 super
273 assert n isa Prod
274 if not isset n._location and isset _location then n._location = _location
275 end
276 end
277
278 # Abstract standard visitor on the AST
279 abstract class Visitor
280 # What the visitor do when a node is visited
281 # Concrete visitors should implement this method.
282 # @toimplement
283 protected fun visit(e: ANode) is abstract
284
285 # Ask the visitor to visit a given node.
286 # Usually automatically called by visit_all* methods.
287 # This method should not be redefined
288 fun enter_visit(e: nullable ANode)
289 do
290 if e == null then return
291 var old = _current_node
292 _current_node = e
293 visit(e)
294 _current_node = old
295 end
296
297 # The current visited node
298 var current_node: nullable ANode = null is writable
299 end
300
301 # Token of end of line (basically `\n`)
302 class TEol
303 super Token
304 redef fun to_s
305 do
306 return "end of line"
307 end
308 end
309
310 # Token of a line of comments
311 # Starts with the `#` and contains the final end-of-line (if any)
312 class TComment
313 super Token
314 end
315
316 # A token associated with a keyword
317 abstract class TokenKeyword
318 super Token
319 redef fun to_s
320 do
321 return "keyword '{text}'"
322 end
323 end
324 class TKwpackage
325 super TokenKeyword
326 end
327 class TKwmodule
328 super TokenKeyword
329 end
330 class TKwimport
331 super TokenKeyword
332 end
333 class TKwclass
334 super TokenKeyword
335 end
336 class TKwabstract
337 super TokenKeyword
338 end
339 class TKwinterface
340 super TokenKeyword
341 end
342 class TKwenum
343 super TokenKeyword
344 end
345 class TKwend
346 super TokenKeyword
347 end
348 class TKwmeth
349 super TokenKeyword
350 end
351 class TKwtype
352 super TokenKeyword
353 end
354 class TKwinit
355 super TokenKeyword
356 end
357 class TKwredef
358 super TokenKeyword
359 end
360 class TKwis
361 super TokenKeyword
362 end
363 class TKwdo
364 super TokenKeyword
365 end
366 class TKwreadable
367 super TokenKeyword
368 end
369 class TKwwritable
370 super TokenKeyword
371 end
372 class TKwvar
373 super TokenKeyword
374 end
375 class TKwintern
376 super TokenKeyword
377 end
378 class TKwextern
379 super TokenKeyword
380 end
381 class TKwpublic
382 super TokenKeyword
383 end
384 class TKwprotected
385 super TokenKeyword
386 end
387 class TKwprivate
388 super TokenKeyword
389 end
390 class TKwintrude
391 super TokenKeyword
392 end
393 class TKwif
394 super TokenKeyword
395 end
396 class TKwthen
397 super TokenKeyword
398 end
399 class TKwelse
400 super TokenKeyword
401 end
402 class TKwwhile
403 super TokenKeyword
404 end
405 class TKwloop
406 super TokenKeyword
407 end
408 class TKwfor
409 super TokenKeyword
410 end
411 class TKwin
412 super TokenKeyword
413 end
414 class TKwand
415 super TokenKeyword
416 end
417 class TKwor
418 super TokenKeyword
419 end
420 class TKwimplies
421 super TokenKeyword
422 end
423 class TKwnot
424 super TokenKeyword
425 end
426 class TKwreturn
427 super TokenKeyword
428 end
429 class TKwcontinue
430 super TokenKeyword
431 end
432 class TKwbreak
433 super TokenKeyword
434 end
435 class TKwabort
436 super TokenKeyword
437 end
438 class TKwassert
439 super TokenKeyword
440 end
441 class TKwnew
442 super TokenKeyword
443 end
444 class TKwisa
445 super TokenKeyword
446 end
447 class TKwonce
448 super TokenKeyword
449 end
450 class TKwsuper
451 super TokenKeyword
452 end
453 class TKwself
454 super TokenKeyword
455 end
456 class TKwtrue
457 super TokenKeyword
458 end
459 class TKwfalse
460 super TokenKeyword
461 end
462 class TKwnull
463 super TokenKeyword
464 end
465 class TKwas
466 super TokenKeyword
467 end
468 class TKwnullable
469 super TokenKeyword
470 end
471 class TKwisset
472 super TokenKeyword
473 end
474 class TKwlabel
475 super TokenKeyword
476 end
477 class TKwdebug
478 super Token
479 end
480 class TOpar
481 super Token
482 end
483 class TCpar
484 super Token
485 end
486 class TObra
487 super Token
488 end
489 class TCbra
490 super Token
491 end
492 class TComma
493 super Token
494 end
495 class TColumn
496 super Token
497 end
498 class TQuad
499 super Token
500 end
501 class TAssign
502 super Token
503 end
504
505 # A token associated with an operator (and other lookalike symbols)
506 abstract class TokenOperator
507 super Token
508 redef fun to_s
509 do
510 return "operator '{text}'"
511 end
512 end
513 class TPluseq
514 super TokenOperator
515 end
516 class TMinuseq
517 super TokenOperator
518 end
519 class TDotdotdot
520 super Token
521 end
522 class TDotdot
523 super Token
524 end
525 class TDot
526 super Token
527 end
528 class TPlus
529 super TokenOperator
530 end
531 class TMinus
532 super TokenOperator
533 end
534 class TStar
535 super TokenOperator
536 end
537 class TStarstar
538 super TokenOperator
539 end
540 class TSlash
541 super TokenOperator
542 end
543 class TPercent
544 super TokenOperator
545 end
546 class TEq
547 super TokenOperator
548 end
549 class TNe
550 super TokenOperator
551 end
552 class TLt
553 super TokenOperator
554 end
555 class TLe
556 super TokenOperator
557 end
558 class TLl
559 super TokenOperator
560 end
561 class TGt
562 super TokenOperator
563 end
564 class TGe
565 super TokenOperator
566 end
567 class TGg
568 super TokenOperator
569 end
570 class TStarship
571 super TokenOperator
572 end
573 class TBang
574 super TokenOperator
575 end
576 class TAt
577 super Token
578 end
579
580 # A class (or formal type) identifier. They start with an uppercase.
581 class TClassid
582 super Token
583 redef fun to_s
584 do
585 do return "type identifier '{text}'"
586 end
587 end
588
589 # A standard identifier (variable, method...). They start with a lowercase.
590 class TId
591 super Token
592 redef fun to_s
593 do
594 do return "identifier '{text}'"
595 end
596 end
597
598 # An attribute identifier. They start with an underscore.
599 class TAttrid
600 super Token
601 redef fun to_s
602 do
603 do return "attribute '{text}'"
604 end
605 end
606
607 # A token of a literal value (string, integer, etc).
608 abstract class TokenLiteral
609 super Token
610 redef fun to_s
611 do
612 do return "literal value '{text}'"
613 end
614 end
615 class TNumber
616 super TokenLiteral
617 end
618 class THexNumber
619 super TokenLiteral
620 end
621 class TFloat
622 super TokenLiteral
623 end
624 class TChar
625 super TokenLiteral
626 end
627 class TString
628 super TokenLiteral
629 end
630 class TStartString
631 super TokenLiteral
632 end
633 class TMidString
634 super TokenLiteral
635 end
636 class TEndString
637 super TokenLiteral
638 end
639
640 # A malformed string
641 class TBadString
642 super Token
643 redef fun to_s
644 do
645 do return "malformed string {text}"
646 end
647 end
648
649 # A malformed char
650 class TBadChar
651 super Token
652 redef fun to_s
653 do
654 do return "malformed character {text}"
655 end
656 end
657
658 class TExternCodeSegment
659 super Token
660 end
661
662 # A end of file
663 class EOF
664 super Token
665 redef fun to_s
666 do
667 return "end of file"
668 end
669 end
670
671 # A mark of an error
672 class AError
673 super EOF
674 end
675 class ALexerError
676 super AError
677 end
678 class AParserError
679 super AError
680 end
681
682 # The main node of a Nit source-file
683 class AModule
684 super Prod
685
686 var n_moduledecl: nullable AModuledecl = null is writable
687 var n_imports: ANodes[AImport] = new ANodes[AImport](self)
688 var n_extern_code_blocks: ANodes[AExternCodeBlock] = new ANodes[AExternCodeBlock](self)
689 var n_classdefs: ANodes[AClassdef] = new ANodes[AClassdef](self)
690 end
691
692 # The declaration of the module with the documentation, name, and annotations
693 class AModuledecl
694 super Prod
695 var n_doc: nullable ADoc = null is writable
696 var n_kwredef: nullable TKwredef = null is writable
697 var n_visibility: AVisibility is writable, noinit
698 var n_kwmodule: TKwmodule is writable, noinit
699 var n_name: AModuleName is writable, noinit
700 end
701
702 # A import clause of a module
703 abstract class AImport
704 super Prod
705 end
706
707 # A standard import clause. eg `import x`
708 class AStdImport
709 super AImport
710 var n_visibility: AVisibility is writable, noinit
711 var n_kwimport: TKwimport is writable, noinit
712 var n_name: AModuleName is writable, noinit
713 end
714
715 # The special import clause of the kernel module. eg `import end`
716 class ANoImport
717 super AImport
718 var n_visibility: AVisibility is writable, noinit
719 var n_kwimport: TKwimport is writable, noinit
720 var n_kwend: TKwend is writable, noinit
721 end
722
723 # A visibility modifier
724 #
725 # The public visibility is an empty production (no keyword).
726 #
727 # Note: even if some visibilities are only valid on some placse (for instance, no `protected` class or no `intrude` method)
728 # the parser has no such a restriction, therefore the semantic phases has to check that the visibilities make sense.
729 abstract class AVisibility
730 super Prod
731 end
732 class APublicVisibility
733 super AVisibility
734 var n_kwpublic: nullable TKwpublic is writable
735 end
736 class APrivateVisibility
737 super AVisibility
738 var n_kwprivate: TKwprivate is writable, noinit
739 end
740 class AProtectedVisibility
741 super AVisibility
742 var n_kwprotected: TKwprotected is writable, noinit
743 end
744 class AIntrudeVisibility
745 super AVisibility
746 var n_kwintrude: TKwintrude is writable, noinit
747 end
748
749 # A class definition
750 # While most definition are `AStdClassdef`
751 # There is tow special case of class definition
752 abstract class AClassdef
753 super Prod
754 var n_propdefs: ANodes[APropdef] = new ANodes[APropdef](self)
755 end
756
757 # A standard class definition with a name, superclasses and properties
758 class AStdClassdef
759 super AClassdef
760 var n_doc: nullable ADoc = null is writable
761 var n_kwredef: nullable TKwredef = null is writable
762 var n_visibility: AVisibility is writable, noinit
763 var n_classkind: AClasskind is writable, noinit
764 var n_id: nullable TClassid = null is writable
765 var n_formaldefs: ANodes[AFormaldef] = new ANodes[AFormaldef](self)
766 var n_extern_code_block: nullable AExternCodeBlock = null is writable
767 var n_superclasses: ANodes[ASuperclass] = new ANodes[ASuperclass](self)
768 var n_kwend: TKwend is writable, noinit
769 redef fun hot_location do return n_id.location
770 end
771
772 # The implicit class definition of the implicit main method
773 class ATopClassdef
774 super AClassdef
775 end
776
777 # The implicit class definition of the top-level methods
778 class AMainClassdef
779 super AClassdef
780 end
781
782 # The modifier for the kind of class (abstract, interface, etc.)
783 abstract class AClasskind
784 super Prod
785 end
786 class AConcreteClasskind
787 super AClasskind
788 var n_kwclass: TKwclass is writable, noinit
789 end
790 class AAbstractClasskind
791 super AClasskind
792 var n_kwabstract: TKwabstract is writable, noinit
793 var n_kwclass: TKwclass is writable, noinit
794 end
795 class AInterfaceClasskind
796 super AClasskind
797 var n_kwinterface: TKwinterface is writable, noinit
798 end
799 class AEnumClasskind
800 super AClasskind
801 var n_kwenum: TKwenum is writable, noinit
802 end
803 class AExternClasskind
804 super AClasskind
805 var n_kwextern: TKwextern is writable, noinit
806 var n_kwclass: nullable TKwclass = null is writable
807 end
808
809 # The definition of a formal generic parameter type. eg `X: Y`
810 class AFormaldef
811 super Prod
812 var n_id: TClassid is writable, noinit
813 # The bound of the parameter type
814 var n_type: nullable AType = null is writable
815 end
816
817 # A super-class. eg `super X`
818 class ASuperclass
819 super Prod
820 var n_kwsuper: TKwsuper is writable, noinit
821 var n_type: AType is writable, noinit
822 end
823
824 # The definition of a property
825 abstract class APropdef
826 super Prod
827 var n_doc: nullable ADoc = null is writable
828 var n_kwredef: nullable TKwredef = null is writable
829 var n_visibility: nullable AVisibility = null is writable
830 end
831
832 # A definition of an attribute
833 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
834 class AAttrPropdef
835 super APropdef
836 var n_kwvar: TKwvar is writable, noinit
837
838 # The identifier for an old-style attribute (null if new-style)
839 var n_id: nullable TAttrid is writable
840
841 # The identifier for a new-style attribute (null if old-style)
842 var n_id2: nullable TId is writable
843
844 var n_type: nullable AType = null is writable
845 var n_readable: nullable AAble = null is writable
846 var n_writable: nullable AAble = null is writable
847
848 # The initial value, if any
849 var n_expr: nullable AExpr = null is writable
850 redef fun hot_location
851 do
852 if n_id != null then return n_id.location else return n_id2.location
853 end
854 end
855
856 # A definition of all kind of method (including constructors)
857 class AMethPropdef
858 super APropdef
859 var n_kwmeth: nullable TKwmeth = null is writable
860 var n_kwinit: nullable TKwinit = null is writable
861 var n_kwnew: nullable TKwnew = null is writable
862 var n_methid: nullable AMethid = null is writable
863 var n_signature: nullable ASignature = null is writable
864 var n_block: nullable AExpr = null is writable
865 var n_extern: nullable TString = null is writable
866 var n_extern_calls: nullable AExternCalls = null is writable
867 var n_extern_code_block: nullable AExternCodeBlock = null is writable
868 redef fun hot_location
869 do
870 if n_methid != null then
871 return n_methid.location
872 else if n_kwinit != null then
873 return n_kwinit.location
874 else if n_kwnew != null then
875 return n_kwnew.location
876 else
877 return location
878 end
879 end
880 end
881
882 # A method marked abstract
883 # *deferred* is a old synonynmous of *abstract* that comes from PRM, that comes from Eiffel.
884 class ADeferredMethPropdef
885 super AMethPropdef
886 end
887
888 # A method marked intern
889 class AInternMethPropdef
890 super AMethPropdef
891 end
892
893 # A method of a constructor marked extern
894 abstract class AExternPropdef
895 super AMethPropdef
896 end
897
898 # A method marked extern
899 class AExternMethPropdef
900 super AExternPropdef
901 end
902
903 # A method with a body
904 class AConcreteMethPropdef
905 super AMethPropdef
906 end
907
908 # A constructor
909 abstract class AInitPropdef
910 super AMethPropdef
911 end
912
913 # A constructor with a body
914 class AConcreteInitPropdef
915 super AConcreteMethPropdef
916 super AInitPropdef
917 end
918
919 class AInternNewPropdef
920 super AInternMethPropdef
921 super AInitPropdef
922 end
923
924 # A constructor marked extern (defined with the `new` keyword)
925 class AExternInitPropdef
926 super AExternPropdef
927 super AInitPropdef
928 end
929
930 # The implicit main method
931 class AMainMethPropdef
932 super AConcreteMethPropdef
933 end
934
935 # Declaration of callbacks for extern methods
936 class AExternCalls
937 super Prod
938 var n_kwimport: TKwimport is writable, noinit
939 var n_extern_calls: ANodes[AExternCall] = new ANodes[AExternCall](self)
940 end
941 abstract class AExternCall
942 super Prod
943 end
944 abstract class APropExternCall
945 super AExternCall
946 end
947 class ALocalPropExternCall
948 super APropExternCall
949 var n_methid: AMethid is writable, noinit
950 end
951 class AFullPropExternCall
952 super APropExternCall
953 var n_type: AType is writable, noinit
954 var n_dot: nullable TDot = null is writable
955 var n_methid: AMethid is writable, noinit
956 end
957 class AInitPropExternCall
958 super APropExternCall
959 var n_type: AType is writable, noinit
960 end
961 class ASuperExternCall
962 super AExternCall
963 var n_kwsuper: TKwsuper is writable, noinit
964 end
965 abstract class ACastExternCall
966 super AExternCall
967 end
968 class ACastAsExternCall
969 super ACastExternCall
970 var n_from_type: AType is writable, noinit
971 var n_dot: nullable TDot = null is writable
972 var n_kwas: TKwas is writable, noinit
973 var n_to_type: AType is writable, noinit
974 end
975 class AAsNullableExternCall
976 super ACastExternCall
977 var n_type: AType is writable, noinit
978 var n_kwas: TKwas is writable, noinit
979 var n_kwnullable: TKwnullable is writable, noinit
980 end
981 class AAsNotNullableExternCall
982 super ACastExternCall
983 var n_type: AType is writable, noinit
984 var n_kwas: TKwas is writable, noinit
985 var n_kwnot: TKwnot is writable, noinit
986 var n_kwnullable: TKwnullable is writable, noinit
987 end
988
989 # A definition of a virtual type
990 class ATypePropdef
991 super APropdef
992 var n_kwtype: TKwtype is writable, noinit
993 var n_id: TClassid is writable, noinit
994 var n_type: AType is writable, noinit
995 end
996
997 # A `writable` or `readable` modifier
998 abstract class AAble
999 super Prod
1000 var n_visibility: nullable AVisibility = null is writable
1001 var n_kwredef: nullable TKwredef = null is writable
1002 end
1003
1004 # A `readable` modifier
1005 class AReadAble
1006 super AAble
1007 var n_kwreadable: TKwreadable is writable, noinit
1008 end
1009
1010 # A `writable` modifier
1011 class AWriteAble
1012 super AAble
1013 var n_kwwritable: TKwwritable is writable, noinit
1014 end
1015
1016 # The identifier of a method in a method declaration.
1017 # There is a specific class because of operator and setters.
1018 abstract class AMethid
1019 super Prod
1020 end
1021 class AIdMethid
1022 super AMethid
1023 var n_id: TId is writable, noinit
1024 end
1025 class APlusMethid
1026 super AMethid
1027 var n_plus: TPlus is writable, noinit
1028 end
1029 class AMinusMethid
1030 super AMethid
1031 var n_minus: TMinus is writable, noinit
1032 end
1033 class AStarMethid
1034 super AMethid
1035 var n_star: TStar is writable, noinit
1036 end
1037 class AStarstarMethid
1038 super AMethid
1039 var n_starstar: TStarstar is writable, noinit
1040 end
1041 class ASlashMethid
1042 super AMethid
1043 var n_slash: TSlash is writable, noinit
1044 end
1045 class APercentMethid
1046 super AMethid
1047 var n_percent: TPercent is writable, noinit
1048 end
1049 class AEqMethid
1050 super AMethid
1051 var n_eq: TEq is writable, noinit
1052 end
1053 class ANeMethid
1054 super AMethid
1055 var n_ne: TNe is writable, noinit
1056 end
1057 class ALeMethid
1058 super AMethid
1059 var n_le: TLe is writable, noinit
1060 end
1061 class AGeMethid
1062 super AMethid
1063 var n_ge: TGe is writable, noinit
1064 end
1065 class ALtMethid
1066 super AMethid
1067 var n_lt: TLt is writable, noinit
1068 end
1069 class AGtMethid
1070 super AMethid
1071 var n_gt: TGt is writable, noinit
1072 end
1073 class ALlMethid
1074 super AMethid
1075 var n_ll: TLl is writable, noinit
1076 end
1077 class AGgMethid
1078 super AMethid
1079 var n_gg: TGg is writable, noinit
1080 end
1081 class ABraMethid
1082 super AMethid
1083 var n_obra: TObra is writable, noinit
1084 var n_cbra: TCbra is writable, noinit
1085 end
1086 class AStarshipMethid
1087 super AMethid
1088 var n_starship: TStarship is writable, noinit
1089 end
1090 class AAssignMethid
1091 super AMethid
1092 var n_id: TId is writable, noinit
1093 var n_assign: TAssign is writable, noinit
1094 end
1095 class ABraassignMethid
1096 super AMethid
1097 var n_obra: TObra is writable, noinit
1098 var n_cbra: TCbra is writable, noinit
1099 var n_assign: TAssign is writable, noinit
1100 end
1101
1102 # A signature in a method definition. eg `(x,y:X,z:Z):T`
1103 class ASignature
1104 super Prod
1105 var n_opar: nullable TOpar = null is writable
1106 var n_params: ANodes[AParam] = new ANodes[AParam](self)
1107 var n_cpar: nullable TCpar = null is writable
1108 var n_type: nullable AType = null is writable
1109 end
1110
1111 # A parameter definition in a signature. eg `x:X`
1112 class AParam
1113 super Prod
1114 var n_id: TId is writable, noinit
1115 var n_type: nullable AType = null is writable
1116 var n_dotdotdot: nullable TDotdotdot = null is writable
1117 end
1118
1119 # A static type. eg `nullable X[Y]`
1120 class AType
1121 super Prod
1122 var n_kwnullable: nullable TKwnullable = null is writable
1123
1124 # The name of the class or of the formal type
1125 var n_id: TClassid is writable, noinit
1126
1127 # Type arguments for a generic type
1128 var n_types: ANodes[AType] = new ANodes[AType](self)
1129 end
1130
1131 # A label at the end of a block or in a break/continue statement. eg `label x`
1132 class ALabel
1133 super Prod
1134 var n_kwlabel: TKwlabel is writable, noinit
1135 var n_id: nullable TId is writable
1136 end
1137
1138 # Expression and statements
1139 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1140 abstract class AExpr
1141 super Prod
1142 end
1143
1144 # A sequence of AExpr (usually statements)
1145 # The last AExpr gives the value of the whole block
1146 class ABlockExpr
1147 super AExpr
1148 var n_expr: ANodes[AExpr] = new ANodes[AExpr](self)
1149 var n_kwend: nullable TKwend = null is writable
1150 end
1151
1152 # A declaration of a local variable. eg `var x: X = y`
1153 class AVardeclExpr
1154 super AExpr
1155 var n_kwvar: TKwvar is writable, noinit
1156 var n_id: TId is writable, noinit
1157 var n_type: nullable AType = null is writable
1158 var n_assign: nullable TAssign = null is writable
1159
1160 # The initial value, if any
1161 var n_expr: nullable AExpr = null is writable
1162 end
1163
1164 # A `return` statement. eg `return x`
1165 class AReturnExpr
1166 super AExpr
1167 var n_kwreturn: nullable TKwreturn = null is writable
1168 var n_expr: nullable AExpr = null is writable
1169 end
1170
1171 # Something that has a label.
1172 abstract class ALabelable
1173 super Prod
1174 var n_label: nullable ALabel = null is writable
1175 end
1176
1177 # A `break` statement.
1178 class ABreakExpr
1179 super AExpr
1180 super ALabelable
1181 var n_kwbreak: TKwbreak is writable, noinit
1182 var n_expr: nullable AExpr = null is writable
1183 end
1184
1185 # An `abort` statement
1186 class AAbortExpr
1187 super AExpr
1188 var n_kwabort: TKwabort is writable, noinit
1189 end
1190
1191 # A `continue` statement
1192 class AContinueExpr
1193 super AExpr
1194 super ALabelable
1195 var n_kwcontinue: nullable TKwcontinue = null is writable
1196 var n_expr: nullable AExpr = null is writable
1197 end
1198
1199 # A `do` statement
1200 class ADoExpr
1201 super AExpr
1202 super ALabelable
1203 var n_kwdo: TKwdo is writable, noinit
1204 var n_block: nullable AExpr = null is writable
1205 end
1206
1207 # A `if` statement
1208 class AIfExpr
1209 super AExpr
1210 var n_kwif: TKwif is writable, noinit
1211 var n_expr: AExpr is writable, noinit
1212 var n_then: nullable AExpr = null is writable
1213 var n_else: nullable AExpr = null is writable
1214 end
1215
1216 # A `if` expression
1217 class AIfexprExpr
1218 super AExpr
1219 var n_kwif: TKwif is writable, noinit
1220 var n_expr: AExpr is writable, noinit
1221 var n_kwthen: TKwthen is writable, noinit
1222 var n_then: AExpr is writable, noinit
1223 var n_kwelse: TKwelse is writable, noinit
1224 var n_else: AExpr is writable, noinit
1225 end
1226
1227 # A `while` statement
1228 class AWhileExpr
1229 super AExpr
1230 super ALabelable
1231 var n_kwwhile: TKwwhile is writable, noinit
1232 var n_expr: AExpr is writable, noinit
1233 var n_kwdo: TKwdo is writable, noinit
1234 var n_block: nullable AExpr = null is writable
1235 end
1236
1237 # A `loop` statement
1238 class ALoopExpr
1239 super AExpr
1240 super ALabelable
1241 var n_kwloop: TKwloop is writable, noinit
1242 var n_block: nullable AExpr = null is writable
1243 end
1244
1245 # A `for` statement
1246 class AForExpr
1247 super AExpr
1248 super ALabelable
1249 var n_kwfor: TKwfor is writable, noinit
1250 var n_ids: ANodes[TId] = new ANodes[TId](self)
1251 var n_expr: AExpr is writable, noinit
1252 var n_kwdo: TKwdo is writable, noinit
1253 var n_block: nullable AExpr = null is writable
1254 end
1255
1256 # An `assert` statement
1257 class AAssertExpr
1258 super AExpr
1259 var n_kwassert: TKwassert is writable, noinit
1260 var n_id: nullable TId = null is writable
1261 var n_expr: AExpr is writable, noinit
1262 var n_else: nullable AExpr = null is writable
1263 end
1264
1265 # Whatever is a simple assignment. eg `= something`
1266 abstract class AAssignFormExpr
1267 super AExpr
1268 var n_assign: TAssign is writable, noinit
1269 var n_value: AExpr is writable, noinit
1270 end
1271
1272 # Whatever is a combined assignment. eg `+= something`
1273 abstract class AReassignFormExpr
1274 super AExpr
1275 var n_assign_op: AAssignOp is writable, noinit
1276 var n_value: AExpr is writable, noinit
1277 end
1278
1279 # A `once` expression. eg `once x`
1280 class AOnceExpr
1281 super AProxyExpr
1282 var n_kwonce: TKwonce is writable, noinit
1283 end
1284
1285 # A polymorphic invocation of a method
1286 # The form of the invocation (name, arguments, etc) are specific
1287 abstract class ASendExpr
1288 super AExpr
1289 # The receiver of the method invocation
1290 var n_expr: AExpr is writable, noinit
1291 end
1292
1293 # A binary operation on a method
1294 abstract class ABinopExpr
1295 super ASendExpr
1296 # The second operand of the operation
1297 # Note: the receiver (`n_expr`) is the first operand
1298 var n_expr2: AExpr is writable, noinit
1299 end
1300
1301 # Something that is boolean expression
1302 abstract class ABoolExpr
1303 super AExpr
1304 end
1305
1306 # A `or` expression
1307 class AOrExpr
1308 super ABoolExpr
1309 var n_expr: AExpr is writable, noinit
1310 var n_expr2: AExpr is writable, noinit
1311 end
1312
1313 # A `and` expression
1314 class AAndExpr
1315 super ABoolExpr
1316 var n_expr: AExpr is writable, noinit
1317 var n_expr2: AExpr is writable, noinit
1318 end
1319
1320 # A `or else` expression
1321 class AOrElseExpr
1322 super ABoolExpr
1323 var n_expr: AExpr is writable, noinit
1324 var n_expr2: AExpr is writable, noinit
1325 end
1326
1327 # A `implies` expression
1328 class AImpliesExpr
1329 super ABoolExpr
1330 var n_expr: AExpr is writable, noinit
1331 var n_expr2: AExpr is writable, noinit
1332 end
1333
1334 # A `not` expression
1335 class ANotExpr
1336 super ABoolExpr
1337 var n_kwnot: TKwnot is writable, noinit
1338 var n_expr: AExpr is writable, noinit
1339 end
1340
1341 # A `==` expression
1342 class AEqExpr
1343 super ABinopExpr
1344 end
1345
1346 # A `!=` expression
1347 class ANeExpr
1348 super ABinopExpr
1349 end
1350
1351 # A `<` expression
1352 class ALtExpr
1353 super ABinopExpr
1354 end
1355
1356 # A `<=` expression
1357 class ALeExpr
1358 super ABinopExpr
1359 end
1360
1361 # A `<<` expression
1362 class ALlExpr
1363 super ABinopExpr
1364 end
1365
1366 # A `>` expression
1367 class AGtExpr
1368 super ABinopExpr
1369 end
1370
1371 # A `>=` expression
1372 class AGeExpr
1373 super ABinopExpr
1374 end
1375
1376 # A `>>` expression
1377 class AGgExpr
1378 super ABinopExpr
1379 end
1380
1381 # A type-ckeck expression. eg `x isa T`
1382 class AIsaExpr
1383 super ABoolExpr
1384 var n_expr: AExpr is writable, noinit
1385 var n_type: AType is writable, noinit
1386 end
1387
1388 # A `+` expression
1389 class APlusExpr
1390 super ABinopExpr
1391 end
1392
1393 # A `-` expression
1394 class AMinusExpr
1395 super ABinopExpr
1396 end
1397
1398 # A `<=>` expression
1399 class AStarshipExpr
1400 super ABinopExpr
1401 end
1402
1403 # A `*` expression
1404 class AStarExpr
1405 super ABinopExpr
1406 end
1407
1408 # A `**` expression
1409 class AStarstarExpr
1410 super ABinopExpr
1411 end
1412
1413 # A `/` expression
1414 class ASlashExpr
1415 super ABinopExpr
1416 end
1417
1418 # A `%` expression
1419 class APercentExpr
1420 super ABinopExpr
1421 end
1422
1423 # A unary minus expression. eg `-x`
1424 class AUminusExpr
1425 super ASendExpr
1426 var n_minus: TMinus is writable, noinit
1427 end
1428
1429 # An explicit instantiation. eg `new T`
1430 class ANewExpr
1431 super AExpr
1432 var n_kwnew: TKwnew is writable, noinit
1433 var n_type: AType is writable, noinit
1434
1435 # The name of the named-constructor, if any
1436 var n_id: nullable TId = null is writable
1437 var n_args: AExprs is writable, noinit
1438 end
1439
1440 # Whatever is a old-style attribute access
1441 abstract class AAttrFormExpr
1442 super AExpr
1443
1444 # The receiver of the attribute
1445 var n_expr: AExpr is writable, noinit
1446
1447 # The name of the attribute
1448 var n_id: TAttrid is writable, noinit
1449
1450 end
1451
1452 # The read of an attribute. eg `x._a`
1453 class AAttrExpr
1454 super AAttrFormExpr
1455 end
1456
1457 # The assignment of an attribute. eg `x._a=y`
1458 class AAttrAssignExpr
1459 super AAttrFormExpr
1460 super AAssignFormExpr
1461 end
1462
1463 # Whatever looks-like a call with a standard method and any number of arguments.
1464 abstract class ACallFormExpr
1465 super ASendExpr
1466
1467 # The name of the method
1468 var n_id: TId is writable, noinit
1469
1470 # The arguments of the call
1471 var n_args: AExprs is writable, noinit
1472 end
1473
1474 # A complex setter call (standard or brackets)
1475 abstract class ASendReassignFormExpr
1476 super ASendExpr
1477 super AReassignFormExpr
1478 end
1479
1480 # A complex attribute assignment. eg `x._a+=y`
1481 class AAttrReassignExpr
1482 super AAttrFormExpr
1483 super AReassignFormExpr
1484 end
1485
1486 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
1487 # 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`.
1488 # Semantic analysis have to transform them to instance of `AVarExpr`.
1489 class ACallExpr
1490 super ACallFormExpr
1491 end
1492
1493 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
1494 # 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`.
1495 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
1496 class ACallAssignExpr
1497 super ACallFormExpr
1498 super AAssignFormExpr
1499 end
1500
1501 # 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.
1502 # Note: because the parser cannot distinguish a variable write with a compex setter call with an implicit receiver and no arguments, it always returns a `ACallReassignExpr`.
1503 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
1504 class ACallReassignExpr
1505 super ACallFormExpr
1506 super ASendReassignFormExpr
1507 end
1508
1509 # A call to `super`. OR a call of a super-constructor
1510 class ASuperExpr
1511 super AExpr
1512 var n_qualified: nullable AQualified = null is writable
1513 var n_kwsuper: TKwsuper is writable, noinit
1514 var n_args: AExprs is writable, noinit
1515 end
1516
1517 # A call to the `init` constructor.
1518 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a ACallFormExpr.
1519 class AInitExpr
1520 super ASendExpr
1521 var n_kwinit: TKwinit is writable, noinit
1522 var n_args: AExprs is writable, noinit
1523 end
1524
1525 # Whatever looks-like a call of the brackets `[]` operator.
1526 abstract class ABraFormExpr
1527 super ASendExpr
1528 var n_args: AExprs is writable, noinit
1529 end
1530
1531 # A call of the brackets operator. eg `x[y,z]`
1532 class ABraExpr
1533 super ABraFormExpr
1534 end
1535
1536 # A setter call of the bracket operator. eg `x[y,z]=t`
1537 class ABraAssignExpr
1538 super ABraFormExpr
1539 super AAssignFormExpr
1540 end
1541
1542 # Whatever is an access to a local variable
1543 abstract class AVarFormExpr
1544 super AExpr
1545 var n_id: TId is writable, noinit
1546 end
1547
1548 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
1549 class ABraReassignExpr
1550 super ABraFormExpr
1551 super ASendReassignFormExpr
1552 end
1553
1554 # A local variable read access.
1555 # The parser cannot instantiate them, see `ACallExpr`.
1556 class AVarExpr
1557 super AVarFormExpr
1558 end
1559
1560 # A local variable simple assigment access
1561 # The parser cannot instantiate them, see `ACallAssignExpr`.
1562 class AVarAssignExpr
1563 super AVarFormExpr
1564 super AAssignFormExpr
1565 end
1566
1567 # A local variable complex assignment access
1568 # The parser cannot instantiate them, see `ACallReassignExpr`.
1569 class AVarReassignExpr
1570 super AVarFormExpr
1571 super AReassignFormExpr
1572 end
1573
1574 # A literal range, open or closed
1575 abstract class ARangeExpr
1576 super AExpr
1577 var n_expr: AExpr is writable, noinit
1578 var n_expr2: AExpr is writable, noinit
1579 end
1580
1581 # A closed literal range. eg `[x..y]`
1582 class ACrangeExpr
1583 super ARangeExpr
1584 var n_obra: TObra is writable, noinit
1585 var n_cbra: TCbra is writable, noinit
1586 end
1587
1588 # An open literal range. eg `[x..y[`
1589 class AOrangeExpr
1590 super ARangeExpr
1591 var n_obra: TObra is writable, noinit
1592 var n_cbra: TObra is writable, noinit
1593 end
1594
1595 # A literal array. eg. `[x,y,z]`
1596 class AArrayExpr
1597 super AExpr
1598 var n_exprs: AExprs is writable, noinit
1599 end
1600
1601 # A read of `self`
1602 class ASelfExpr
1603 super AExpr
1604 var n_kwself: nullable TKwself is writable
1605 end
1606
1607 # When there is no explicit receiver, `self` is implicit
1608 class AImplicitSelfExpr
1609 super ASelfExpr
1610 end
1611
1612 # A `true` boolean literal constant
1613 class ATrueExpr
1614 super ABoolExpr
1615 var n_kwtrue: TKwtrue is writable, noinit
1616 end
1617 # A `false` boolean literal constant
1618 class AFalseExpr
1619 super ABoolExpr
1620 var n_kwfalse: TKwfalse is writable, noinit
1621 end
1622 # A `null` literal constant
1623 class ANullExpr
1624 super AExpr
1625 var n_kwnull: TKwnull is writable, noinit
1626 end
1627 # An integer literal
1628 class AIntExpr
1629 super AExpr
1630 end
1631 # An integer literal in decimal format
1632 class ADecIntExpr
1633 super AIntExpr
1634 var n_number: TNumber is writable, noinit
1635 end
1636 # An integer literal in hexadecimal format
1637 class AHexIntExpr
1638 super AIntExpr
1639 var n_hex_number: THexNumber is writable, noinit
1640 end
1641 # A float literal
1642 class AFloatExpr
1643 super AExpr
1644 var n_float: TFloat is writable, noinit
1645 end
1646 # A character literal
1647 class ACharExpr
1648 super AExpr
1649 var n_char: TChar is writable, noinit
1650 end
1651 # A string literal
1652 abstract class AStringFormExpr
1653 super AExpr
1654 var n_string: Token is writable, noinit
1655 end
1656
1657 # A simple string. eg. `"abc"`
1658 class AStringExpr
1659 super AStringFormExpr
1660 end
1661
1662 # The start of a superstring. eg `"abc{`
1663 class AStartStringExpr
1664 super AStringFormExpr
1665 end
1666
1667 # The middle of a superstring. eg `}abc{`
1668 class AMidStringExpr
1669 super AStringFormExpr
1670 end
1671
1672 # The end of a superstrng. eg `}abc"`
1673 class AEndStringExpr
1674 super AStringFormExpr
1675 end
1676
1677 # A superstring literal. eg `"a{x}b{y}c"`
1678 # Each part is modelized a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
1679 class ASuperstringExpr
1680 super AExpr
1681 var n_exprs: ANodes[AExpr] = new ANodes[AExpr](self)
1682 end
1683
1684 # A simple parenthesis. eg `(x)`
1685 class AParExpr
1686 super AProxyExpr
1687 var n_opar: TOpar is writable, noinit
1688 var n_cpar: TCpar is writable, noinit
1689 end
1690
1691 # Whatevej just contains (and mimic) an other expression
1692 abstract class AProxyExpr
1693 super AExpr
1694 var n_expr: AExpr is writable, noinit
1695 end
1696
1697 # A type cast. eg `x.as(T)`
1698 class AAsCastExpr
1699 super AExpr
1700 var n_expr: AExpr is writable, noinit
1701 var n_kwas: TKwas is writable, noinit
1702 var n_opar: nullable TOpar = null is writable
1703 var n_type: AType is writable, noinit
1704 var n_cpar: nullable TCpar = null is writable
1705 end
1706
1707 # A as-not-null cast. eg `x.as(not null)`
1708 class AAsNotnullExpr
1709 super AExpr
1710 var n_expr: AExpr is writable, noinit
1711 var n_kwas: TKwas is writable, noinit
1712 var n_opar: nullable TOpar = null is writable
1713 var n_kwnot: TKwnot is writable, noinit
1714 var n_kwnull: TKwnull is writable, noinit
1715 var n_cpar: nullable TCpar = null is writable
1716 end
1717
1718 # A is-set check of old-style attributes. eg `isset x._a`
1719 class AIssetAttrExpr
1720 super AAttrFormExpr
1721 var n_kwisset: TKwisset is writable, noinit
1722 end
1723
1724 # A elyspis notation used to pass an expression as it in a vararg parameter
1725 class AVarargExpr
1726 super AExpr
1727 var n_expr: AExpr is writable, noinit
1728 var n_dotdotdot: TDotdotdot is writable, noinit
1729 end
1730
1731 # A list of expression separated with commas (arguments for instance)
1732 abstract class AExprs
1733 super Prod
1734 var n_exprs: ANodes[AExpr] = new ANodes[AExpr](self)
1735 end
1736
1737
1738 class ADebugTypeExpr
1739 super AExpr
1740 var n_kwdebug: TKwdebug is writable, noinit
1741 var n_kwtype: TKwtype is writable, noinit
1742 var n_expr: AExpr is writable, noinit
1743 var n_type: AType is writable, noinit
1744 end
1745
1746 # A simple list of expressions
1747 class AListExprs
1748 super AExprs
1749 end
1750
1751 # A list of expressions enclosed in parentheses
1752 class AParExprs
1753 super AExprs
1754 var n_opar: TOpar is writable, noinit
1755 var n_cpar: TCpar is writable, noinit
1756 end
1757
1758 # A list of expressions enclosed in brackets
1759 class ABraExprs
1760 super AExprs
1761 var n_obra: TObra is writable, noinit
1762 var n_cbra: TCbra is writable, noinit
1763 end
1764
1765 # A complex assignment operator. eg `+=`
1766 abstract class AAssignOp
1767 super Prod
1768 end
1769 class APlusAssignOp
1770 super AAssignOp
1771 var n_pluseq: TPluseq is writable, noinit
1772 end
1773 class AMinusAssignOp
1774 super AAssignOp
1775 var n_minuseq: TMinuseq is writable, noinit
1776 end
1777
1778 class AModuleName
1779 super Prod
1780 var n_quad: nullable TQuad = null is writable
1781 var n_path: ANodes[TId] = new ANodes[TId](self)
1782 var n_id: TId is writable, noinit
1783 end
1784 class AInLanguage
1785 super Prod
1786 var n_kwin: TKwin is writable, noinit
1787 var n_string: TString is writable, noinit
1788 end
1789 class AExternCodeBlock
1790 super Prod
1791 var n_in_language: nullable AInLanguage = null is writable
1792 var n_extern_code_segment: TExternCodeSegment is writable, noinit
1793 end
1794 class AQualified
1795 super Prod
1796 var n_quad: nullable TQuad = null is writable
1797 var n_id: ANodes[TId] = new ANodes[TId](self)
1798 var n_classid: nullable TClassid = null is writable
1799 end
1800
1801 # A documentation of a definition
1802 # It contains the block of comments just above the declaration
1803 class ADoc
1804 super Prod
1805 var n_comment: ANodes[TComment] = new ANodes[TComment](self)
1806 end
1807
1808 class AAnnotations
1809 super Prod
1810 var n_at: nullable TAt = null is writable
1811 var n_opar: nullable TOpar = null is writable
1812 var n_items: ANodes[AAnnotation] = new ANodes[AAnnotation](self)
1813 var n_cpar: nullable TCpar = null is writable
1814 end
1815 class AAnnotation
1816 super Prod
1817 var n_doc: nullable ADoc = null is writable
1818 var n_kwredef: nullable TKwredef = null is writable
1819 var n_visibility: nullable AVisibility is writable
1820 var n_atid: AAtid is writable, noinit
1821 var n_opar: nullable TOpar = null is writable
1822 var n_args: ANodes[AAtArg] = new ANodes[AAtArg](self)
1823 var n_cpar: nullable TCpar = null is writable
1824 end
1825 abstract class AAtArg
1826 super Prod
1827 end
1828 class ATypeAtArg
1829 super AAtArg
1830 var n_type: AType is writable, noinit
1831 end
1832 class AExprAtArg
1833 super AAtArg
1834 var n_expr: AExpr is writable, noinit
1835 end
1836 class AAtAtArg
1837 super AAtArg
1838 end
1839 abstract class AAtid
1840 super Prod
1841 var n_id: Token is writable, noinit
1842 end
1843 class AIdAtid
1844 super AAtid
1845 end
1846 class AKwexternAtid
1847 super AAtid
1848 end
1849 class AKwinternAtid
1850 super AAtid
1851 end
1852 class AKwreadableAtid
1853 super AAtid
1854 end
1855 class AKwwritableAtid
1856 super AAtid
1857 end
1858 class AKwimportAtid
1859 super AAtid
1860 end
1861 class AKwabstractAtid
1862 super AAtid
1863 end
1864
1865 # The root of the AST
1866 class Start
1867 super Prod
1868 var n_base: nullable AModule is writable
1869 var n_eof: EOF is writable, noinit
1870 init(n_base: nullable AModule, n_eof: EOF)
1871 do
1872 self._n_base = n_base
1873 self._n_eof = n_eof
1874 end
1875 end