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