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 # A constructor marked extern (defined with the `new` keyword)
938 class AExternInitPropdef
943 # The implicit main method
944 class AMainMethPropdef
945 super AConcreteMethPropdef
948 # Declaration of callbacks for extern methods
951 readable writable var _n_kwimport
: TKwimport
952 readable var _n_extern_calls
: ANodes[AExternCall] = new ANodes[AExternCall](self)
955 abstract class AExternCall
958 abstract class APropExternCall
961 class ALocalPropExternCall
962 super APropExternCall
963 readable writable var _n_methid
: AMethid
966 class AFullPropExternCall
967 super APropExternCall
968 readable writable var _n_type
: AType
969 readable writable var _n_dot
: nullable TDot = null
970 readable writable var _n_methid
: AMethid
973 class AInitPropExternCall
974 super APropExternCall
975 readable writable var _n_type
: AType
978 class ASuperExternCall
980 readable writable var _n_kwsuper
: TKwsuper
983 abstract class ACastExternCall
986 class ACastAsExternCall
987 super ACastExternCall
988 readable writable var _n_from_type
: AType
989 readable writable var _n_dot
: nullable TDot = null
990 readable writable var _n_kwas
: TKwas
991 readable writable var _n_to_type
: AType
994 class AAsNullableExternCall
995 super ACastExternCall
996 readable writable var _n_type
: AType
997 readable writable var _n_kwas
: TKwas
998 readable writable var _n_kwnullable
: TKwnullable
1001 class AAsNotNullableExternCall
1002 super ACastExternCall
1003 readable writable var _n_type
: AType
1004 readable writable var _n_kwas
: TKwas
1005 readable writable var _n_kwnot
: TKwnot
1006 readable writable var _n_kwnullable
: TKwnullable
1010 # A definition of a virtual type
1013 readable writable var _n_kwtype
: TKwtype
1014 readable writable var _n_id
: TClassid
1015 readable writable var _n_type
: AType
1019 # A `writable` or `readable` modifier
1020 abstract class AAble
1022 readable writable var _n_visibility
: nullable AVisibility = null
1023 readable writable var _n_kwredef
: nullable TKwredef = null
1027 # A `readable` modifier
1030 readable writable var _n_kwreadable
: TKwreadable
1034 # A `writable` modifier
1037 readable writable var _n_kwwritable
: TKwwritable
1041 # The identifier of a method in a method declaration.
1042 # There is a specific class because of operator and setters.
1043 abstract class AMethid
1048 readable writable var _n_id
: TId
1053 readable writable var _n_plus
: TPlus
1058 readable writable var _n_minus
: TMinus
1063 readable writable var _n_star
: TStar
1068 readable writable var _n_slash
: TSlash
1071 class APercentMethid
1073 readable writable var _n_percent
: TPercent
1078 readable writable var _n_eq
: TEq
1083 readable writable var _n_ne
: TNe
1088 readable writable var _n_le
: TLe
1093 readable writable var _n_ge
: TGe
1098 readable writable var _n_lt
: TLt
1103 readable writable var _n_gt
: TGt
1108 readable writable var _n_ll
: TLl
1113 readable writable var _n_gg
: TGg
1118 readable writable var _n_obra
: TObra
1119 readable writable var _n_cbra
: TCbra
1122 class AStarshipMethid
1124 readable writable var _n_starship
: TStarship
1129 readable writable var _n_id
: TId
1130 readable writable var _n_assign
: TAssign
1133 class ABraassignMethid
1135 readable writable var _n_obra
: TObra
1136 readable writable var _n_cbra
: TCbra
1137 readable writable var _n_assign
: TAssign
1141 # A signature in a method definition. eg `(x,y:X,z:Z):T`
1144 readable writable var _n_opar
: nullable TOpar = null
1145 readable var _n_params
: ANodes[AParam] = new ANodes[AParam](self)
1146 readable writable var _n_cpar
: nullable TCpar = null
1147 readable writable var _n_type
: nullable AType = null
1151 # A parameter definition in a signature. eg `x:X`
1154 readable writable var _n_id
: TId
1155 readable writable var _n_type
: nullable AType = null
1156 readable writable var _n_dotdotdot
: nullable TDotdotdot = null
1160 # A static type. eg `nullable X[Y]`
1163 readable writable var _n_kwnullable
: nullable TKwnullable = null
1165 # The name of the class or of the formal type
1166 readable writable var _n_id
: TClassid
1168 # Type arguments for a generic type
1169 readable var _n_types
: ANodes[AType] = new ANodes[AType](self)
1173 # A label at the end of a block or in a break/continue statement. eg `label x`
1176 readable writable var _n_kwlabel
: TKwlabel
1177 readable writable var _n_id
: TId
1181 # Expression and statements
1182 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1183 abstract class AExpr
1187 # A sequence of AExpr (usually statements)
1188 # The last AExpr gives the value of the whole block
1191 readable var _n_expr
: ANodes[AExpr] = new ANodes[AExpr](self)
1192 readable writable var _n_kwend
: nullable TKwend = null
1196 # A declaration of a local variable. eg `var x: X = y`
1199 readable writable var _n_kwvar
: TKwvar
1200 readable writable var _n_id
: TId
1201 readable writable var _n_type
: nullable AType = null
1202 readable writable var _n_assign
: nullable TAssign = null
1204 # The initial value, if any
1205 readable writable var _n_expr
: nullable AExpr = null
1209 # A `return` statement. eg `return x`
1212 readable writable var _n_kwreturn
: nullable TKwreturn = null
1213 readable writable var _n_expr
: nullable AExpr = null
1217 # Something that has a label.
1218 abstract class ALabelable
1220 readable writable var _n_label
: nullable ALabel = null
1224 # A `break` statement.
1228 readable writable var _n_kwbreak
: TKwbreak
1229 readable writable var _n_expr
: nullable AExpr = null
1233 # An `abort` statement
1236 readable writable var _n_kwabort
: TKwabort
1240 # A `continue` statement
1244 readable writable var _n_kwcontinue
: nullable TKwcontinue = null
1245 readable writable var _n_expr
: nullable AExpr = null
1253 readable writable var _n_kwdo
: TKwdo
1254 readable writable var _n_block
: nullable AExpr = null
1261 readable writable var _n_kwif
: TKwif
1262 readable writable var _n_expr
: AExpr
1263 readable writable var _n_then
: nullable AExpr = null
1264 readable writable var _n_else
: nullable AExpr = null
1271 readable writable var _n_kwif
: TKwif
1272 readable writable var _n_expr
: AExpr
1273 readable writable var _n_kwthen
: TKwthen
1274 readable writable var _n_then
: AExpr
1275 readable writable var _n_kwelse
: TKwelse
1276 readable writable var _n_else
: AExpr
1280 # A `while` statement
1284 readable writable var _n_kwwhile
: TKwwhile
1285 readable writable var _n_expr
: AExpr
1286 readable writable var _n_kwdo
: TKwdo
1287 readable writable var _n_block
: nullable AExpr = null
1291 # A `loop` statement
1295 readable writable var _n_kwloop
: TKwloop
1296 readable writable var _n_block
: nullable AExpr = null
1304 readable writable var _n_kwfor
: TKwfor
1305 readable var _n_ids
: ANodes[TId] = new ANodes[TId](self)
1306 readable writable var _n_expr
: AExpr
1307 readable writable var _n_kwdo
: TKwdo
1308 readable writable var _n_block
: nullable AExpr = null
1312 # An `assert` statement
1315 readable writable var _n_kwassert
: TKwassert
1316 readable writable var _n_id
: nullable TId = null
1317 readable writable var _n_expr
: AExpr
1318 readable writable var _n_else
: nullable AExpr = null
1322 # Whatever is a simple assignment. eg `= something`
1323 abstract class AAssignFormExpr
1325 readable writable var _n_assign
: TAssign
1326 readable writable var _n_value
: AExpr
1330 # Whatever is a combined assignment. eg `+= something`
1331 abstract class AReassignFormExpr
1333 readable writable var _n_assign_op
: AAssignOp
1334 readable writable var _n_value
: AExpr
1338 # A `once` expression. eg `once x`
1341 readable writable var _n_kwonce
: TKwonce
1345 # A polymorphic invocation of a method
1346 # The form of the invocation (name, arguments, etc) are specific
1347 abstract class ASendExpr
1349 # The receiver of the method invocation
1350 readable writable var _n_expr
: AExpr
1354 # A binary operation on a method
1355 abstract class ABinopExpr
1357 # The second operand of the operation
1358 # Note: the receiver (`n_expr`) is the first operand
1359 readable writable var _n_expr2
: AExpr
1363 # Something that is boolean expression
1364 abstract class ABoolExpr
1371 readable writable var _n_expr
: AExpr
1372 readable writable var _n_expr2
: AExpr
1376 # A `and` expression
1379 readable writable var _n_expr
: AExpr
1380 readable writable var _n_expr2
: AExpr
1384 # A `or else` expression
1387 readable writable var _n_expr
: AExpr
1388 readable writable var _n_expr2
: AExpr
1392 # A `implies` expression
1395 readable writable var _n_expr
: AExpr
1396 readable writable var _n_expr2
: AExpr
1400 # A `not` expression
1403 readable writable var _n_kwnot
: TKwnot
1404 readable writable var _n_expr
: AExpr
1448 # A type-ckeck expression. eg `x isa T`
1451 readable writable var _n_expr
: AExpr
1452 readable writable var _n_type
: AType
1466 # A `<=>` expression
1486 # A unary minus expression. eg `-x`
1489 readable writable var _n_minus
: TMinus
1493 # An explicit instantiation. eg `new T`
1496 readable writable var _n_kwnew
: TKwnew
1497 readable writable var _n_type
: AType
1499 # The name of the named-constructor, if any
1500 readable writable var _n_id
: nullable TId = null
1501 readable writable var _n_args
: AExprs
1505 # Whatever is a old-style attribute access
1506 abstract class AAttrFormExpr
1509 # The receiver of the attribute
1510 readable writable var _n_expr
: AExpr
1512 # The name of the attribute
1513 readable writable var _n_id
: TAttrid
1518 # The read of an attribute. eg `x._a`
1523 # The assignment of an attribute. eg `x._a=y`
1524 class AAttrAssignExpr
1526 super AAssignFormExpr
1529 # Whatever looks-like a call with a standard method and any number of arguments.
1530 abstract class ACallFormExpr
1533 # The name of the method
1534 readable writable var _n_id
: TId
1536 # The arguments of the call
1537 readable writable var _n_args
: AExprs
1541 # A complex setter call (standard or brackets)
1542 abstract class ASendReassignFormExpr
1544 super AReassignFormExpr
1547 # A complex attribute assignment. eg `x._a+=y`
1548 class AAttrReassignExpr
1550 super AReassignFormExpr
1553 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
1554 # 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`.
1555 # Semantic analysis have to transform them to instance of `AVarExpr`.
1560 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
1561 # 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`.
1562 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
1563 class ACallAssignExpr
1565 super AAssignFormExpr
1568 # 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.
1569 # 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`.
1570 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
1571 class ACallReassignExpr
1573 super ASendReassignFormExpr
1576 # A call to `super`. OR a call of a super-constructor
1579 readable writable var _n_qualified
: nullable AQualified = null
1580 readable writable var _n_kwsuper
: TKwsuper
1581 readable writable var _n_args
: AExprs
1585 # A call to the `init` constructor.
1586 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a ACallFormExpr.
1589 readable writable var _n_kwinit
: TKwinit
1590 readable writable var _n_args
: AExprs
1594 # Whatever looks-like a call of the brackets `[]` operator.
1595 abstract class ABraFormExpr
1597 readable writable var _n_args
: AExprs
1601 # A call of the brackets operator. eg `x[y,z]`
1606 # A setter call of the bracket operator. eg `x[y,z]=t`
1607 class ABraAssignExpr
1609 super AAssignFormExpr
1612 # Whatever is an access to a local variable
1613 abstract class AVarFormExpr
1615 readable writable var _n_id
: TId
1619 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
1620 class ABraReassignExpr
1622 super ASendReassignFormExpr
1625 # A local variable read access.
1626 # The parser cannot instantiate them, see `ACallExpr`.
1631 # A local variable simple assigment access
1632 # The parser cannot instantiate them, see `ACallAssignExpr`.
1633 class AVarAssignExpr
1635 super AAssignFormExpr
1638 # A local variable complex assignment access
1639 # The parser cannot instantiate them, see `ACallReassignExpr`.
1640 class AVarReassignExpr
1642 super AReassignFormExpr
1645 # A literal range, open or closed
1646 abstract class ARangeExpr
1648 readable writable var _n_expr
: AExpr
1649 readable writable var _n_expr2
: AExpr
1653 # A closed literal range. eg `[x..y]`
1656 readable writable var _n_obra
: TObra
1657 readable writable var _n_cbra
: TCbra
1661 # An open literal range. eg `[x..y[`
1664 readable writable var _n_obra
: TObra
1665 readable writable var _n_cbra
: TObra
1669 # A literal array. eg. `[x,y,z]`
1672 readable writable var _n_exprs
: AExprs
1679 readable writable var _n_kwself
: nullable TKwself
1683 # When there is no explicit receiver, `self` is implicit
1684 class AImplicitSelfExpr
1688 # A `true` boolean literal constant
1691 readable writable var _n_kwtrue
: TKwtrue
1694 # A `false` boolean literal constant
1697 readable writable var _n_kwfalse
: TKwfalse
1700 # A `null` literal constant
1703 readable writable var _n_kwnull
: TKwnull
1706 # An integer literal
1710 # An integer literal in decimal format
1713 readable writable var _n_number
: TNumber
1716 # An integer literal in hexadecimal format
1719 readable writable var _n_hex_number
: THexNumber
1725 readable writable var _n_float
: TFloat
1728 # A character literal
1731 readable writable var _n_char
: TChar
1735 abstract class AStringFormExpr
1737 readable writable var _n_string
: Token
1741 # A simple string. eg. `"abc"`
1743 super AStringFormExpr
1746 # The start of a superstring. eg `"abc{`
1747 class AStartStringExpr
1748 super AStringFormExpr
1751 # The middle of a superstring. eg `}abc{`
1752 class AMidStringExpr
1753 super AStringFormExpr
1756 # The end of a superstrng. eg `}abc"`
1757 class AEndStringExpr
1758 super AStringFormExpr
1761 # A superstring literal. eg `"a{x}b{y}c"`
1762 # Each part is modelized a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
1763 class ASuperstringExpr
1765 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1769 # A simple parenthesis. eg `(x)`
1772 readable writable var _n_opar
: TOpar
1773 readable writable var _n_cpar
: TCpar
1777 # Whatevej just contains (and mimic) an other expression
1778 abstract class AProxyExpr
1780 readable writable var _n_expr
: AExpr
1784 # A type cast. eg `x.as(T)`
1787 readable writable var _n_expr
: AExpr
1788 readable writable var _n_kwas
: TKwas
1789 readable writable var _n_opar
: nullable TOpar = null
1790 readable writable var _n_type
: AType
1791 readable writable var _n_cpar
: nullable TCpar = null
1795 # A as-not-null cast. eg `x.as(not null)`
1796 class AAsNotnullExpr
1798 readable writable var _n_expr
: AExpr
1799 readable writable var _n_kwas
: TKwas
1800 readable writable var _n_opar
: nullable TOpar = null
1801 readable writable var _n_kwnot
: TKwnot
1802 readable writable var _n_kwnull
: TKwnull
1803 readable writable var _n_cpar
: nullable TCpar = null
1807 # A is-set check of old-style attributes. eg `isset x._a`
1808 class AIssetAttrExpr
1810 readable writable var _n_kwisset
: TKwisset
1814 # A list of expression separated with commas (arguments for instance)
1815 abstract class AExprs
1817 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1821 class ADebugTypeExpr
1823 readable writable var _n_kwdebug
: TKwdebug
1824 readable writable var _n_kwtype
: TKwtype
1825 readable writable var _n_expr
: AExpr
1826 readable writable var _n_type
: AType
1830 # A simple list of expressions
1835 # A list of expressions enclosed in parentheses
1838 readable writable var _n_opar
: TOpar
1839 readable writable var _n_cpar
: TCpar
1843 # A list of expressions enclosed in brackets
1846 readable writable var _n_obra
: TObra
1847 readable writable var _n_cbra
: TCbra
1851 # A complex assignment operator. eg `+=`
1852 abstract class AAssignOp
1857 readable writable var _n_pluseq
: TPluseq
1860 class AMinusAssignOp
1862 readable writable var _n_minuseq
: TMinuseq
1868 readable writable var _n_quad
: nullable TQuad = null
1869 readable var _n_path
: ANodes[TId] = new ANodes[TId](self)
1870 readable writable var _n_id
: TId
1875 readable writable var _n_kwin
: TKwin
1876 readable writable var _n_string
: TString
1879 class AExternCodeBlock
1881 readable writable var _n_in_language
: nullable AInLanguage = null
1882 readable writable var _n_extern_code_segment
: TExternCodeSegment
1887 readable writable var _n_quad
: nullable TQuad = null
1888 readable var _n_id
: ANodes[TId] = new ANodes[TId](self)
1889 readable writable var _n_classid
: nullable TClassid = null
1893 # A documentation of a definition
1894 # It contains the block of comments just above the declaration
1897 readable var _n_comment
: ANodes[TComment] = new ANodes[TComment](self)
1903 readable writable var _n_at
: nullable TAt = null
1904 readable writable var _n_opar
: nullable TOpar = null
1905 readable var _n_items
: ANodes[AAnnotation] = new ANodes[AAnnotation](self)
1906 readable writable var _n_cpar
: nullable TCpar = null
1911 readable writable var _n_atid
: AAtid
1912 readable writable var _n_opar
: nullable TOpar = null
1913 readable var _n_args
: ANodes[AAtArg] = new ANodes[AAtArg](self)
1914 readable writable var _n_cpar
: nullable TCpar = null
1917 abstract class AAtArg
1922 readable writable var _n_type
: AType
1927 readable writable var _n_expr
: AExpr
1933 abstract class AAtid
1935 readable writable var _n_id
: Token
1947 class AKwreadableAtid
1950 class AKwwritableAtid
1957 # The root of the AST
1960 readable writable var _n_base
: nullable AModule
1961 readable writable var _n_eof
: EOF
1962 init(n_base
: nullable AModule, n_eof
: EOF)
1964 self._n_base
= n_base