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 var _location
: nullable Location = null
25 # Location is set during AST building. Once built, location cannon be null.
26 # However, manual instantiated nodes may need more care.
27 fun location
: Location do return _location
.as(not null)
29 # The location of the important part of the node (identifier or whatever)
30 fun hot_location
: Location do return location
32 # Display a message for the colored location of the node
33 fun debug
(message
: String)
35 sys
.stderr
.write
"{hot_location} {self.class_name}: {message}\n{hot_location.colored_line("0;32")}\n"
38 # Parent of the node in the AST
39 var parent
: nullable ANode = null
41 # The topmost ancestor of the element
42 # This just apply `parent` until the first one
48 if p
== null then return res
53 # The most specific common parent between `self` and `other`
54 # Return null if the two node are unrelated (distinct root)
55 fun common_parent
(other
: ANode): nullable ANode
57 # First, get the same depth
58 var s
: nullable ANode = self
59 var o
: nullable ANode = other
60 var d
= s
.depth
- o
.depth
69 assert o
.depth
== s
.depth
70 # Second, go up until same in found
78 # Number of nodes between `self` and the `root` of the AST
79 # ENSURE `self == self.root implies result == 0 `
80 # ENSURE `self != self.root implies result == self.parent.depth + 1`
87 if p
== null then return res
93 # Protect from invalid instantiation of nodes
96 # Replace a child with an other node in the AST
97 private fun replace_child
(old_child
: ANode, new_child
: nullable ANode) is abstract
99 # Detach a node from its parent
100 # Aborts if the node is not detashable. use `replace_with` instead
101 # REQUIRE: parent != null
102 # REQUIRE: is_detachable
103 # ENDURE: parent == null
106 assert parent
!= null
107 parent
.replace_child
(self, null)
111 # Replace itself with an other node in the AST
112 # REQUIRE: parent != null
113 # ENSURE: node.parent == old(parent)
114 # ENSURE: parent == null
115 fun replace_with
(node
: ANode)
117 assert parent
!= null
118 parent
.replace_child
(self, node
)
122 # Visit all nodes in order.
123 # Thus, call `v.enter_visit(e)` for each child `e`
124 fun visit_all
(v
: Visitor) is abstract
127 # A sequence of nodes
128 # There is a specifc class (instead of a using Array) to track the parent/child relation when nodes are added or removed
129 class ANodes[E
: ANode]
131 private var parent
: ANode
132 private var items
= new Array[E
]
133 redef fun iterator
do return items
.iterator
134 redef fun length
do return items
.length
135 redef fun is_empty
do return items
.is_empty
154 var res
= items
.shift
166 redef fun []=(index
, e
)
168 hook_remove
(self[index
])
172 redef fun remove_at
(index
)
174 hook_remove
(items
[index
])
175 items
.remove_at
(index
)
177 private fun hook_add
(e
: E
)
179 #assert e.parent == null
182 private fun hook_remove
(e
: E
)
184 assert e
.parent
== parent
188 # Used in parent contructor to fill elements
189 private fun unsafe_add_all
(nodes
: Collection[Object])
191 var parent
= self.parent
199 private fun replace_child
(old_child
: ANode, new_child
: nullable ANode): Bool
201 var parent
= self.parent
202 for i
in [0..length
[ do
203 if self[i
] == old_child
then
204 if new_child
!= null then
205 assert new_child
isa E
207 new_child
.parent
= parent
217 private fun visit_all
(v
: Visitor)
219 for n
in self do v
.enter_visit
(n
)
223 # Ancestor of all tokens
224 # A token is a node that has a `text` but no children.
228 # The raw content on the token
229 fun text
: String is abstract
230 fun text
=(text
: String) is abstract
232 # The previous token in the Lexer.
233 # May have disapeared in the AST
234 var prev_token
: nullable Token = null
236 # The next token in the Lexer.
237 # May have disapeared in the AST
238 var next_token
: nullable Token = null
240 # The verbatim blank text between `prev_token` and `self`
241 fun blank_before
: String
243 if prev_token
== null then return ""
244 var from
= prev_token
.location
.pend
+1
245 var to
= location
.pstart
246 return location
.file
.string
.substring
(from
,to-from
)
249 redef fun to_s
: String do
253 redef fun visit_all
(v
: Visitor) do end
254 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode) do end
257 redef class SourceFile
258 # The first token parser by the lexer
259 # May have disapeared in the final AST
260 var first_token
: nullable Token = null
262 # The first token parser by the lexer
263 # May have disapeared in the final AST
264 var last_token
: nullable Token = null
267 # Ancestor of all productions
268 # A production is a node without text but that usually has children.
272 fun location
=(l
: Location) do _location
= l
274 # All the annotations attached directly to the node
275 readable writable var _n_annotations
: nullable AAnnotations = null
277 redef fun replace_with
(n
: ANode)
281 if n
._location
== null then n
._location
= _location
285 # Abstract standard visitor on the AST
286 abstract class Visitor
287 # What the visitor do when a node is visited
288 # Concrete visitors should implement this method.
290 protected fun visit
(e
: ANode) is abstract
292 # Ask the visitor to visit a given node.
293 # Usually automatically called by visit_all* methods.
294 # This method should not be redefined
295 fun enter_visit
(e
: nullable ANode)
297 if e
== null then return
298 var old
= _current_node
304 # The current visited node
305 readable writable var _current_node
: nullable ANode = null
308 # Token of end of line (basically `\n`)
317 # Token of a line of comments
318 # Starts with the `#` and contains the final end-of-line (if any)
323 # A token associated with a keyword
324 abstract class TokenKeyword
328 return "keyword '{text}'"
512 # A token associated with an operator (and other lookalike symbols)
513 abstract class TokenOperator
517 return "operator '{text}'"
584 # A class (or formal type) identifier. They start with an uppercase.
589 do return "type identifier '{text}'"
593 # A standard identifier (variable, method...). They start with a lowercase.
598 do return "identifier '{text}'"
602 # An attribute identifier. They start with an underscore.
607 do return "attribute '{text}'"
611 # A token of a literal value (string, integer, etc).
612 abstract class TokenLiteral
616 do return "literal value '{text}'"
649 do return "malformed string {text}"
658 do return "malformed character {text}"
662 class TExternCodeSegment
686 # The main node of a Nit source-file
690 readable writable var _n_moduledecl
: nullable AModuledecl = null
691 readable var _n_imports
: ANodes[AImport] = new ANodes[AImport](self)
692 readable var _n_extern_code_blocks
: ANodes[AExternCodeBlock] = new ANodes[AExternCodeBlock](self)
693 readable var _n_classdefs
: ANodes[AClassdef] = new ANodes[AClassdef](self)
697 # The declaration of the module with the documentation, name, and annotations
700 readable writable var _n_doc
: nullable ADoc = null
701 readable writable var _n_kwmodule
: TKwmodule
702 readable writable var _n_name
: AModuleName
706 # A import clause of a module
707 abstract class AImport
711 # A standard import clause. eg `import x`
714 readable writable var _n_visibility
: AVisibility
715 readable writable var _n_kwimport
: TKwimport
716 readable writable var _n_name
: AModuleName
720 # The special import clause of the kernel module. eg `import end`
723 readable writable var _n_visibility
: AVisibility
724 readable writable var _n_kwimport
: TKwimport
725 readable writable var _n_kwend
: TKwend
729 # A visibility modifier
731 # The public visibility is an empty production (no keyword).
733 # Note: even if some visibilities are only valid on some placse (for instance, no `protected` class or no `intrude` method)
734 # the parser has no such a restriction, therefore the semantic phases has to check that the visibilities make sense.
735 abstract class AVisibility
738 class APublicVisibility
741 class APrivateVisibility
743 readable writable var _n_kwprivate
: TKwprivate
746 class AProtectedVisibility
748 readable writable var _n_kwprotected
: TKwprotected
751 class AIntrudeVisibility
753 readable writable var _n_kwintrude
: TKwintrude
758 # While most definition are `AStdClassdef`
759 # There is tow special case of class definition
760 abstract class AClassdef
762 readable var _n_propdefs
: ANodes[APropdef] = new ANodes[APropdef](self)
766 # A standard class definition with a name, superclasses and properties
769 readable writable var _n_doc
: nullable ADoc = null
770 readable writable var _n_kwredef
: nullable TKwredef = null
771 readable writable var _n_visibility
: AVisibility
772 readable writable var _n_classkind
: AClasskind
773 readable writable var _n_id
: nullable TClassid = null
774 readable var _n_formaldefs
: ANodes[AFormaldef] = new ANodes[AFormaldef](self)
775 readable writable var _n_extern_code_block
: nullable AExternCodeBlock = null
776 readable var _n_superclasses
: ANodes[ASuperclass] = new ANodes[ASuperclass](self)
777 readable writable var _n_kwend
: TKwend
778 redef fun hot_location
do return n_id
.location
782 # The implicit class definition of the implicit main method
787 # The implicit class definition of the top-level methods
792 # The modifier for the kind of class (abstract, interface, etc.)
793 abstract class AClasskind
796 class AConcreteClasskind
798 readable writable var _n_kwclass
: TKwclass
801 class AAbstractClasskind
803 readable writable var _n_kwabstract
: TKwabstract
804 readable writable var _n_kwclass
: TKwclass
807 class AInterfaceClasskind
809 readable writable var _n_kwinterface
: TKwinterface
814 readable writable var _n_kwenum
: TKwenum
817 class AExternClasskind
819 readable writable var _n_kwextern
: TKwextern
820 readable writable var _n_kwclass
: nullable TKwclass = null
824 # The definition of a formal generic parameter type. eg `X: Y`
827 readable writable var _n_id
: TClassid
828 # The bound of the parameter type
829 readable writable var _n_type
: nullable AType = null
833 # A super-class. eg `super X`
836 readable writable var _n_kwsuper
: TKwsuper
837 readable writable var _n_type
: AType
841 # The definition of a property
842 abstract class APropdef
844 readable writable var _n_doc
: nullable ADoc = null
845 readable writable var _n_kwredef
: nullable TKwredef = null
846 readable writable var _n_visibility
: nullable AVisibility = null
849 # A definition of an attribute
850 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
853 readable writable var _n_kwvar
: TKwvar
855 # The identifier for an old-style attribute (null if new-style)
856 readable writable var _n_id
: nullable TAttrid
858 # The identifier for a new-style attribute (null if old-style)
859 readable writable var _n_id2
: nullable TId
861 readable writable var _n_type
: nullable AType = null
862 readable writable var _n_readable
: nullable AAble = null
863 readable writable var _n_writable
: nullable AAble = null
865 # The initial value, if any
866 readable writable var _n_expr
: nullable AExpr = null
867 redef fun hot_location
869 if n_id
!= null then return n_id
.location
else return n_id2
.location
874 # A definition of all kind of method (including constructors)
875 abstract class AMethPropdef
877 readable writable var _n_kwmeth
: nullable TKwmeth = null
878 readable writable var _n_kwinit
: nullable TKwinit = null
879 readable writable var _n_kwnew
: nullable TKwnew = null
880 readable writable var _n_methid
: nullable AMethid = null
881 readable writable var _n_signature
: nullable ASignature = null
882 readable writable var _n_block
: nullable AExpr = null
883 readable writable var _n_extern
: nullable TString = null
884 readable writable var _n_extern_calls
: nullable AExternCalls = null
885 readable writable var _n_extern_code_block
: nullable AExternCodeBlock = null
886 redef fun hot_location
888 if n_methid
!= null then
889 return n_methid
.location
890 else if n_kwinit
!= null then
891 return n_kwinit
.location
892 else if n_kwnew
!= null then
893 return n_kwnew
.location
900 # A method marked abstract
901 # *deferred* is a old synonynmous of *abstract* that comes from PRM, that comes from Eiffel.
902 class ADeferredMethPropdef
906 # A method marked intern
907 class AInternMethPropdef
911 # A method of a constructor marked extern
912 abstract class AExternPropdef
916 # A method marked extern
917 class AExternMethPropdef
921 # A method with a body
922 class AConcreteMethPropdef
927 abstract class AInitPropdef
931 # A constructor with a body
932 class AConcreteInitPropdef
933 super AConcreteMethPropdef
937 class AInternNewPropdef
938 super AInternMethPropdef
942 # A constructor marked extern (defined with the `new` keyword)
943 class AExternInitPropdef
948 # The implicit main method
949 class AMainMethPropdef
950 super AConcreteMethPropdef
953 # Declaration of callbacks for extern methods
956 readable writable var _n_kwimport
: TKwimport
957 readable var _n_extern_calls
: ANodes[AExternCall] = new ANodes[AExternCall](self)
960 abstract class AExternCall
963 abstract class APropExternCall
966 class ALocalPropExternCall
967 super APropExternCall
968 readable writable var _n_methid
: AMethid
971 class AFullPropExternCall
972 super APropExternCall
973 readable writable var _n_type
: AType
974 readable writable var _n_dot
: nullable TDot = null
975 readable writable var _n_methid
: AMethid
978 class AInitPropExternCall
979 super APropExternCall
980 readable writable var _n_type
: AType
983 class ASuperExternCall
985 readable writable var _n_kwsuper
: TKwsuper
988 abstract class ACastExternCall
991 class ACastAsExternCall
992 super ACastExternCall
993 readable writable var _n_from_type
: AType
994 readable writable var _n_dot
: nullable TDot = null
995 readable writable var _n_kwas
: TKwas
996 readable writable var _n_to_type
: AType
999 class AAsNullableExternCall
1000 super ACastExternCall
1001 readable writable var _n_type
: AType
1002 readable writable var _n_kwas
: TKwas
1003 readable writable var _n_kwnullable
: TKwnullable
1006 class AAsNotNullableExternCall
1007 super ACastExternCall
1008 readable writable var _n_type
: AType
1009 readable writable var _n_kwas
: TKwas
1010 readable writable var _n_kwnot
: TKwnot
1011 readable writable var _n_kwnullable
: TKwnullable
1015 # A definition of a virtual type
1018 readable writable var _n_kwtype
: TKwtype
1019 readable writable var _n_id
: TClassid
1020 readable writable var _n_type
: AType
1024 # A `writable` or `readable` modifier
1025 abstract class AAble
1027 readable writable var _n_visibility
: nullable AVisibility = null
1028 readable writable var _n_kwredef
: nullable TKwredef = null
1032 # A `readable` modifier
1035 readable writable var _n_kwreadable
: TKwreadable
1039 # A `writable` modifier
1042 readable writable var _n_kwwritable
: TKwwritable
1046 # The identifier of a method in a method declaration.
1047 # There is a specific class because of operator and setters.
1048 abstract class AMethid
1053 readable writable var _n_id
: TId
1058 readable writable var _n_plus
: TPlus
1063 readable writable var _n_minus
: TMinus
1068 readable writable var _n_star
: TStar
1073 readable writable var _n_slash
: TSlash
1076 class APercentMethid
1078 readable writable var _n_percent
: TPercent
1083 readable writable var _n_eq
: TEq
1088 readable writable var _n_ne
: TNe
1093 readable writable var _n_le
: TLe
1098 readable writable var _n_ge
: TGe
1103 readable writable var _n_lt
: TLt
1108 readable writable var _n_gt
: TGt
1113 readable writable var _n_ll
: TLl
1118 readable writable var _n_gg
: TGg
1123 readable writable var _n_obra
: TObra
1124 readable writable var _n_cbra
: TCbra
1127 class AStarshipMethid
1129 readable writable var _n_starship
: TStarship
1134 readable writable var _n_id
: TId
1135 readable writable var _n_assign
: TAssign
1138 class ABraassignMethid
1140 readable writable var _n_obra
: TObra
1141 readable writable var _n_cbra
: TCbra
1142 readable writable var _n_assign
: TAssign
1146 # A signature in a method definition. eg `(x,y:X,z:Z):T`
1149 readable writable var _n_opar
: nullable TOpar = null
1150 readable var _n_params
: ANodes[AParam] = new ANodes[AParam](self)
1151 readable writable var _n_cpar
: nullable TCpar = null
1152 readable writable var _n_type
: nullable AType = null
1156 # A parameter definition in a signature. eg `x:X`
1159 readable writable var _n_id
: TId
1160 readable writable var _n_type
: nullable AType = null
1161 readable writable var _n_dotdotdot
: nullable TDotdotdot = null
1165 # A static type. eg `nullable X[Y]`
1168 readable writable var _n_kwnullable
: nullable TKwnullable = null
1170 # The name of the class or of the formal type
1171 readable writable var _n_id
: TClassid
1173 # Type arguments for a generic type
1174 readable var _n_types
: ANodes[AType] = new ANodes[AType](self)
1178 # A label at the end of a block or in a break/continue statement. eg `label x`
1181 readable writable var _n_kwlabel
: TKwlabel
1182 readable writable var _n_id
: TId
1186 # Expression and statements
1187 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1188 abstract class AExpr
1192 # A sequence of AExpr (usually statements)
1193 # The last AExpr gives the value of the whole block
1196 readable var _n_expr
: ANodes[AExpr] = new ANodes[AExpr](self)
1197 readable writable var _n_kwend
: nullable TKwend = null
1201 # A declaration of a local variable. eg `var x: X = y`
1204 readable writable var _n_kwvar
: TKwvar
1205 readable writable var _n_id
: TId
1206 readable writable var _n_type
: nullable AType = null
1207 readable writable var _n_assign
: nullable TAssign = null
1209 # The initial value, if any
1210 readable writable var _n_expr
: nullable AExpr = null
1214 # A `return` statement. eg `return x`
1217 readable writable var _n_kwreturn
: nullable TKwreturn = null
1218 readable writable var _n_expr
: nullable AExpr = null
1222 # Something that has a label.
1223 abstract class ALabelable
1225 readable writable var _n_label
: nullable ALabel = null
1229 # A `break` statement.
1233 readable writable var _n_kwbreak
: TKwbreak
1234 readable writable var _n_expr
: nullable AExpr = null
1238 # An `abort` statement
1241 readable writable var _n_kwabort
: TKwabort
1245 # A `continue` statement
1249 readable writable var _n_kwcontinue
: nullable TKwcontinue = null
1250 readable writable var _n_expr
: nullable AExpr = null
1258 readable writable var _n_kwdo
: TKwdo
1259 readable writable var _n_block
: nullable AExpr = null
1266 readable writable var _n_kwif
: TKwif
1267 readable writable var _n_expr
: AExpr
1268 readable writable var _n_then
: nullable AExpr = null
1269 readable writable var _n_else
: nullable AExpr = null
1276 readable writable var _n_kwif
: TKwif
1277 readable writable var _n_expr
: AExpr
1278 readable writable var _n_kwthen
: TKwthen
1279 readable writable var _n_then
: AExpr
1280 readable writable var _n_kwelse
: TKwelse
1281 readable writable var _n_else
: AExpr
1285 # A `while` statement
1289 readable writable var _n_kwwhile
: TKwwhile
1290 readable writable var _n_expr
: AExpr
1291 readable writable var _n_kwdo
: TKwdo
1292 readable writable var _n_block
: nullable AExpr = null
1296 # A `loop` statement
1300 readable writable var _n_kwloop
: TKwloop
1301 readable writable var _n_block
: nullable AExpr = null
1309 readable writable var _n_kwfor
: TKwfor
1310 readable var _n_ids
: ANodes[TId] = new ANodes[TId](self)
1311 readable writable var _n_expr
: AExpr
1312 readable writable var _n_kwdo
: TKwdo
1313 readable writable var _n_block
: nullable AExpr = null
1317 # An `assert` statement
1320 readable writable var _n_kwassert
: TKwassert
1321 readable writable var _n_id
: nullable TId = null
1322 readable writable var _n_expr
: AExpr
1323 readable writable var _n_else
: nullable AExpr = null
1327 # Whatever is a simple assignment. eg `= something`
1328 abstract class AAssignFormExpr
1330 readable writable var _n_assign
: TAssign
1331 readable writable var _n_value
: AExpr
1335 # Whatever is a combined assignment. eg `+= something`
1336 abstract class AReassignFormExpr
1338 readable writable var _n_assign_op
: AAssignOp
1339 readable writable var _n_value
: AExpr
1343 # A `once` expression. eg `once x`
1346 readable writable var _n_kwonce
: TKwonce
1350 # A polymorphic invocation of a method
1351 # The form of the invocation (name, arguments, etc) are specific
1352 abstract class ASendExpr
1354 # The receiver of the method invocation
1355 readable writable var _n_expr
: AExpr
1359 # A binary operation on a method
1360 abstract class ABinopExpr
1362 # The second operand of the operation
1363 # Note: the receiver (`n_expr`) is the first operand
1364 readable writable var _n_expr2
: AExpr
1368 # Something that is boolean expression
1369 abstract class ABoolExpr
1376 readable writable var _n_expr
: AExpr
1377 readable writable var _n_expr2
: AExpr
1381 # A `and` expression
1384 readable writable var _n_expr
: AExpr
1385 readable writable var _n_expr2
: AExpr
1389 # A `or else` expression
1392 readable writable var _n_expr
: AExpr
1393 readable writable var _n_expr2
: AExpr
1397 # A `implies` expression
1400 readable writable var _n_expr
: AExpr
1401 readable writable var _n_expr2
: AExpr
1405 # A `not` expression
1408 readable writable var _n_kwnot
: TKwnot
1409 readable writable var _n_expr
: AExpr
1453 # A type-ckeck expression. eg `x isa T`
1456 readable writable var _n_expr
: AExpr
1457 readable writable var _n_type
: AType
1471 # A `<=>` expression
1491 # A unary minus expression. eg `-x`
1494 readable writable var _n_minus
: TMinus
1498 # An explicit instantiation. eg `new T`
1501 readable writable var _n_kwnew
: TKwnew
1502 readable writable var _n_type
: AType
1504 # The name of the named-constructor, if any
1505 readable writable var _n_id
: nullable TId = null
1506 readable writable var _n_args
: AExprs
1510 # Whatever is a old-style attribute access
1511 abstract class AAttrFormExpr
1514 # The receiver of the attribute
1515 readable writable var _n_expr
: AExpr
1517 # The name of the attribute
1518 readable writable var _n_id
: TAttrid
1523 # The read of an attribute. eg `x._a`
1528 # The assignment of an attribute. eg `x._a=y`
1529 class AAttrAssignExpr
1531 super AAssignFormExpr
1534 # Whatever looks-like a call with a standard method and any number of arguments.
1535 abstract class ACallFormExpr
1538 # The name of the method
1539 readable writable var _n_id
: TId
1541 # The arguments of the call
1542 readable writable var _n_args
: AExprs
1546 # A complex setter call (standard or brackets)
1547 abstract class ASendReassignFormExpr
1549 super AReassignFormExpr
1552 # A complex attribute assignment. eg `x._a+=y`
1553 class AAttrReassignExpr
1555 super AReassignFormExpr
1558 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
1559 # 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`.
1560 # Semantic analysis have to transform them to instance of `AVarExpr`.
1565 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
1566 # 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`.
1567 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
1568 class ACallAssignExpr
1570 super AAssignFormExpr
1573 # 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.
1574 # 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`.
1575 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
1576 class ACallReassignExpr
1578 super ASendReassignFormExpr
1581 # A call to `super`. OR a call of a super-constructor
1584 readable writable var _n_qualified
: nullable AQualified = null
1585 readable writable var _n_kwsuper
: TKwsuper
1586 readable writable var _n_args
: AExprs
1590 # A call to the `init` constructor.
1591 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a ACallFormExpr.
1594 readable writable var _n_kwinit
: TKwinit
1595 readable writable var _n_args
: AExprs
1599 # Whatever looks-like a call of the brackets `[]` operator.
1600 abstract class ABraFormExpr
1602 readable writable var _n_args
: AExprs
1606 # A call of the brackets operator. eg `x[y,z]`
1611 # A setter call of the bracket operator. eg `x[y,z]=t`
1612 class ABraAssignExpr
1614 super AAssignFormExpr
1617 # Whatever is an access to a local variable
1618 abstract class AVarFormExpr
1620 readable writable var _n_id
: TId
1624 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
1625 class ABraReassignExpr
1627 super ASendReassignFormExpr
1630 # A local variable read access.
1631 # The parser cannot instantiate them, see `ACallExpr`.
1636 # A local variable simple assigment access
1637 # The parser cannot instantiate them, see `ACallAssignExpr`.
1638 class AVarAssignExpr
1640 super AAssignFormExpr
1643 # A local variable complex assignment access
1644 # The parser cannot instantiate them, see `ACallReassignExpr`.
1645 class AVarReassignExpr
1647 super AReassignFormExpr
1650 # A literal range, open or closed
1651 abstract class ARangeExpr
1653 readable writable var _n_expr
: AExpr
1654 readable writable var _n_expr2
: AExpr
1658 # A closed literal range. eg `[x..y]`
1661 readable writable var _n_obra
: TObra
1662 readable writable var _n_cbra
: TCbra
1666 # An open literal range. eg `[x..y[`
1669 readable writable var _n_obra
: TObra
1670 readable writable var _n_cbra
: TObra
1674 # A literal array. eg. `[x,y,z]`
1677 readable writable var _n_exprs
: AExprs
1684 readable writable var _n_kwself
: nullable TKwself
1688 # When there is no explicit receiver, `self` is implicit
1689 class AImplicitSelfExpr
1693 # A `true` boolean literal constant
1696 readable writable var _n_kwtrue
: TKwtrue
1699 # A `false` boolean literal constant
1702 readable writable var _n_kwfalse
: TKwfalse
1705 # A `null` literal constant
1708 readable writable var _n_kwnull
: TKwnull
1711 # An integer literal
1715 # An integer literal in decimal format
1718 readable writable var _n_number
: TNumber
1721 # An integer literal in hexadecimal format
1724 readable writable var _n_hex_number
: THexNumber
1730 readable writable var _n_float
: TFloat
1733 # A character literal
1736 readable writable var _n_char
: TChar
1740 abstract class AStringFormExpr
1742 readable writable var _n_string
: Token
1746 # A simple string. eg. `"abc"`
1748 super AStringFormExpr
1751 # The start of a superstring. eg `"abc{`
1752 class AStartStringExpr
1753 super AStringFormExpr
1756 # The middle of a superstring. eg `}abc{`
1757 class AMidStringExpr
1758 super AStringFormExpr
1761 # The end of a superstrng. eg `}abc"`
1762 class AEndStringExpr
1763 super AStringFormExpr
1766 # A superstring literal. eg `"a{x}b{y}c"`
1767 # Each part is modelized a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
1768 class ASuperstringExpr
1770 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1774 # A simple parenthesis. eg `(x)`
1777 readable writable var _n_opar
: TOpar
1778 readable writable var _n_cpar
: TCpar
1782 # Whatevej just contains (and mimic) an other expression
1783 abstract class AProxyExpr
1785 readable writable var _n_expr
: AExpr
1789 # A type cast. eg `x.as(T)`
1792 readable writable var _n_expr
: AExpr
1793 readable writable var _n_kwas
: TKwas
1794 readable writable var _n_opar
: nullable TOpar = null
1795 readable writable var _n_type
: AType
1796 readable writable var _n_cpar
: nullable TCpar = null
1800 # A as-not-null cast. eg `x.as(not null)`
1801 class AAsNotnullExpr
1803 readable writable var _n_expr
: AExpr
1804 readable writable var _n_kwas
: TKwas
1805 readable writable var _n_opar
: nullable TOpar = null
1806 readable writable var _n_kwnot
: TKwnot
1807 readable writable var _n_kwnull
: TKwnull
1808 readable writable var _n_cpar
: nullable TCpar = null
1812 # A is-set check of old-style attributes. eg `isset x._a`
1813 class AIssetAttrExpr
1815 readable writable var _n_kwisset
: TKwisset
1819 # A list of expression separated with commas (arguments for instance)
1820 abstract class AExprs
1822 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1826 class ADebugTypeExpr
1828 readable writable var _n_kwdebug
: TKwdebug
1829 readable writable var _n_kwtype
: TKwtype
1830 readable writable var _n_expr
: AExpr
1831 readable writable var _n_type
: AType
1835 # A simple list of expressions
1840 # A list of expressions enclosed in parentheses
1843 readable writable var _n_opar
: TOpar
1844 readable writable var _n_cpar
: TCpar
1848 # A list of expressions enclosed in brackets
1851 readable writable var _n_obra
: TObra
1852 readable writable var _n_cbra
: TCbra
1856 # A complex assignment operator. eg `+=`
1857 abstract class AAssignOp
1862 readable writable var _n_pluseq
: TPluseq
1865 class AMinusAssignOp
1867 readable writable var _n_minuseq
: TMinuseq
1873 readable writable var _n_quad
: nullable TQuad = null
1874 readable var _n_path
: ANodes[TId] = new ANodes[TId](self)
1875 readable writable var _n_id
: TId
1880 readable writable var _n_kwin
: TKwin
1881 readable writable var _n_string
: TString
1884 class AExternCodeBlock
1886 readable writable var _n_in_language
: nullable AInLanguage = null
1887 readable writable var _n_extern_code_segment
: TExternCodeSegment
1892 readable writable var _n_quad
: nullable TQuad = null
1893 readable var _n_id
: ANodes[TId] = new ANodes[TId](self)
1894 readable writable var _n_classid
: nullable TClassid = null
1898 # A documentation of a definition
1899 # It contains the block of comments just above the declaration
1902 readable var _n_comment
: ANodes[TComment] = new ANodes[TComment](self)
1908 readable writable var _n_at
: nullable TAt = null
1909 readable writable var _n_opar
: nullable TOpar = null
1910 readable var _n_items
: ANodes[AAnnotation] = new ANodes[AAnnotation](self)
1911 readable writable var _n_cpar
: nullable TCpar = null
1916 readable writable var _n_atid
: AAtid
1917 readable writable var _n_opar
: nullable TOpar = null
1918 readable var _n_args
: ANodes[AAtArg] = new ANodes[AAtArg](self)
1919 readable writable var _n_cpar
: nullable TCpar = null
1922 abstract class AAtArg
1927 readable writable var _n_type
: AType
1932 readable writable var _n_expr
: AExpr
1938 abstract class AAtid
1940 readable writable var _n_id
: Token
1952 class AKwreadableAtid
1955 class AKwwritableAtid
1962 # The root of the AST
1965 readable writable var _n_base
: nullable AModule
1966 readable writable var _n_eof
: EOF
1967 init(n_base
: nullable AModule, n_eof
: EOF)
1969 self._n_base
= n_base