1 # This file is part of NIT ( http://www.nitlanguage.org ).
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 # AST nodes of the Nit language
16 # Was previously based on parser_abs.nit.
21 # Root of the AST class-hierarchy
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
27 # The location of the important part of the node (identifier or whatever)
28 fun hot_location
: Location do return location
30 # Display a message for the colored location of the node
31 fun debug
(message
: String)
33 sys
.stderr
.write
"{hot_location} {self.class_name}: {message}\n{hot_location.colored_line("0;32")}\n"
36 # Parent of the node in the AST
37 var parent
: nullable ANode = null
39 # The topmost ancestor of the element
40 # This just apply `parent` until the first one
46 if p
== null then return res
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
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
67 assert o
.depth
== s
.depth
68 # Second, go up until same in found
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`
85 if p
== null then return res
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
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
101 assert parent
!= null
102 parent
.replace_child
(self, null)
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)
112 assert parent
!= null
113 parent
.replace_child
(self, node
)
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
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]
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
149 var res
= items
.shift
161 redef fun []=(index
, e
)
163 hook_remove
(self[index
])
167 redef fun remove_at
(index
)
169 hook_remove
(items
[index
])
170 items
.remove_at
(index
)
172 private fun hook_add
(e
: E
)
174 #assert e.parent == null
177 private fun hook_remove
(e
: E
)
179 assert e
.parent
== parent
183 # Used in parent contructor to fill elements
184 private fun unsafe_add_all
(nodes
: Collection[Object])
186 var parent
= self.parent
194 private fun replace_child
(old_child
: ANode, new_child
: nullable ANode): Bool
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
202 new_child
.parent
= parent
212 private fun visit_all
(v
: Visitor)
214 for n
in self do v
.enter_visit
(n
)
218 # Ancestor of all tokens
219 # A token is a node that has a `text` but no children.
223 # The raw content on the token
224 fun text
: String is abstract
225 fun text
=(text
: String) is abstract
227 # The previous token in the Lexer.
228 # May have disapeared in the AST
229 var prev_token
: nullable Token = null
231 # The next token in the Lexer.
232 # May have disapeared in the AST
233 var next_token
: nullable Token = null
235 # The verbatim blank text between `prev_token` and `self`
236 fun blank_before
: String
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
)
244 redef fun to_s
: String do
248 redef fun visit_all
(v
: Visitor) do end
249 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode) do end
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
257 # The first token parser by the lexer
258 # May have disapeared in the final AST
259 var last_token
: nullable Token = null
262 # Ancestor of all productions
263 # A production is a node without text but that usually has children.
267 # All the annotations attached directly to the node
268 var n_annotations
: nullable AAnnotations = null is writable
270 redef fun replace_with
(n
: ANode)
274 if not isset n
._location
and isset _location
then n
._location
= _location
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.
283 protected fun visit
(e
: ANode) is abstract
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)
290 if e
== null then return
291 var old
= _current_node
297 # The current visited node
298 var current_node
: nullable ANode = null is writable
301 # Token of end of line (basically `\n`)
310 # Token of a line of comments
311 # Starts with the `#` and contains the final end-of-line (if any)
316 # A token associated with a keyword
317 abstract class TokenKeyword
321 return "keyword '{text}'"
496 # A token associated with an operator (and other lookalike symbols)
497 abstract class TokenOperator
501 return "operator '{text}'"
571 # A class (or formal type) identifier. They start with an uppercase.
576 do return "type identifier '{text}'"
580 # A standard identifier (variable, method...). They start with a lowercase.
585 do return "identifier '{text}'"
589 # An attribute identifier. They start with an underscore.
594 do return "attribute '{text}'"
598 # A token of a literal value (string, integer, etc).
599 abstract class TokenLiteral
603 do return "literal value '{text}'"
636 do return "malformed string {text}"
645 do return "malformed character {text}"
649 class TExternCodeSegment
673 # The main node of a Nit source-file
677 var n_moduledecl
: nullable AModuledecl = null is writable
678 var n_imports
: ANodes[AImport] = new ANodes[AImport](self)
679 var n_extern_code_blocks
: ANodes[AExternCodeBlock] = new ANodes[AExternCodeBlock](self)
680 var n_classdefs
: ANodes[AClassdef] = new ANodes[AClassdef](self)
683 # The declaration of the module with the documentation, name, and annotations
686 var n_doc
: nullable ADoc = null is writable
687 var n_kwredef
: nullable TKwredef = null is writable
688 var n_visibility
: AVisibility is writable, noinit
689 var n_kwmodule
: TKwmodule is writable, noinit
690 var n_name
: AModuleName is writable, noinit
693 # A import clause of a module
694 abstract class AImport
698 # A standard import clause. eg `import x`
701 var n_visibility
: AVisibility is writable, noinit
702 var n_kwimport
: TKwimport is writable, noinit
703 var n_name
: AModuleName is writable, noinit
706 # The special import clause of the kernel module. eg `import end`
709 var n_visibility
: AVisibility is writable, noinit
710 var n_kwimport
: TKwimport is writable, noinit
711 var n_kwend
: TKwend is writable, noinit
714 # A visibility modifier
716 # The public visibility is an empty production (no keyword).
718 # Note: even if some visibilities are only valid on some placse (for instance, no `protected` class or no `intrude` method)
719 # the parser has no such a restriction, therefore the semantic phases has to check that the visibilities make sense.
720 abstract class AVisibility
723 class APublicVisibility
725 var n_kwpublic
: nullable TKwpublic is writable
727 class APrivateVisibility
729 var n_kwprivate
: TKwprivate is writable, noinit
731 class AProtectedVisibility
733 var n_kwprotected
: TKwprotected is writable, noinit
735 class AIntrudeVisibility
737 var n_kwintrude
: TKwintrude is writable, noinit
741 # While most definition are `AStdClassdef`
742 # There is tow special case of class definition
743 abstract class AClassdef
745 var n_propdefs
: ANodes[APropdef] = new ANodes[APropdef](self)
748 # A standard class definition with a name, superclasses and properties
751 var n_doc
: nullable ADoc = null is writable
752 var n_kwredef
: nullable TKwredef = null is writable
753 var n_visibility
: AVisibility is writable, noinit
754 var n_classkind
: AClasskind is writable, noinit
755 var n_id
: nullable TClassid = null is writable
756 var n_formaldefs
: ANodes[AFormaldef] = new ANodes[AFormaldef](self)
757 var n_extern_code_block
: nullable AExternCodeBlock = null is writable
758 var n_superclasses
: ANodes[ASuperclass] = new ANodes[ASuperclass](self)
759 var n_kwend
: TKwend is writable, noinit
760 redef fun hot_location
do return n_id
.location
763 # The implicit class definition of the implicit main method
768 # The implicit class definition of the top-level methods
773 # The modifier for the kind of class (abstract, interface, etc.)
774 abstract class AClasskind
777 class AConcreteClasskind
779 var n_kwclass
: TKwclass is writable, noinit
781 class AAbstractClasskind
783 var n_kwabstract
: TKwabstract is writable, noinit
784 var n_kwclass
: TKwclass is writable, noinit
786 class AInterfaceClasskind
788 var n_kwinterface
: TKwinterface is writable, noinit
792 var n_kwenum
: TKwenum is writable, noinit
794 class AExternClasskind
796 var n_kwextern
: TKwextern is writable, noinit
797 var n_kwclass
: nullable TKwclass = null is writable
800 # The definition of a formal generic parameter type. eg `X: Y`
803 var n_id
: TClassid is writable, noinit
804 # The bound of the parameter type
805 var n_type
: nullable AType = null is writable
808 # A super-class. eg `super X`
811 var n_kwsuper
: TKwsuper is writable, noinit
812 var n_type
: AType is writable, noinit
815 # The definition of a property
816 abstract class APropdef
818 var n_doc
: nullable ADoc = null is writable
819 var n_kwredef
: nullable TKwredef = null is writable
820 var n_visibility
: nullable AVisibility = null is writable
823 # A definition of an attribute
824 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
827 var n_kwvar
: TKwvar is writable, noinit
829 # The identifier for a new-style attribute (null if old-style)
830 var n_id2
: TId is writable, noinit
832 var n_type
: nullable AType = null is writable
834 # The initial value, if any
835 var n_expr
: nullable AExpr = null is writable
836 redef fun hot_location
838 return n_id2
.location
842 # A definition of all kind of method (including constructors)
845 var n_kwmeth
: nullable TKwmeth = null is writable
846 var n_kwinit
: nullable TKwinit = null is writable
847 var n_kwnew
: nullable TKwnew = null is writable
848 var n_methid
: nullable AMethid = null is writable
849 var n_signature
: nullable ASignature = null is writable
850 var n_block
: nullable AExpr = null is writable
851 var n_extern_calls
: nullable AExternCalls = null is writable
852 var n_extern_code_block
: nullable AExternCodeBlock = null is writable
853 redef fun hot_location
855 if n_methid
!= null then
856 return n_methid
.location
857 else if n_kwinit
!= null then
858 return n_kwinit
.location
859 else if n_kwnew
!= null then
860 return n_kwnew
.location
867 # The implicit main method
868 class AMainMethPropdef
872 # Declaration of callbacks for extern methods
875 var n_kwimport
: TKwimport is writable, noinit
876 var n_extern_calls
: ANodes[AExternCall] = new ANodes[AExternCall](self)
878 abstract class AExternCall
881 abstract class APropExternCall
884 class ALocalPropExternCall
885 super APropExternCall
886 var n_methid
: AMethid is writable, noinit
888 class AFullPropExternCall
889 super APropExternCall
890 var n_type
: AType is writable, noinit
891 var n_dot
: nullable TDot = null is writable
892 var n_methid
: AMethid is writable, noinit
894 class AInitPropExternCall
895 super APropExternCall
896 var n_type
: AType is writable, noinit
898 class ASuperExternCall
900 var n_kwsuper
: TKwsuper is writable, noinit
902 abstract class ACastExternCall
905 class ACastAsExternCall
906 super ACastExternCall
907 var n_from_type
: AType is writable, noinit
908 var n_dot
: nullable TDot = null is writable
909 var n_kwas
: TKwas is writable, noinit
910 var n_to_type
: AType is writable, noinit
912 class AAsNullableExternCall
913 super ACastExternCall
914 var n_type
: AType is writable, noinit
915 var n_kwas
: TKwas is writable, noinit
916 var n_kwnullable
: TKwnullable is writable, noinit
918 class AAsNotNullableExternCall
919 super ACastExternCall
920 var n_type
: AType is writable, noinit
921 var n_kwas
: TKwas is writable, noinit
922 var n_kwnot
: TKwnot is writable, noinit
923 var n_kwnullable
: TKwnullable is writable, noinit
926 # A definition of a virtual type
929 var n_kwtype
: TKwtype is writable, noinit
930 var n_id
: TClassid is writable, noinit
931 var n_type
: AType is writable, noinit
934 # The identifier of a method in a method declaration.
935 # There is a specific class because of operator and setters.
936 abstract class AMethid
941 var n_id
: TId is writable, noinit
945 var n_plus
: TPlus is writable, noinit
949 var n_minus
: TMinus is writable, noinit
953 var n_star
: TStar is writable, noinit
955 class AStarstarMethid
957 var n_starstar
: TStarstar is writable, noinit
961 var n_slash
: TSlash is writable, noinit
965 var n_percent
: TPercent is writable, noinit
969 var n_eq
: TEq is writable, noinit
973 var n_ne
: TNe is writable, noinit
977 var n_le
: TLe is writable, noinit
981 var n_ge
: TGe is writable, noinit
985 var n_lt
: TLt is writable, noinit
989 var n_gt
: TGt is writable, noinit
993 var n_ll
: TLl is writable, noinit
997 var n_gg
: TGg is writable, noinit
1001 var n_obra
: TObra is writable, noinit
1002 var n_cbra
: TCbra is writable, noinit
1004 class AStarshipMethid
1006 var n_starship
: TStarship is writable, noinit
1010 var n_id
: TId is writable, noinit
1011 var n_assign
: TAssign is writable, noinit
1013 class ABraassignMethid
1015 var n_obra
: TObra is writable, noinit
1016 var n_cbra
: TCbra is writable, noinit
1017 var n_assign
: TAssign is writable, noinit
1020 # A signature in a method definition. eg `(x,y:X,z:Z):T`
1023 var n_opar
: nullable TOpar = null is writable
1024 var n_params
: ANodes[AParam] = new ANodes[AParam](self)
1025 var n_cpar
: nullable TCpar = null is writable
1026 var n_type
: nullable AType = null is writable
1029 # A parameter definition in a signature. eg `x:X`
1032 var n_id
: TId is writable, noinit
1033 var n_type
: nullable AType = null is writable
1034 var n_dotdotdot
: nullable TDotdotdot = null is writable
1037 # A static type. eg `nullable X[Y]`
1040 var n_kwnullable
: nullable TKwnullable = null is writable
1042 # The name of the class or of the formal type
1043 var n_id
: TClassid is writable, noinit
1045 # Type arguments for a generic type
1046 var n_types
: ANodes[AType] = new ANodes[AType](self)
1049 # A label at the end of a block or in a break/continue statement. eg `label x`
1052 var n_kwlabel
: TKwlabel is writable, noinit
1053 var n_id
: nullable TId is writable
1056 # Expression and statements
1057 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1058 abstract class AExpr
1062 # A sequence of AExpr (usually statements)
1063 # The last AExpr gives the value of the whole block
1066 var n_expr
: ANodes[AExpr] = new ANodes[AExpr](self)
1067 var n_kwend
: nullable TKwend = null is writable
1070 # A declaration of a local variable. eg `var x: X = y`
1073 var n_kwvar
: TKwvar is writable, noinit
1074 var n_id
: TId is writable, noinit
1075 var n_type
: nullable AType = null is writable
1076 var n_assign
: nullable TAssign = null is writable
1078 # The initial value, if any
1079 var n_expr
: nullable AExpr = null is writable
1082 # A `return` statement. eg `return x`
1085 var n_kwreturn
: nullable TKwreturn = null is writable
1086 var n_expr
: nullable AExpr = null is writable
1089 # Something that has a label.
1090 abstract class ALabelable
1092 var n_label
: nullable ALabel = null is writable
1095 # A `break` statement.
1099 var n_kwbreak
: TKwbreak is writable, noinit
1100 var n_expr
: nullable AExpr = null is writable
1103 # An `abort` statement
1106 var n_kwabort
: TKwabort is writable, noinit
1109 # A `continue` statement
1113 var n_kwcontinue
: nullable TKwcontinue = null is writable
1114 var n_expr
: nullable AExpr = null is writable
1121 var n_kwdo
: TKwdo is writable, noinit
1122 var n_block
: nullable AExpr = null is writable
1128 var n_kwif
: TKwif is writable, noinit
1129 var n_expr
: AExpr is writable, noinit
1130 var n_then
: nullable AExpr = null is writable
1131 var n_else
: nullable AExpr = null is writable
1137 var n_kwif
: TKwif is writable, noinit
1138 var n_expr
: AExpr is writable, noinit
1139 var n_kwthen
: TKwthen is writable, noinit
1140 var n_then
: AExpr is writable, noinit
1141 var n_kwelse
: TKwelse is writable, noinit
1142 var n_else
: AExpr is writable, noinit
1145 # A `while` statement
1149 var n_kwwhile
: TKwwhile is writable, noinit
1150 var n_expr
: AExpr is writable, noinit
1151 var n_kwdo
: TKwdo is writable, noinit
1152 var n_block
: nullable AExpr = null is writable
1155 # A `loop` statement
1159 var n_kwloop
: TKwloop is writable, noinit
1160 var n_block
: nullable AExpr = null is writable
1167 var n_kwfor
: TKwfor is writable, noinit
1168 var n_ids
: ANodes[TId] = new ANodes[TId](self)
1169 var n_expr
: AExpr is writable, noinit
1170 var n_kwdo
: TKwdo is writable, noinit
1171 var n_block
: nullable AExpr = null is writable
1174 # An `assert` statement
1177 var n_kwassert
: TKwassert is writable, noinit
1178 var n_id
: nullable TId = null is writable
1179 var n_expr
: AExpr is writable, noinit
1180 var n_else
: nullable AExpr = null is writable
1183 # Whatever is a simple assignment. eg `= something`
1184 abstract class AAssignFormExpr
1186 var n_assign
: TAssign is writable, noinit
1187 var n_value
: AExpr is writable, noinit
1190 # Whatever is a combined assignment. eg `+= something`
1191 abstract class AReassignFormExpr
1193 var n_assign_op
: AAssignOp is writable, noinit
1194 var n_value
: AExpr is writable, noinit
1197 # A `once` expression. eg `once x`
1200 var n_kwonce
: TKwonce is writable, noinit
1203 # A polymorphic invocation of a method
1204 # The form of the invocation (name, arguments, etc) are specific
1205 abstract class ASendExpr
1207 # The receiver of the method invocation
1208 var n_expr
: AExpr is writable, noinit
1211 # A binary operation on a method
1212 abstract class ABinopExpr
1214 # The second operand of the operation
1215 # Note: the receiver (`n_expr`) is the first operand
1216 var n_expr2
: AExpr is writable, noinit
1219 # Something that is boolean expression
1220 abstract class ABoolExpr
1227 var n_expr
: AExpr is writable, noinit
1228 var n_expr2
: AExpr is writable, noinit
1231 # A `and` expression
1234 var n_expr
: AExpr is writable, noinit
1235 var n_expr2
: AExpr is writable, noinit
1238 # A `or else` expression
1241 var n_expr
: AExpr is writable, noinit
1242 var n_expr2
: AExpr is writable, noinit
1245 # A `implies` expression
1248 var n_expr
: AExpr is writable, noinit
1249 var n_expr2
: AExpr is writable, noinit
1252 # A `not` expression
1255 var n_kwnot
: TKwnot is writable, noinit
1256 var n_expr
: AExpr is writable, noinit
1299 # A type-ckeck expression. eg `x isa T`
1302 var n_expr
: AExpr is writable, noinit
1303 var n_type
: AType is writable, noinit
1316 # A `<=>` expression
1341 # A unary minus expression. eg `-x`
1344 var n_minus
: TMinus is writable, noinit
1347 # An explicit instantiation. eg `new T`
1350 var n_kwnew
: TKwnew is writable, noinit
1351 var n_type
: AType is writable, noinit
1353 # The name of the named-constructor, if any
1354 var n_id
: nullable TId = null is writable
1355 var n_args
: AExprs is writable, noinit
1358 # Whatever is a old-style attribute access
1359 abstract class AAttrFormExpr
1362 # The receiver of the attribute
1363 var n_expr
: AExpr is writable, noinit
1365 # The name of the attribute
1366 var n_id
: TAttrid is writable, noinit
1370 # The read of an attribute. eg `x._a`
1375 # The assignment of an attribute. eg `x._a=y`
1376 class AAttrAssignExpr
1378 super AAssignFormExpr
1381 # Whatever looks-like a call with a standard method and any number of arguments.
1382 abstract class ACallFormExpr
1385 # The name of the method
1386 var n_id
: TId is writable, noinit
1388 # The arguments of the call
1389 var n_args
: AExprs is writable, noinit
1392 # A complex setter call (standard or brackets)
1393 abstract class ASendReassignFormExpr
1395 super AReassignFormExpr
1398 # A complex attribute assignment. eg `x._a+=y`
1399 class AAttrReassignExpr
1401 super AReassignFormExpr
1404 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
1405 # 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`.
1406 # Semantic analysis have to transform them to instance of `AVarExpr`.
1411 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
1412 # 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`.
1413 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
1414 class ACallAssignExpr
1416 super AAssignFormExpr
1419 # 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.
1420 # 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`.
1421 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
1422 class ACallReassignExpr
1424 super ASendReassignFormExpr
1427 # A call to `super`. OR a call of a super-constructor
1430 var n_qualified
: nullable AQualified = null is writable
1431 var n_kwsuper
: TKwsuper is writable, noinit
1432 var n_args
: AExprs is writable, noinit
1435 # A call to the `init` constructor.
1436 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a ACallFormExpr.
1439 var n_kwinit
: TKwinit is writable, noinit
1440 var n_args
: AExprs is writable, noinit
1443 # Whatever looks-like a call of the brackets `[]` operator.
1444 abstract class ABraFormExpr
1446 var n_args
: AExprs is writable, noinit
1449 # A call of the brackets operator. eg `x[y,z]`
1454 # A setter call of the bracket operator. eg `x[y,z]=t`
1455 class ABraAssignExpr
1457 super AAssignFormExpr
1460 # Whatever is an access to a local variable
1461 abstract class AVarFormExpr
1463 var n_id
: TId is writable, noinit
1466 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
1467 class ABraReassignExpr
1469 super ASendReassignFormExpr
1472 # A local variable read access.
1473 # The parser cannot instantiate them, see `ACallExpr`.
1478 # A local variable simple assigment access
1479 # The parser cannot instantiate them, see `ACallAssignExpr`.
1480 class AVarAssignExpr
1482 super AAssignFormExpr
1485 # A local variable complex assignment access
1486 # The parser cannot instantiate them, see `ACallReassignExpr`.
1487 class AVarReassignExpr
1489 super AReassignFormExpr
1492 # A literal range, open or closed
1493 abstract class ARangeExpr
1495 var n_expr
: AExpr is writable, noinit
1496 var n_expr2
: AExpr is writable, noinit
1499 # A closed literal range. eg `[x..y]`
1502 var n_obra
: TObra is writable, noinit
1503 var n_cbra
: TCbra is writable, noinit
1506 # An open literal range. eg `[x..y[`
1509 var n_obra
: TObra is writable, noinit
1510 var n_cbra
: TObra is writable, noinit
1513 # A literal array. eg. `[x,y,z]`
1516 var n_obra
: TObra is writable, noinit
1517 var n_exprs
: AExprs is writable, noinit
1518 var n_type
: nullable AType = null is writable
1519 var n_cbra
: TCbra is writable, noinit
1525 var n_kwself
: nullable TKwself is writable
1528 # When there is no explicit receiver, `self` is implicit
1529 class AImplicitSelfExpr
1533 # A `true` boolean literal constant
1536 var n_kwtrue
: TKwtrue is writable, noinit
1538 # A `false` boolean literal constant
1541 var n_kwfalse
: TKwfalse is writable, noinit
1543 # A `null` literal constant
1546 var n_kwnull
: TKwnull is writable, noinit
1548 # An integer literal
1552 # An integer literal in decimal format
1555 var n_number
: TNumber is writable, noinit
1557 # An integer literal in hexadecimal format
1560 var n_hex_number
: THexNumber is writable, noinit
1565 var n_float
: TFloat is writable, noinit
1567 # A character literal
1570 var n_char
: TChar is writable, noinit
1573 abstract class AStringFormExpr
1575 var n_string
: Token is writable, noinit
1578 # A simple string. eg. `"abc"`
1580 super AStringFormExpr
1583 # The start of a superstring. eg `"abc{`
1584 class AStartStringExpr
1585 super AStringFormExpr
1588 # The middle of a superstring. eg `}abc{`
1589 class AMidStringExpr
1590 super AStringFormExpr
1593 # The end of a superstrng. eg `}abc"`
1594 class AEndStringExpr
1595 super AStringFormExpr
1598 # A superstring literal. eg `"a{x}b{y}c"`
1599 # Each part is modelized a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
1600 class ASuperstringExpr
1602 var n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1605 # A simple parenthesis. eg `(x)`
1608 var n_opar
: TOpar is writable, noinit
1609 var n_cpar
: TCpar is writable, noinit
1612 # Whatevej just contains (and mimic) an other expression
1613 abstract class AProxyExpr
1615 var n_expr
: AExpr is writable, noinit
1618 # A type cast. eg `x.as(T)`
1621 var n_expr
: AExpr is writable, noinit
1622 var n_kwas
: TKwas is writable, noinit
1623 var n_opar
: nullable TOpar = null is writable
1624 var n_type
: AType is writable, noinit
1625 var n_cpar
: nullable TCpar = null is writable
1628 # A as-not-null cast. eg `x.as(not null)`
1629 class AAsNotnullExpr
1631 var n_expr
: AExpr is writable, noinit
1632 var n_kwas
: TKwas is writable, noinit
1633 var n_opar
: nullable TOpar = null is writable
1634 var n_kwnot
: TKwnot is writable, noinit
1635 var n_kwnull
: TKwnull is writable, noinit
1636 var n_cpar
: nullable TCpar = null is writable
1639 # A is-set check of old-style attributes. eg `isset x._a`
1640 class AIssetAttrExpr
1642 var n_kwisset
: TKwisset is writable, noinit
1645 # A elyspis notation used to pass an expression as it in a vararg parameter
1648 var n_expr
: AExpr is writable, noinit
1649 var n_dotdotdot
: TDotdotdot is writable, noinit
1652 # A list of expression separated with commas (arguments for instance)
1653 abstract class AExprs
1655 var n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1659 class ADebugTypeExpr
1661 var n_kwdebug
: TKwdebug is writable, noinit
1662 var n_kwtype
: TKwtype is writable, noinit
1663 var n_expr
: AExpr is writable, noinit
1664 var n_type
: AType is writable, noinit
1667 # A simple list of expressions
1672 # A list of expressions enclosed in parentheses
1675 var n_opar
: TOpar is writable, noinit
1676 var n_cpar
: TCpar is writable, noinit
1679 # A list of expressions enclosed in brackets
1682 var n_obra
: TObra is writable, noinit
1683 var n_cbra
: TCbra is writable, noinit
1686 # A complex assignment operator. eg `+=`
1687 abstract class AAssignOp
1692 var n_pluseq
: TPluseq is writable, noinit
1694 class AMinusAssignOp
1696 var n_minuseq
: TMinuseq is writable, noinit
1701 var n_quad
: nullable TQuad = null is writable
1702 var n_path
: ANodes[TId] = new ANodes[TId](self)
1703 var n_id
: TId is writable, noinit
1707 var n_kwin
: TKwin is writable, noinit
1708 var n_string
: TString is writable, noinit
1710 class AExternCodeBlock
1712 var n_in_language
: nullable AInLanguage = null is writable
1713 var n_extern_code_segment
: TExternCodeSegment is writable, noinit
1717 var n_quad
: nullable TQuad = null is writable
1718 var n_id
: ANodes[TId] = new ANodes[TId](self)
1719 var n_classid
: nullable TClassid = null is writable
1722 # A documentation of a definition
1723 # It contains the block of comments just above the declaration
1726 var n_comment
: ANodes[TComment] = new ANodes[TComment](self)
1731 var n_at
: nullable TAt = null is writable
1732 var n_opar
: nullable TOpar = null is writable
1733 var n_items
: ANodes[AAnnotation] = new ANodes[AAnnotation](self)
1734 var n_cpar
: nullable TCpar = null is writable
1738 var n_doc
: nullable ADoc = null is writable
1739 var n_kwredef
: nullable TKwredef = null is writable
1740 var n_visibility
: nullable AVisibility is writable
1741 var n_atid
: AAtid is writable, noinit
1742 var n_opar
: nullable TOpar = null is writable
1743 var n_args
: ANodes[AAtArg] = new ANodes[AAtArg](self)
1744 var n_cpar
: nullable TCpar = null is writable
1746 abstract class AAtArg
1751 var n_type
: AType is writable, noinit
1755 var n_expr
: AExpr is writable, noinit
1760 abstract class AAtid
1762 var n_id
: Token is writable, noinit
1773 class AKwabstractAtid
1777 # The root of the AST
1780 var n_base
: nullable AModule is writable
1781 var n_eof
: EOF is writable, noinit
1782 init(n_base
: nullable AModule, n_eof
: EOF)
1784 self._n_base
= n_base