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}'"
505 # A token associated with an operator (and other lookalike symbols)
506 abstract class TokenOperator
510 return "operator '{text}'"
580 # A class (or formal type) identifier. They start with an uppercase.
585 do return "type identifier '{text}'"
589 # A standard identifier (variable, method...). They start with a lowercase.
594 do return "identifier '{text}'"
598 # An attribute identifier. They start with an underscore.
603 do return "attribute '{text}'"
607 # A token of a literal value (string, integer, etc).
608 abstract class TokenLiteral
612 do return "literal value '{text}'"
645 do return "malformed string {text}"
654 do return "malformed character {text}"
658 class TExternCodeSegment
682 # The main node of a Nit source-file
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)
692 # The declaration of the module with the documentation, name, and annotations
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
702 # A import clause of a module
703 abstract class AImport
707 # A standard import clause. eg `import x`
710 var n_visibility
: AVisibility is writable, noinit
711 var n_kwimport
: TKwimport is writable, noinit
712 var n_name
: AModuleName is writable, noinit
715 # The special import clause of the kernel module. eg `import end`
718 var n_visibility
: AVisibility is writable, noinit
719 var n_kwimport
: TKwimport is writable, noinit
720 var n_kwend
: TKwend is writable, noinit
723 # A visibility modifier
725 # The public visibility is an empty production (no keyword).
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
732 class APublicVisibility
734 var n_kwpublic
: nullable TKwpublic is writable
736 class APrivateVisibility
738 var n_kwprivate
: TKwprivate is writable, noinit
740 class AProtectedVisibility
742 var n_kwprotected
: TKwprotected is writable, noinit
744 class AIntrudeVisibility
746 var n_kwintrude
: TKwintrude is writable, noinit
750 # While most definition are `AStdClassdef`
751 # There is tow special case of class definition
752 abstract class AClassdef
754 var n_propdefs
: ANodes[APropdef] = new ANodes[APropdef](self)
757 # A standard class definition with a name, superclasses and properties
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
772 # The implicit class definition of the implicit main method
777 # The implicit class definition of the top-level methods
782 # The modifier for the kind of class (abstract, interface, etc.)
783 abstract class AClasskind
786 class AConcreteClasskind
788 var n_kwclass
: TKwclass is writable, noinit
790 class AAbstractClasskind
792 var n_kwabstract
: TKwabstract is writable, noinit
793 var n_kwclass
: TKwclass is writable, noinit
795 class AInterfaceClasskind
797 var n_kwinterface
: TKwinterface is writable, noinit
801 var n_kwenum
: TKwenum is writable, noinit
803 class AExternClasskind
805 var n_kwextern
: TKwextern is writable, noinit
806 var n_kwclass
: nullable TKwclass = null is writable
809 # The definition of a formal generic parameter type. eg `X: Y`
812 var n_id
: TClassid is writable, noinit
813 # The bound of the parameter type
814 var n_type
: nullable AType = null is writable
817 # A super-class. eg `super X`
820 var n_kwsuper
: TKwsuper is writable, noinit
821 var n_type
: AType is writable, noinit
824 # The definition of a property
825 abstract class APropdef
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
832 # A definition of an attribute
833 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
836 var n_kwvar
: TKwvar is writable, noinit
838 # The identifier for an old-style attribute (null if new-style)
839 var n_id
: nullable TAttrid is writable
841 # The identifier for a new-style attribute (null if old-style)
842 var n_id2
: nullable TId is writable
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
848 # The initial value, if any
849 var n_expr
: nullable AExpr = null is writable
850 redef fun hot_location
852 if n_id
!= null then return n_id
.location
else return n_id2
.location
856 # A definition of all kind of method (including constructors)
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
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
882 # A method marked abstract
883 # *deferred* is a old synonynmous of *abstract* that comes from PRM, that comes from Eiffel.
884 class ADeferredMethPropdef
888 # A method marked intern
889 class AInternMethPropdef
893 # A method of a constructor marked extern
894 abstract class AExternPropdef
898 # A method marked extern
899 class AExternMethPropdef
903 # A method with a body
904 class AConcreteMethPropdef
909 abstract class AInitPropdef
913 # A constructor with a body
914 class AConcreteInitPropdef
915 super AConcreteMethPropdef
919 class AInternNewPropdef
920 super AInternMethPropdef
924 # A constructor marked extern (defined with the `new` keyword)
925 class AExternInitPropdef
930 # The implicit main method
931 class AMainMethPropdef
932 super AConcreteMethPropdef
935 # Declaration of callbacks for extern methods
938 var n_kwimport
: TKwimport is writable, noinit
939 var n_extern_calls
: ANodes[AExternCall] = new ANodes[AExternCall](self)
941 abstract class AExternCall
944 abstract class APropExternCall
947 class ALocalPropExternCall
948 super APropExternCall
949 var n_methid
: AMethid is writable, noinit
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
957 class AInitPropExternCall
958 super APropExternCall
959 var n_type
: AType is writable, noinit
961 class ASuperExternCall
963 var n_kwsuper
: TKwsuper is writable, noinit
965 abstract class ACastExternCall
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
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
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
989 # A definition of a virtual type
992 var n_kwtype
: TKwtype is writable, noinit
993 var n_id
: TClassid is writable, noinit
994 var n_type
: AType is writable, noinit
997 # A `writable` or `readable` modifier
1000 var n_visibility
: nullable AVisibility = null is writable
1001 var n_kwredef
: nullable TKwredef = null is writable
1004 # A `readable` modifier
1007 var n_kwreadable
: TKwreadable is writable, noinit
1010 # A `writable` modifier
1013 var n_kwwritable
: TKwwritable is writable, noinit
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
1023 var n_id
: TId is writable, noinit
1027 var n_plus
: TPlus is writable, noinit
1031 var n_minus
: TMinus is writable, noinit
1035 var n_star
: TStar is writable, noinit
1037 class AStarstarMethid
1039 var n_starstar
: TStarstar is writable, noinit
1043 var n_slash
: TSlash is writable, noinit
1045 class APercentMethid
1047 var n_percent
: TPercent is writable, noinit
1051 var n_eq
: TEq is writable, noinit
1055 var n_ne
: TNe is writable, noinit
1059 var n_le
: TLe is writable, noinit
1063 var n_ge
: TGe is writable, noinit
1067 var n_lt
: TLt is writable, noinit
1071 var n_gt
: TGt is writable, noinit
1075 var n_ll
: TLl is writable, noinit
1079 var n_gg
: TGg is writable, noinit
1083 var n_obra
: TObra is writable, noinit
1084 var n_cbra
: TCbra is writable, noinit
1086 class AStarshipMethid
1088 var n_starship
: TStarship is writable, noinit
1092 var n_id
: TId is writable, noinit
1093 var n_assign
: TAssign is writable, noinit
1095 class ABraassignMethid
1097 var n_obra
: TObra is writable, noinit
1098 var n_cbra
: TCbra is writable, noinit
1099 var n_assign
: TAssign is writable, noinit
1102 # A signature in a method definition. eg `(x,y:X,z:Z):T`
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
1111 # A parameter definition in a signature. eg `x:X`
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
1119 # A static type. eg `nullable X[Y]`
1122 var n_kwnullable
: nullable TKwnullable = null is writable
1124 # The name of the class or of the formal type
1125 var n_id
: TClassid is writable, noinit
1127 # Type arguments for a generic type
1128 var n_types
: ANodes[AType] = new ANodes[AType](self)
1131 # A label at the end of a block or in a break/continue statement. eg `label x`
1134 var n_kwlabel
: TKwlabel is writable, noinit
1135 var n_id
: nullable TId is writable
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
1144 # A sequence of AExpr (usually statements)
1145 # The last AExpr gives the value of the whole block
1148 var n_expr
: ANodes[AExpr] = new ANodes[AExpr](self)
1149 var n_kwend
: nullable TKwend = null is writable
1152 # A declaration of a local variable. eg `var x: X = y`
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
1160 # The initial value, if any
1161 var n_expr
: nullable AExpr = null is writable
1164 # A `return` statement. eg `return x`
1167 var n_kwreturn
: nullable TKwreturn = null is writable
1168 var n_expr
: nullable AExpr = null is writable
1171 # Something that has a label.
1172 abstract class ALabelable
1174 var n_label
: nullable ALabel = null is writable
1177 # A `break` statement.
1181 var n_kwbreak
: TKwbreak is writable, noinit
1182 var n_expr
: nullable AExpr = null is writable
1185 # An `abort` statement
1188 var n_kwabort
: TKwabort is writable, noinit
1191 # A `continue` statement
1195 var n_kwcontinue
: nullable TKwcontinue = null is writable
1196 var n_expr
: nullable AExpr = null is writable
1203 var n_kwdo
: TKwdo is writable, noinit
1204 var n_block
: nullable AExpr = null is writable
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
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
1227 # A `while` statement
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
1237 # A `loop` statement
1241 var n_kwloop
: TKwloop is writable, noinit
1242 var n_block
: nullable AExpr = null is writable
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
1256 # An `assert` statement
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
1265 # Whatever is a simple assignment. eg `= something`
1266 abstract class AAssignFormExpr
1268 var n_assign
: TAssign is writable, noinit
1269 var n_value
: AExpr is writable, noinit
1272 # Whatever is a combined assignment. eg `+= something`
1273 abstract class AReassignFormExpr
1275 var n_assign_op
: AAssignOp is writable, noinit
1276 var n_value
: AExpr is writable, noinit
1279 # A `once` expression. eg `once x`
1282 var n_kwonce
: TKwonce is writable, noinit
1285 # A polymorphic invocation of a method
1286 # The form of the invocation (name, arguments, etc) are specific
1287 abstract class ASendExpr
1289 # The receiver of the method invocation
1290 var n_expr
: AExpr is writable, noinit
1293 # A binary operation on a method
1294 abstract class ABinopExpr
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
1301 # Something that is boolean expression
1302 abstract class ABoolExpr
1309 var n_expr
: AExpr is writable, noinit
1310 var n_expr2
: AExpr is writable, noinit
1313 # A `and` expression
1316 var n_expr
: AExpr is writable, noinit
1317 var n_expr2
: AExpr is writable, noinit
1320 # A `or else` expression
1323 var n_expr
: AExpr is writable, noinit
1324 var n_expr2
: AExpr is writable, noinit
1327 # A `implies` expression
1330 var n_expr
: AExpr is writable, noinit
1331 var n_expr2
: AExpr is writable, noinit
1334 # A `not` expression
1337 var n_kwnot
: TKwnot is writable, noinit
1338 var n_expr
: AExpr is writable, noinit
1381 # A type-ckeck expression. eg `x isa T`
1384 var n_expr
: AExpr is writable, noinit
1385 var n_type
: AType is writable, noinit
1398 # A `<=>` expression
1423 # A unary minus expression. eg `-x`
1426 var n_minus
: TMinus is writable, noinit
1429 # An explicit instantiation. eg `new T`
1432 var n_kwnew
: TKwnew is writable, noinit
1433 var n_type
: AType is writable, noinit
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
1440 # Whatever is a old-style attribute access
1441 abstract class AAttrFormExpr
1444 # The receiver of the attribute
1445 var n_expr
: AExpr is writable, noinit
1447 # The name of the attribute
1448 var n_id
: TAttrid is writable, noinit
1452 # The read of an attribute. eg `x._a`
1457 # The assignment of an attribute. eg `x._a=y`
1458 class AAttrAssignExpr
1460 super AAssignFormExpr
1463 # Whatever looks-like a call with a standard method and any number of arguments.
1464 abstract class ACallFormExpr
1467 # The name of the method
1468 var n_id
: TId is writable, noinit
1470 # The arguments of the call
1471 var n_args
: AExprs is writable, noinit
1474 # A complex setter call (standard or brackets)
1475 abstract class ASendReassignFormExpr
1477 super AReassignFormExpr
1480 # A complex attribute assignment. eg `x._a+=y`
1481 class AAttrReassignExpr
1483 super AReassignFormExpr
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`.
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
1498 super AAssignFormExpr
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
1506 super ASendReassignFormExpr
1509 # A call to `super`. OR a call of a super-constructor
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
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.
1521 var n_kwinit
: TKwinit is writable, noinit
1522 var n_args
: AExprs is writable, noinit
1525 # Whatever looks-like a call of the brackets `[]` operator.
1526 abstract class ABraFormExpr
1528 var n_args
: AExprs is writable, noinit
1531 # A call of the brackets operator. eg `x[y,z]`
1536 # A setter call of the bracket operator. eg `x[y,z]=t`
1537 class ABraAssignExpr
1539 super AAssignFormExpr
1542 # Whatever is an access to a local variable
1543 abstract class AVarFormExpr
1545 var n_id
: TId is writable, noinit
1548 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
1549 class ABraReassignExpr
1551 super ASendReassignFormExpr
1554 # A local variable read access.
1555 # The parser cannot instantiate them, see `ACallExpr`.
1560 # A local variable simple assigment access
1561 # The parser cannot instantiate them, see `ACallAssignExpr`.
1562 class AVarAssignExpr
1564 super AAssignFormExpr
1567 # A local variable complex assignment access
1568 # The parser cannot instantiate them, see `ACallReassignExpr`.
1569 class AVarReassignExpr
1571 super AReassignFormExpr
1574 # A literal range, open or closed
1575 abstract class ARangeExpr
1577 var n_expr
: AExpr is writable, noinit
1578 var n_expr2
: AExpr is writable, noinit
1581 # A closed literal range. eg `[x..y]`
1584 var n_obra
: TObra is writable, noinit
1585 var n_cbra
: TCbra is writable, noinit
1588 # An open literal range. eg `[x..y[`
1591 var n_obra
: TObra is writable, noinit
1592 var n_cbra
: TObra is writable, noinit
1595 # A literal array. eg. `[x,y,z]`
1598 var n_exprs
: AExprs is writable, noinit
1604 var n_kwself
: nullable TKwself is writable
1607 # When there is no explicit receiver, `self` is implicit
1608 class AImplicitSelfExpr
1612 # A `true` boolean literal constant
1615 var n_kwtrue
: TKwtrue is writable, noinit
1617 # A `false` boolean literal constant
1620 var n_kwfalse
: TKwfalse is writable, noinit
1622 # A `null` literal constant
1625 var n_kwnull
: TKwnull is writable, noinit
1627 # An integer literal
1631 # An integer literal in decimal format
1634 var n_number
: TNumber is writable, noinit
1636 # An integer literal in hexadecimal format
1639 var n_hex_number
: THexNumber is writable, noinit
1644 var n_float
: TFloat is writable, noinit
1646 # A character literal
1649 var n_char
: TChar is writable, noinit
1652 abstract class AStringFormExpr
1654 var n_string
: Token is writable, noinit
1657 # A simple string. eg. `"abc"`
1659 super AStringFormExpr
1662 # The start of a superstring. eg `"abc{`
1663 class AStartStringExpr
1664 super AStringFormExpr
1667 # The middle of a superstring. eg `}abc{`
1668 class AMidStringExpr
1669 super AStringFormExpr
1672 # The end of a superstrng. eg `}abc"`
1673 class AEndStringExpr
1674 super AStringFormExpr
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
1681 var n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1684 # A simple parenthesis. eg `(x)`
1687 var n_opar
: TOpar is writable, noinit
1688 var n_cpar
: TCpar is writable, noinit
1691 # Whatevej just contains (and mimic) an other expression
1692 abstract class AProxyExpr
1694 var n_expr
: AExpr is writable, noinit
1697 # A type cast. eg `x.as(T)`
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
1707 # A as-not-null cast. eg `x.as(not null)`
1708 class AAsNotnullExpr
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
1718 # A is-set check of old-style attributes. eg `isset x._a`
1719 class AIssetAttrExpr
1721 var n_kwisset
: TKwisset is writable, noinit
1724 # A elyspis notation used to pass an expression as it in a vararg parameter
1727 var n_expr
: AExpr is writable, noinit
1728 var n_dotdotdot
: TDotdotdot is writable, noinit
1731 # A list of expression separated with commas (arguments for instance)
1732 abstract class AExprs
1734 var n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1738 class ADebugTypeExpr
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
1746 # A simple list of expressions
1751 # A list of expressions enclosed in parentheses
1754 var n_opar
: TOpar is writable, noinit
1755 var n_cpar
: TCpar is writable, noinit
1758 # A list of expressions enclosed in brackets
1761 var n_obra
: TObra is writable, noinit
1762 var n_cbra
: TCbra is writable, noinit
1765 # A complex assignment operator. eg `+=`
1766 abstract class AAssignOp
1771 var n_pluseq
: TPluseq is writable, noinit
1773 class AMinusAssignOp
1775 var n_minuseq
: TMinuseq is writable, noinit
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
1786 var n_kwin
: TKwin is writable, noinit
1787 var n_string
: TString is writable, noinit
1789 class AExternCodeBlock
1791 var n_in_language
: nullable AInLanguage = null is writable
1792 var n_extern_code_segment
: TExternCodeSegment is writable, noinit
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
1801 # A documentation of a definition
1802 # It contains the block of comments just above the declaration
1805 var n_comment
: ANodes[TComment] = new ANodes[TComment](self)
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
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
1825 abstract class AAtArg
1830 var n_type
: AType is writable, noinit
1834 var n_expr
: AExpr is writable, noinit
1839 abstract class AAtid
1841 var n_id
: Token is writable, noinit
1852 class AKwreadableAtid
1855 class AKwwritableAtid
1861 class AKwabstractAtid
1865 # The root of the AST
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)
1872 self._n_base
= n_base