6bf5eacb1fbc988f5d280a5ebcf9fad92a63ab53
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 detachable. 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 # It is a specific class (instead of using a Array) to track the parent/child relation when nodes are added or removed
124 class ANodes[E
: ANode]
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 constructor 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
226 # The raw content on the token
227 fun text
=(text
: String) is abstract
229 # The previous token in the Lexer.
230 # May have disappeared in the AST
231 var prev_token
: nullable Token = null
233 # The next token in the Lexer.
234 # May have disappeared in the AST
235 var next_token
: nullable Token = null
237 # The verbatim blank text between `prev_token` and `self`
238 fun blank_before
: String
240 if prev_token
== null then return ""
241 var from
= prev_token
.location
.pend
+1
242 var to
= location
.pstart
243 return location
.file
.string
.substring
(from
,to-from
)
246 redef fun to_s
: String do
250 redef fun visit_all
(v
: Visitor) do end
251 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode) do end
254 redef class SourceFile
255 # The first token parser by the lexer
256 # May have disappeared in the final AST
257 var first_token
: nullable Token = null
259 # The first token parser by the lexer
260 # May have disappeared in the final AST
261 var last_token
: nullable Token = null
264 # Ancestor of all productions
265 # A production is a node without text but that usually has children.
269 # All the annotations attached directly to the node
270 var n_annotations
: nullable AAnnotations = null is writable
272 redef fun replace_with
(n
: ANode)
276 if not isset n
._location
and isset _location
then n
._location
= _location
280 # Abstract standard visitor on the AST
281 abstract class Visitor
282 # What the visitor do when a node is visited
283 # Concrete visitors should implement this method.
285 protected fun visit
(e
: ANode) is abstract
287 # Ask the visitor to visit a given node.
288 # Usually automatically called by visit_all* methods.
289 # This method should not be redefined
290 fun enter_visit
(e
: nullable ANode)
292 if e
== null then return
293 var old
= _current_node
299 # The current visited node
300 var current_node
: nullable ANode = null is writable
303 # Token of end of line (basically `\n`)
312 # Token of a line of comments
313 # Starts with the `#` and contains the final end-of-line (if any)
318 # A token associated with a keyword
319 abstract class TokenKeyword
323 return "keyword '{text}'"
327 # The deprecated keyword `package`.
332 # The keyword `module`
337 # The keyword `import`
342 # The keyword `class`
347 # The keyword `abstract`
352 # The keyword `interface`
357 # The keywords `enum` ane `universal`
382 # The keyword `redef`
402 # The keyword `extern`
407 # The keyword `public`
412 # The keyword `protected`
417 # The keyword `private`
422 # The keyword `intrude`
442 # The keyword `while`
472 # The keyword `implies`
482 # The keyword `return`
487 # The keyword `continue`
492 # The keyword `break`
497 # The keyword `abort`
502 # The keyword `assert`
522 # The keyword `super`
537 # The keyword `false`
552 # The keyword `nullable`
557 # The keyword `isset`
562 # The keyword `label`
567 # The special keyword `__DEBUG__`
612 # A token associated with an operator (and other lookalike symbols)
613 abstract class TokenOperator
617 return "operator '{text}'"
731 # A class (or formal type) identifier. They start with an uppercase.
736 do return "type identifier '{text}'"
740 # A standard identifier (variable, method...). They start with a lowercase.
745 do return "identifier '{text}'"
749 # An attribute identifier. They start with an underscore.
754 do return "attribute '{text}'"
758 # A token of a literal value (string, integer, etc).
759 abstract class TokenLiteral
763 do return "literal value '{text}'"
767 # A literal decimal integer
772 # A literal hexadecimal integer
777 # A literal floating point number
782 # A literal character
792 # The starting part of a super string (between `"` and `{`)
797 # The middle part of a super string (between `}` and `{`)
802 # The final part of a super string (between `}` and `"`)
812 do return "malformed string {text}"
821 do return "malformed character {text}"
825 # A extern code block
826 class TExternCodeSegment
843 # A lexical error (unexpected character)
847 # A syntactic error (unexpected token)
852 # The main node of a Nit source-file
856 var n_moduledecl
: nullable AModuledecl = null is writable
857 var n_imports
= new ANodes[AImport](self)
858 var n_extern_code_blocks
= new ANodes[AExternCodeBlock](self)
859 var n_classdefs
= new ANodes[AClassdef](self)
862 # Abstract class for definition of entities
863 abstract class ADefinition
865 var n_doc
: nullable ADoc = null is writable
866 var n_kwredef
: nullable TKwredef = null is writable
867 var n_visibility
: nullable AVisibility = null is writable
870 # The declaration of the module with the documentation, name, and annotations
873 var n_kwmodule
: TKwmodule is writable, noinit
874 var n_name
: AModuleName is writable, noinit
877 # A import clause of a module
878 abstract class AImport
880 var n_visibility
: AVisibility is writable, noinit
881 var n_kwimport
: TKwimport is writable, noinit
884 # A standard import clause. eg `import x`
887 var n_name
: AModuleName is writable, noinit
890 # The special import clause of the kernel module. eg `import end`
893 var n_kwend
: TKwend is writable, noinit
896 # A visibility modifier
898 # The public visibility is an empty production (no keyword).
900 # Note: even if some visibilities are only valid on some placse (for instance, no `protected` class or no `intrude` method)
901 # the parser has no such a restriction, therefore the semantic phases has to check that the visibilities make sense.
902 abstract class AVisibility
906 # An implicit or explicit public visibility modifier
907 class APublicVisibility
909 var n_kwpublic
: nullable TKwpublic is writable
911 # An explicit private visibility modifier
912 class APrivateVisibility
914 var n_kwprivate
: TKwprivate is writable, noinit
916 # An explicit protected visibility modifier
917 class AProtectedVisibility
919 var n_kwprotected
: TKwprotected is writable, noinit
921 # An explicit intrude visibility modifier
922 class AIntrudeVisibility
924 var n_kwintrude
: TKwintrude is writable, noinit
928 # While most definition are `AStdClassdef`
929 # There is tow special case of class definition
930 abstract class AClassdef
932 var n_propdefs
= new ANodes[APropdef](self)
935 # A standard class definition with a name, superclasses and properties
939 var n_classkind
: AClasskind is writable, noinit
940 var n_id
: nullable TClassid = null is writable
941 var n_formaldefs
= new ANodes[AFormaldef](self)
942 var n_extern_code_block
: nullable AExternCodeBlock = null is writable
943 var n_superclasses
= new ANodes[ASuperclass](self)
944 var n_kwend
: TKwend is writable, noinit
945 redef fun hot_location
do return n_id
.location
948 # The implicit class definition of the implicit main method
953 # The implicit class definition of the top-level methods
958 # The modifier for the kind of class (abstract, interface, etc.)
959 abstract class AClasskind
963 # A default, or concrete class modifier (just `class`)
964 class AConcreteClasskind
966 var n_kwclass
: TKwclass is writable, noinit
969 # An abstract class modifier (`abstract class`)
970 class AAbstractClasskind
972 var n_kwabstract
: TKwabstract is writable, noinit
973 var n_kwclass
: TKwclass is writable, noinit
976 # An interface class modifier (`interface`)
977 class AInterfaceClasskind
979 var n_kwinterface
: TKwinterface is writable, noinit
982 # An enum/universal class modifier (`enum class`)
985 var n_kwenum
: TKwenum is writable, noinit
988 # An extern class modifier (`extern class`)
989 class AExternClasskind
991 var n_kwextern
: TKwextern is writable, noinit
992 var n_kwclass
: nullable TKwclass = null is writable
995 # The definition of a formal generic parameter type. eg `X: Y`
998 var n_id
: TClassid is writable, noinit
999 # The bound of the parameter type
1000 var n_type
: nullable AType = null is writable
1003 # A super-class. eg `super X`
1006 var n_kwsuper
: TKwsuper is writable, noinit
1007 var n_type
: AType is writable, noinit
1010 # The definition of a property
1011 abstract class APropdef
1015 # A definition of an attribute
1016 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
1019 var n_kwvar
: TKwvar is writable, noinit
1021 # The identifier for a new-style attribute (null if old-style)
1022 var n_id2
: TId is writable, noinit
1024 var n_type
: nullable AType = null is writable
1026 # The initial value, if any
1027 var n_expr
: nullable AExpr = null is writable
1029 var n_block
: nullable AExpr = null is writable
1031 redef fun hot_location
1033 return n_id2
.location
1037 # A definition of all kind of method (including constructors)
1040 var n_kwmeth
: nullable TKwmeth = null is writable
1041 var n_kwinit
: nullable TKwinit = null is writable
1042 var n_kwnew
: nullable TKwnew = null is writable
1043 var n_methid
: nullable AMethid = null is writable
1044 var n_signature
: nullable ASignature = null is writable
1045 var n_block
: nullable AExpr = null is writable
1046 var n_extern_calls
: nullable AExternCalls = null is writable
1047 var n_extern_code_block
: nullable AExternCodeBlock = null is writable
1048 redef fun hot_location
1050 if n_methid
!= null then
1051 return n_methid
.location
1052 else if n_kwinit
!= null then
1053 return n_kwinit
.location
1054 else if n_kwnew
!= null then
1055 return n_kwnew
.location
1062 # The implicit main method
1063 class AMainMethPropdef
1067 # Declaration of callbacks for extern methods
1070 var n_kwimport
: TKwimport is writable, noinit
1071 var n_extern_calls
: ANodes[AExternCall] = new ANodes[AExternCall](self)
1074 # A single callback declaration
1075 abstract class AExternCall
1079 # A single callback declaration on a method
1080 abstract class APropExternCall
1084 # A single callback declaration on a method on the current receiver
1085 class ALocalPropExternCall
1086 super APropExternCall
1087 var n_methid
: AMethid is writable, noinit
1090 # A single callback declaration on a method on an explicit receiver type.
1091 class AFullPropExternCall
1092 super APropExternCall
1093 var n_type
: AType is writable, noinit
1094 var n_dot
: nullable TDot = null is writable
1095 var n_methid
: AMethid is writable, noinit
1098 # A single callback declaration on a method on a constructor
1099 class AInitPropExternCall
1100 super APropExternCall
1101 var n_type
: AType is writable, noinit
1104 # A single callback declaration on a `super` call
1105 class ASuperExternCall
1107 var n_kwsuper
: TKwsuper is writable, noinit
1110 # A single callback declaration on a cast
1111 abstract class ACastExternCall
1115 # A single callback declaration on a cast to a given type
1116 class ACastAsExternCall
1117 super ACastExternCall
1118 var n_from_type
: AType is writable, noinit
1119 var n_dot
: nullable TDot = null is writable
1120 var n_kwas
: TKwas is writable, noinit
1121 var n_to_type
: AType is writable, noinit
1124 # A single callback declaration on a cast to a nullable type
1125 class AAsNullableExternCall
1126 super ACastExternCall
1127 var n_type
: AType is writable, noinit
1128 var n_kwas
: TKwas is writable, noinit
1129 var n_kwnullable
: TKwnullable is writable, noinit
1132 # A single callback declaration on a cast to a non-nullable type
1133 class AAsNotNullableExternCall
1134 super ACastExternCall
1135 var n_type
: AType is writable, noinit
1136 var n_kwas
: TKwas is writable, noinit
1137 var n_kwnot
: TKwnot is writable, noinit
1138 var n_kwnullable
: TKwnullable is writable, noinit
1141 # A definition of a virtual type
1144 var n_kwtype
: TKwtype is writable, noinit
1145 var n_id
: TClassid is writable, noinit
1146 var n_type
: AType is writable, noinit
1149 # The identifier of a method in a method declaration.
1150 # There is a specific class because of operator and setters.
1151 abstract class AMethid
1155 # A method name with a simple identifier
1158 var n_id
: TId is writable, noinit
1164 var n_plus
: TPlus is writable, noinit
1170 var n_minus
: TMinus is writable, noinit
1176 var n_star
: TStar is writable, noinit
1179 # A method name `**`
1180 class AStarstarMethid
1182 var n_starstar
: TStarstar is writable, noinit
1188 var n_slash
: TSlash is writable, noinit
1192 class APercentMethid
1194 var n_percent
: TPercent is writable, noinit
1197 # A method name `==`
1200 var n_eq
: TEq is writable, noinit
1203 # A method name `!=`
1206 var n_ne
: TNe is writable, noinit
1209 # A method name `<=`
1212 var n_le
: TLe is writable, noinit
1215 # A method name `>=`
1218 var n_ge
: TGe is writable, noinit
1224 var n_lt
: TLt is writable, noinit
1230 var n_gt
: TGt is writable, noinit
1233 # A method name `<<`
1236 var n_ll
: TLl is writable, noinit
1239 # A method name `>>`
1242 var n_gg
: TGg is writable, noinit
1245 # A method name `[]`
1248 var n_obra
: TObra is writable, noinit
1249 var n_cbra
: TCbra is writable, noinit
1252 # A method name `<=>`
1253 class AStarshipMethid
1255 var n_starship
: TStarship is writable, noinit
1258 # A setter method name with a simple identifier (with a `=`)
1261 var n_id
: TId is writable, noinit
1262 var n_assign
: TAssign is writable, noinit
1265 # A method name `[]=`
1266 class ABraassignMethid
1268 var n_obra
: TObra is writable, noinit
1269 var n_cbra
: TCbra is writable, noinit
1270 var n_assign
: TAssign is writable, noinit
1273 # A signature in a method definition. eg `(x,y:X,z:Z):T`
1276 var n_opar
: nullable TOpar = null is writable
1277 var n_params
= new ANodes[AParam](self)
1278 var n_cpar
: nullable TCpar = null is writable
1279 var n_type
: nullable AType = null is writable
1282 # A parameter definition in a signature. eg `x:X`
1285 var n_id
: TId is writable, noinit
1286 var n_type
: nullable AType = null is writable
1287 var n_dotdotdot
: nullable TDotdotdot = null is writable
1290 # A static type. eg `nullable X[Y]`
1293 var n_kwnullable
: nullable TKwnullable = null is writable
1295 # The name of the class or of the formal type
1296 var n_id
: TClassid is writable, noinit
1298 # Type arguments for a generic type
1299 var n_types
= new ANodes[AType](self)
1302 # A label at the end of a block or in a break/continue statement. eg `label x`
1305 var n_kwlabel
: TKwlabel is writable, noinit
1306 var n_id
: nullable TId is writable
1309 # Expression and statements
1310 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1311 abstract class AExpr
1315 # A sequence of `AExpr` (usually statements)
1316 # The last `AExpr` gives the value of the whole block
1319 var n_expr
= new ANodes[AExpr](self)
1320 var n_kwend
: nullable TKwend = null is writable
1323 # A declaration of a local variable. eg `var x: X = y`
1326 var n_kwvar
: TKwvar is writable, noinit
1327 var n_id
: TId is writable, noinit
1328 var n_type
: nullable AType = null is writable
1329 var n_assign
: nullable TAssign = null is writable
1331 # The initial value, if any
1332 var n_expr
: nullable AExpr = null is writable
1335 # A `return` statement. eg `return x`
1338 var n_kwreturn
: nullable TKwreturn = null is writable
1339 var n_expr
: nullable AExpr = null is writable
1342 # Something that has a label.
1343 abstract class ALabelable
1345 var n_label
: nullable ALabel = null is writable
1348 # A `break` or a `continue`
1349 abstract class AEscapeExpr
1352 var n_expr
: nullable AExpr = null is writable
1355 # A `break` statement.
1358 var n_kwbreak
: TKwbreak is writable, noinit
1361 # An `abort` statement
1364 var n_kwabort
: TKwabort is writable, noinit
1367 # A `continue` statement
1370 var n_kwcontinue
: nullable TKwcontinue = null is writable
1377 var n_kwdo
: TKwdo is writable, noinit
1378 var n_block
: nullable AExpr = null is writable
1384 var n_kwif
: TKwif is writable, noinit
1385 var n_expr
: AExpr is writable, noinit
1386 var n_then
: nullable AExpr = null is writable
1387 var n_else
: nullable AExpr = null is writable
1393 var n_kwif
: TKwif is writable, noinit
1394 var n_expr
: AExpr is writable, noinit
1395 var n_kwthen
: TKwthen is writable, noinit
1396 var n_then
: AExpr is writable, noinit
1397 var n_kwelse
: TKwelse is writable, noinit
1398 var n_else
: AExpr is writable, noinit
1401 # A `while` statement
1405 var n_kwwhile
: TKwwhile is writable, noinit
1406 var n_expr
: AExpr is writable, noinit
1407 var n_kwdo
: TKwdo is writable, noinit
1408 var n_block
: nullable AExpr = null is writable
1411 # A `loop` statement
1415 var n_kwloop
: TKwloop is writable, noinit
1416 var n_block
: nullable AExpr = null is writable
1423 var n_kwfor
: TKwfor is writable, noinit
1424 var n_ids
= new ANodes[TId](self)
1425 var n_expr
: AExpr is writable, noinit
1426 var n_kwdo
: TKwdo is writable, noinit
1427 var n_block
: nullable AExpr = null is writable
1430 # An `assert` statement
1433 var n_kwassert
: TKwassert is writable, noinit
1434 var n_id
: nullable TId = null is writable
1435 var n_expr
: AExpr is writable, noinit
1436 var n_else
: nullable AExpr = null is writable
1439 # Whatever is a simple assignment. eg `= something`
1440 abstract class AAssignFormExpr
1442 var n_assign
: TAssign is writable, noinit
1443 var n_value
: AExpr is writable, noinit
1446 # Whatever is a combined assignment. eg `+= something`
1447 abstract class AReassignFormExpr
1449 var n_assign_op
: AAssignOp is writable, noinit
1450 var n_value
: AExpr is writable, noinit
1453 # A `once` expression. eg `once x`
1456 var n_kwonce
: TKwonce is writable, noinit
1457 var n_expr
: AExpr is writable, noinit
1460 # A polymorphic invocation of a method
1461 # The form of the invocation (name, arguments, etc.) are specific
1462 abstract class ASendExpr
1464 # The receiver of the method invocation
1465 var n_expr
: AExpr is writable, noinit
1468 # A binary operation on a method
1469 abstract class ABinopExpr
1471 # The second operand of the operation
1472 # Note: the receiver (`n_expr`) is the first operand
1473 var n_expr2
: AExpr is writable, noinit
1476 # Something that is boolean expression
1477 abstract class ABoolExpr
1481 # Something that is binary boolean expression
1482 abstract class ABinBoolExpr
1484 var n_expr
: AExpr is writable, noinit
1485 var n_expr2
: AExpr is writable, noinit
1493 # A `and` expression
1498 # A `or else` expression
1503 # A `implies` expression
1508 # A `not` expression
1511 var n_kwnot
: TKwnot is writable, noinit
1512 var n_expr
: AExpr is writable, noinit
1555 # A type-ckeck expression. eg `x isa T`
1558 var n_expr
: AExpr is writable, noinit
1559 var n_type
: AType is writable, noinit
1572 # A `<=>` expression
1597 # A unary minus expression. eg `-x`
1600 var n_minus
: TMinus is writable, noinit
1603 # An explicit instantiation. eg `new T`
1606 var n_kwnew
: TKwnew is writable, noinit
1607 var n_type
: AType is writable, noinit
1609 # The name of the named-constructor, if any
1610 var n_id
: nullable TId = null is writable
1611 var n_args
: AExprs is writable, noinit
1614 # Whatever is a old-style attribute access
1615 abstract class AAttrFormExpr
1618 # The receiver of the attribute
1619 var n_expr
: AExpr is writable, noinit
1621 # The name of the attribute
1622 var n_id
: TAttrid is writable, noinit
1626 # The read of an attribute. eg `x._a`
1631 # The assignment of an attribute. eg `x._a=y`
1632 class AAttrAssignExpr
1634 super AAssignFormExpr
1637 # Whatever looks-like a call with a standard method and any number of arguments.
1638 abstract class ACallFormExpr
1641 # The name of the method
1642 var n_id
: TId is writable, noinit
1644 # The arguments of the call
1645 var n_args
: AExprs is writable, noinit
1648 # A complex setter call (standard or brackets)
1649 abstract class ASendReassignFormExpr
1651 super AReassignFormExpr
1654 # A complex attribute assignment. eg `x._a+=y`
1655 class AAttrReassignExpr
1657 super AReassignFormExpr
1660 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
1661 # 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`.
1662 # Semantic analysis have to transform them to instance of `AVarExpr`.
1667 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
1668 # 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`.
1669 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
1670 class ACallAssignExpr
1672 super AAssignFormExpr
1675 # 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.
1676 # Note: because the parser cannot distinguish a variable write with a complex setter call with an implicit receiver and no arguments, it always returns a `ACallReassignExpr`.
1677 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
1678 class ACallReassignExpr
1680 super ASendReassignFormExpr
1683 # A call to `super`. OR a call of a super-constructor
1686 var n_qualified
: nullable AQualified = null is writable
1687 var n_kwsuper
: TKwsuper is writable, noinit
1688 var n_args
: AExprs is writable, noinit
1691 # A call to the `init` constructor.
1692 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a `ACallFormExpr`.
1695 var n_kwinit
: TKwinit is writable, noinit
1696 var n_args
: AExprs is writable, noinit
1699 # Whatever looks-like a call of the brackets `[]` operator.
1700 abstract class ABraFormExpr
1702 var n_args
: AExprs is writable, noinit
1705 # A call of the brackets operator. eg `x[y,z]`
1710 # A setter call of the bracket operator. eg `x[y,z]=t`
1711 class ABraAssignExpr
1713 super AAssignFormExpr
1716 # Whatever is an access to a local variable
1717 abstract class AVarFormExpr
1719 var n_id
: TId is writable, noinit
1722 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
1723 class ABraReassignExpr
1725 super ASendReassignFormExpr
1728 # A local variable read access.
1729 # The parser cannot instantiate them, see `ACallExpr`.
1734 # A local variable simple assignment access
1735 # The parser cannot instantiate them, see `ACallAssignExpr`.
1736 class AVarAssignExpr
1738 super AAssignFormExpr
1741 # A local variable complex assignment access
1742 # The parser cannot instantiate them, see `ACallReassignExpr`.
1743 class AVarReassignExpr
1745 super AReassignFormExpr
1748 # A literal range, open or closed
1749 abstract class ARangeExpr
1751 var n_expr
: AExpr is writable, noinit
1752 var n_expr2
: AExpr is writable, noinit
1755 # A closed literal range. eg `[x..y]`
1758 var n_obra
: TObra is writable, noinit
1759 var n_cbra
: TCbra is writable, noinit
1762 # An open literal range. eg `[x..y[`
1765 var n_obra
: TObra is writable, noinit
1766 var n_cbra
: TObra is writable, noinit
1769 # A literal array. eg. `[x,y,z]`
1772 var n_obra
: TObra is writable, noinit
1773 var n_exprs
= new ANodes[AExpr](self)
1774 var n_type
: nullable AType = null is writable
1775 var n_cbra
: TCbra is writable, noinit
1781 var n_kwself
: nullable TKwself is writable
1784 # When there is no explicit receiver, `self` is implicit
1785 class AImplicitSelfExpr
1789 # A `true` boolean literal constant
1792 var n_kwtrue
: TKwtrue is writable, noinit
1794 # A `false` boolean literal constant
1797 var n_kwfalse
: TKwfalse is writable, noinit
1799 # A `null` literal constant
1802 var n_kwnull
: TKwnull is writable, noinit
1804 # An integer literal
1808 # An integer literal in decimal format
1811 var n_number
: TNumber is writable, noinit
1813 # An integer literal in hexadecimal format
1816 var n_hex_number
: THexNumber is writable, noinit
1821 var n_float
: TFloat is writable, noinit
1823 # A character literal
1826 var n_char
: TChar is writable, noinit
1829 abstract class AStringFormExpr
1831 var n_string
: Token is writable, noinit
1834 # A simple string. eg. `"abc"`
1836 super AStringFormExpr
1839 # The start of a superstring. eg `"abc{`
1840 class AStartStringExpr
1841 super AStringFormExpr
1844 # The middle of a superstring. eg `}abc{`
1845 class AMidStringExpr
1846 super AStringFormExpr
1849 # The end of a superstrng. eg `}abc"`
1850 class AEndStringExpr
1851 super AStringFormExpr
1854 # A superstring literal. eg `"a{x}b{y}c"`
1855 # Each part is modeled a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
1856 class ASuperstringExpr
1858 var n_exprs
= new ANodes[AExpr](self)
1861 # A simple parenthesis. eg `(x)`
1864 var n_opar
: TOpar is writable, noinit
1865 var n_expr
: AExpr is writable, noinit
1866 var n_cpar
: TCpar is writable, noinit
1869 # A cast, against a type or `not null`
1872 var n_expr
: AExpr is writable, noinit
1873 var n_kwas
: TKwas is writable, noinit
1874 var n_opar
: nullable TOpar = null is writable
1875 var n_cpar
: nullable TCpar = null is writable
1878 # A type cast. eg `x.as(T)`
1881 var n_type
: AType is writable, noinit
1884 # A as-not-null cast. eg `x.as(not null)`
1885 class AAsNotnullExpr
1887 var n_kwnot
: TKwnot is writable, noinit
1888 var n_kwnull
: TKwnull is writable, noinit
1891 # A is-set check of old-style attributes. eg `isset x._a`
1892 class AIssetAttrExpr
1894 var n_kwisset
: TKwisset is writable, noinit
1897 # An ellipsis notation used to pass an expression as it, in a vararg parameter
1900 var n_expr
: AExpr is writable, noinit
1901 var n_dotdotdot
: TDotdotdot is writable, noinit
1904 # A list of expression separated with commas (arguments for instance)
1907 var n_exprs
= new ANodes[AExpr](self)
1910 # A special expression that encapsulates a static type
1911 # Can only be found in special construction like arguments of annotations.
1914 var n_type
: AType is writable, noinit
1917 # A special expression that encapsulates a method identifier
1918 # Can only be found in special construction like arguments of annotations.
1921 # The receiver, is any
1922 var n_expr
: AExpr is writable, noinit
1923 var n_id
: AMethid is writable, noinit
1926 # A special expression that encapsulate an annotation
1927 # Can only be found in special construction like arguments of annotations.
1932 # A special expression to debug types
1933 class ADebugTypeExpr
1935 var n_kwdebug
: TKwdebug is writable, noinit
1936 var n_kwtype
: TKwtype is writable, noinit
1937 var n_expr
: AExpr is writable, noinit
1938 var n_type
: AType is writable, noinit
1941 # A list of expression separated with commas (arguments for instance)
1942 abstract class AExprs
1944 var n_exprs
= new ANodes[AExpr](self)
1947 # A simple list of expressions
1952 # A list of expressions enclosed in parentheses
1955 var n_opar
: TOpar is writable, noinit
1956 var n_cpar
: TCpar is writable, noinit
1959 # A list of expressions enclosed in brackets
1962 var n_obra
: TObra is writable, noinit
1963 var n_cbra
: TCbra is writable, noinit
1966 # A complex assignment operator. (`+=` and `-=`)
1967 abstract class AAssignOp
1971 # The `+=` assignment operation
1974 var n_pluseq
: TPluseq is writable, noinit
1977 # The `-=` assignment operator
1978 class AMinusAssignOp
1980 var n_minuseq
: TMinuseq is writable, noinit
1983 # A possibly fully-qualified module identifier
1986 var n_quad
: nullable TQuad = null is writable
1987 var n_path
= new ANodes[TId](self)
1988 var n_id
: TId is writable, noinit
1991 # A language declaration for an extern block
1994 var n_kwin
: TKwin is writable, noinit
1995 var n_string
: TString is writable, noinit
1998 # An full extern block
1999 class AExternCodeBlock
2001 var n_in_language
: nullable AInLanguage = null is writable
2002 var n_extern_code_segment
: TExternCodeSegment is writable, noinit
2005 # A possible full method qualifier.
2008 var n_quad
: nullable TQuad = null is writable
2009 var n_id
= new ANodes[TId](self)
2010 var n_classid
: nullable TClassid = null is writable
2013 # A documentation of a definition
2014 # It contains the block of comments just above the declaration
2017 var n_comment
= new ANodes[TComment](self)
2020 # A group of annotation on a node
2023 var n_at
: nullable TAt = null is writable
2024 var n_opar
: nullable TOpar = null is writable
2025 var n_items
= new ANodes[AAnnotation](self)
2026 var n_cpar
: nullable TCpar = null is writable
2029 # A single annotation
2032 var n_atid
: AAtid is writable, noinit
2033 var n_opar
: nullable TOpar = null is writable
2034 var n_args
= new ANodes[AExpr](self)
2035 var n_cpar
: nullable TCpar = null is writable
2038 # An annotation name
2039 abstract class AAtid
2041 var n_id
: Token is writable, noinit
2044 # An annotation name based on an identifier
2049 # An annotation name based on the keyword `extern`
2054 # An annotation name based on the keyword `import`
2059 # An annotation name based on the keyword `abstract`
2060 class AKwabstractAtid
2064 # The root of the AST
2067 var n_base
: nullable AModule is writable
2068 var n_eof
: EOF is writable