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 print
"{hot_location} {self.class_name}: {message}\n{hot_location.colored_line("0;32")}"
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 redef fun to_s
: String do
244 redef fun visit_all
(v
: Visitor) do end
245 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode) do end
248 redef class SourceFile
249 # The first token parser by the lexer
250 # May have disapeared in the final AST
251 var first_token
: nullable Token = null
253 # The first token parser by the lexer
254 # May have disapeared in the final AST
255 var last_token
: nullable Token = null
258 # Ancestor of all productions
259 # A production is a node without text but that usually has children.
263 fun location
=(l
: Location) do _location
= l
265 # All the annotations attached directly to the node
266 readable writable var _n_annotations
: nullable AAnnotations = null
268 redef fun replace_with
(n
: ANode)
272 if n
._location
== null then n
._location
= _location
276 # Abstract standard visitor on the AST
277 abstract class Visitor
278 # What the visitor do when a node is visited
279 # Concrete visitors should implement this method.
281 protected fun visit
(e
: ANode) is abstract
283 # Ask the visitor to visit a given node.
284 # Usually automatically called by visit_all* methods.
285 # This method should not be redefined
286 fun enter_visit
(e
: nullable ANode)
288 if e
== null then return
289 var old
= _current_node
295 # The current visited node
296 readable writable var _current_node
: nullable ANode = null
299 # Token of end of line (basically `\n`)
308 # Token of a line of comments
309 # Starts with the `#` and contains the final end-of-line (if any)
314 # A token associated with a keyword
315 abstract class TokenKeyword
319 return "keyword '{text}'"
503 # A token associated with an operator (and other lookalike symbols)
504 abstract class TokenOperator
508 return "operator '{text}'"
575 # A class (or formal type) identifier. They start with an uppercase.
580 do return "type identifier '{text}'"
584 # A standard identifier (variable, method...). They start with a lowercase.
589 do return "identifier '{text}'"
593 # An attribute identifier. They start with an underscore.
598 do return "attribute '{text}'"
602 # A token of a literal value (string, integer, etc).
603 abstract class TokenLiteral
607 do return "literal value '{text}'"
640 do return "malformed string {text}"
649 do return "malformed character {text}"
653 class TExternCodeSegment
677 # The main node of a Nit source-file
681 readable writable var _n_moduledecl
: nullable AModuledecl = null
682 readable var _n_imports
: ANodes[AImport] = new ANodes[AImport](self)
683 readable var _n_extern_code_blocks
: ANodes[AExternCodeBlock] = new ANodes[AExternCodeBlock](self)
684 readable var _n_classdefs
: ANodes[AClassdef] = new ANodes[AClassdef](self)
688 # The declaration of the module with the documentation, name, and annotations
691 readable writable var _n_doc
: nullable ADoc = null
692 readable writable var _n_kwmodule
: TKwmodule
693 readable writable var _n_name
: AModuleName
697 # A import clause of a module
698 abstract class AImport
702 # A standard import clause. eg `import x`
705 readable writable var _n_visibility
: AVisibility
706 readable writable var _n_kwimport
: TKwimport
707 readable writable var _n_name
: AModuleName
711 # The special import clause of the kernel module. eg `import end`
714 readable writable var _n_visibility
: AVisibility
715 readable writable var _n_kwimport
: TKwimport
716 readable writable var _n_kwend
: TKwend
720 # A visibility modifier
722 # The public visibility is an empty production (no keyword).
724 # Note: even if some visibilities are only valid on some placse (for instance, no `protected` class or no `intrude` method)
725 # the parser has no such a restriction, therefore the semantic phases has to check that the visibilities make sense.
726 abstract class AVisibility
729 class APublicVisibility
732 class APrivateVisibility
734 readable writable var _n_kwprivate
: TKwprivate
737 class AProtectedVisibility
739 readable writable var _n_kwprotected
: TKwprotected
742 class AIntrudeVisibility
744 readable writable var _n_kwintrude
: TKwintrude
749 # While most definition are `AStdClassdef`
750 # There is tow special case of class definition
751 abstract class AClassdef
753 readable var _n_propdefs
: ANodes[APropdef] = new ANodes[APropdef](self)
757 # A standard class definition with a name, superclasses and properties
760 readable writable var _n_doc
: nullable ADoc = null
761 readable writable var _n_kwredef
: nullable TKwredef = null
762 readable writable var _n_visibility
: AVisibility
763 readable writable var _n_classkind
: AClasskind
764 readable writable var _n_id
: nullable TClassid = null
765 readable var _n_formaldefs
: ANodes[AFormaldef] = new ANodes[AFormaldef](self)
766 readable writable var _n_extern_code_block
: nullable AExternCodeBlock = null
767 readable var _n_superclasses
: ANodes[ASuperclass] = new ANodes[ASuperclass](self)
768 readable writable var _n_kwend
: TKwend
769 redef fun hot_location
do return n_id
.location
773 # The implicit class definition of the implicit main method
778 # The implicit class definition of the top-level methods
783 # The modifier for the kind of class (abstract, interface, etc.)
784 abstract class AClasskind
787 class AConcreteClasskind
789 readable writable var _n_kwclass
: TKwclass
792 class AAbstractClasskind
794 readable writable var _n_kwabstract
: TKwabstract
795 readable writable var _n_kwclass
: TKwclass
798 class AInterfaceClasskind
800 readable writable var _n_kwinterface
: TKwinterface
805 readable writable var _n_kwenum
: TKwenum
808 class AExternClasskind
810 readable writable var _n_kwextern
: TKwextern
811 readable writable var _n_kwclass
: nullable TKwclass = null
815 # The definition of a formal generic parameter type. eg `X: Y`
818 readable writable var _n_id
: TClassid
819 # The bound of the parameter type
820 readable writable var _n_type
: nullable AType = null
824 # A super-class. eg `super X`
827 readable writable var _n_kwsuper
: TKwsuper
828 readable writable var _n_type
: AType
832 # The definition of a property
833 abstract class APropdef
835 readable writable var _n_doc
: nullable ADoc = null
836 readable writable var _n_kwredef
: nullable TKwredef = null
837 readable writable var _n_visibility
: nullable AVisibility = null
840 # A definition of an attribute
841 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
844 readable writable var _n_kwvar
: TKwvar
846 # The identifier for an old-style attribute (null if new-style)
847 readable writable var _n_id
: nullable TAttrid
849 # The identifier for a new-style attribute (null if old-style)
850 readable writable var _n_id2
: nullable TId
852 readable writable var _n_type
: nullable AType = null
853 readable writable var _n_readable
: nullable AAble = null
854 readable writable var _n_writable
: nullable AAble = null
856 # The initial value, if any
857 readable writable var _n_expr
: nullable AExpr = null
858 redef fun hot_location
860 if n_id
!= null then return n_id
.location
else return n_id2
.location
865 # A definition of all kind of method (including constructors)
866 abstract class AMethPropdef
868 readable writable var _n_kwmeth
: nullable TKwmeth = null
869 readable writable var _n_kwinit
: nullable TKwinit = null
870 readable writable var _n_kwnew
: nullable TKwnew = null
871 readable writable var _n_methid
: nullable AMethid = null
872 readable writable var _n_signature
: nullable ASignature = null
873 readable writable var _n_block
: nullable AExpr = null
874 readable writable var _n_extern
: nullable TString = null
875 readable writable var _n_extern_calls
: nullable AExternCalls = null
876 readable writable var _n_extern_code_block
: nullable AExternCodeBlock = null
877 redef fun hot_location
879 if n_methid
!= null then
880 return n_methid
.location
881 else if n_kwinit
!= null then
882 return n_kwinit
.location
883 else if n_kwnew
!= null then
884 return n_kwnew
.location
891 # A method marked abstract
892 # *deferred* is a old synonynmous of *abstract* that comes from PRM, that comes from Eiffel.
893 class ADeferredMethPropdef
897 # A method marked intern
898 class AInternMethPropdef
902 # A method of a constructor marked extern
903 abstract class AExternPropdef
907 # A method marked extern
908 class AExternMethPropdef
912 # A method with a body
913 class AConcreteMethPropdef
918 abstract class AInitPropdef
922 # A constructor with a body
923 class AConcreteInitPropdef
924 super AConcreteMethPropdef
928 # A constructor marked extern (defined with the `new` keyword)
929 class AExternInitPropdef
934 # The implicit main method
935 class AMainMethPropdef
936 super AConcreteMethPropdef
939 # Declaration of callbacks for extern methods
942 readable writable var _n_kwimport
: TKwimport
943 readable var _n_extern_calls
: ANodes[AExternCall] = new ANodes[AExternCall](self)
946 abstract class AExternCall
949 abstract class APropExternCall
952 class ALocalPropExternCall
953 super APropExternCall
954 readable writable var _n_methid
: AMethid
957 class AFullPropExternCall
958 super APropExternCall
959 readable writable var _n_type
: AType
960 readable writable var _n_dot
: nullable TDot = null
961 readable writable var _n_methid
: AMethid
964 class AInitPropExternCall
965 super APropExternCall
966 readable writable var _n_type
: AType
969 class ASuperExternCall
971 readable writable var _n_kwsuper
: TKwsuper
974 abstract class ACastExternCall
977 class ACastAsExternCall
978 super ACastExternCall
979 readable writable var _n_from_type
: AType
980 readable writable var _n_dot
: nullable TDot = null
981 readable writable var _n_kwas
: TKwas
982 readable writable var _n_to_type
: AType
985 class AAsNullableExternCall
986 super ACastExternCall
987 readable writable var _n_type
: AType
988 readable writable var _n_kwas
: TKwas
989 readable writable var _n_kwnullable
: TKwnullable
992 class AAsNotNullableExternCall
993 super ACastExternCall
994 readable writable var _n_type
: AType
995 readable writable var _n_kwas
: TKwas
996 readable writable var _n_kwnot
: TKwnot
997 readable writable var _n_kwnullable
: TKwnullable
1001 # A definition of a virtual type
1004 readable writable var _n_kwtype
: TKwtype
1005 readable writable var _n_id
: TClassid
1006 readable writable var _n_type
: AType
1010 # A `writable` or `readable` modifier
1011 abstract class AAble
1013 readable writable var _n_visibility
: nullable AVisibility = null
1014 readable writable var _n_kwredef
: nullable TKwredef = null
1018 # A `readable` modifier
1021 readable writable var _n_kwreadable
: TKwreadable
1025 # A `writable` modifier
1028 readable writable var _n_kwwritable
: TKwwritable
1032 # The identifier of a method in a method declaration.
1033 # There is a specific class because of operator and setters.
1034 abstract class AMethid
1039 readable writable var _n_id
: TId
1044 readable writable var _n_plus
: TPlus
1049 readable writable var _n_minus
: TMinus
1054 readable writable var _n_star
: TStar
1059 readable writable var _n_slash
: TSlash
1062 class APercentMethid
1064 readable writable var _n_percent
: TPercent
1069 readable writable var _n_eq
: TEq
1074 readable writable var _n_ne
: TNe
1079 readable writable var _n_le
: TLe
1084 readable writable var _n_ge
: TGe
1089 readable writable var _n_lt
: TLt
1094 readable writable var _n_gt
: TGt
1099 readable writable var _n_ll
: TLl
1104 readable writable var _n_gg
: TGg
1109 readable writable var _n_obra
: TObra
1110 readable writable var _n_cbra
: TCbra
1113 class AStarshipMethid
1115 readable writable var _n_starship
: TStarship
1120 readable writable var _n_id
: TId
1121 readable writable var _n_assign
: TAssign
1124 class ABraassignMethid
1126 readable writable var _n_obra
: TObra
1127 readable writable var _n_cbra
: TCbra
1128 readable writable var _n_assign
: TAssign
1132 # A signature in a method definition. eg `(x,y:X,z:Z):T`
1135 readable writable var _n_opar
: nullable TOpar = null
1136 readable var _n_params
: ANodes[AParam] = new ANodes[AParam](self)
1137 readable writable var _n_cpar
: nullable TCpar = null
1138 readable writable var _n_type
: nullable AType = null
1142 # A parameter definition in a signature. eg `x:X`
1145 readable writable var _n_id
: TId
1146 readable writable var _n_type
: nullable AType = null
1147 readable writable var _n_dotdotdot
: nullable TDotdotdot = null
1151 # A static type. eg `nullable X[Y]`
1154 readable writable var _n_kwnullable
: nullable TKwnullable = null
1156 # The name of the class or of the formal type
1157 readable writable var _n_id
: TClassid
1159 # Type arguments for a generic type
1160 readable var _n_types
: ANodes[AType] = new ANodes[AType](self)
1164 # A label at the end of a block or in a break/continue statement. eg `label x`
1167 readable writable var _n_kwlabel
: TKwlabel
1168 readable writable var _n_id
: TId
1172 # Expression and statements
1173 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1174 abstract class AExpr
1178 # A sequence of AExpr (usually statements)
1179 # The last AExpr gives the value of the whole block
1182 readable var _n_expr
: ANodes[AExpr] = new ANodes[AExpr](self)
1183 readable writable var _n_kwend
: nullable TKwend = null
1187 # A declaration of a local variable. eg `var x: X = y`
1190 readable writable var _n_kwvar
: TKwvar
1191 readable writable var _n_id
: TId
1192 readable writable var _n_type
: nullable AType = null
1193 readable writable var _n_assign
: nullable TAssign = null
1195 # The initial value, if any
1196 readable writable var _n_expr
: nullable AExpr = null
1200 # A `return` statement. eg `return x`
1203 readable writable var _n_kwreturn
: nullable TKwreturn = null
1204 readable writable var _n_expr
: nullable AExpr = null
1208 # Something that has a label.
1209 abstract class ALabelable
1211 readable writable var _n_label
: nullable ALabel = null
1215 # A `break` statement.
1219 readable writable var _n_kwbreak
: TKwbreak
1220 readable writable var _n_expr
: nullable AExpr = null
1224 # An `abort` statement
1227 readable writable var _n_kwabort
: TKwabort
1231 # A `continue` statement
1235 readable writable var _n_kwcontinue
: nullable TKwcontinue = null
1236 readable writable var _n_expr
: nullable AExpr = null
1244 readable writable var _n_kwdo
: TKwdo
1245 readable writable var _n_block
: nullable AExpr = null
1252 readable writable var _n_kwif
: TKwif
1253 readable writable var _n_expr
: AExpr
1254 readable writable var _n_then
: nullable AExpr = null
1255 readable writable var _n_else
: nullable AExpr = null
1262 readable writable var _n_kwif
: TKwif
1263 readable writable var _n_expr
: AExpr
1264 readable writable var _n_kwthen
: TKwthen
1265 readable writable var _n_then
: AExpr
1266 readable writable var _n_kwelse
: TKwelse
1267 readable writable var _n_else
: AExpr
1271 # A `while` statement
1275 readable writable var _n_kwwhile
: TKwwhile
1276 readable writable var _n_expr
: AExpr
1277 readable writable var _n_kwdo
: TKwdo
1278 readable writable var _n_block
: nullable AExpr = null
1282 # A `loop` statement
1286 readable writable var _n_kwloop
: TKwloop
1287 readable writable var _n_block
: nullable AExpr = null
1295 readable writable var _n_kwfor
: TKwfor
1296 readable var _n_ids
: ANodes[TId] = new ANodes[TId](self)
1297 readable writable var _n_expr
: AExpr
1298 readable writable var _n_kwdo
: TKwdo
1299 readable writable var _n_block
: nullable AExpr = null
1303 # An `assert` statement
1306 readable writable var _n_kwassert
: TKwassert
1307 readable writable var _n_id
: nullable TId = null
1308 readable writable var _n_expr
: AExpr
1309 readable writable var _n_else
: nullable AExpr = null
1313 # Whatever is a simple assignment. eg `= something`
1314 abstract class AAssignFormExpr
1316 readable writable var _n_assign
: TAssign
1317 readable writable var _n_value
: AExpr
1321 # Whatever is a combined assignment. eg `+= something`
1322 abstract class AReassignFormExpr
1324 readable writable var _n_assign_op
: AAssignOp
1325 readable writable var _n_value
: AExpr
1329 # A `once` expression. eg `once x`
1332 readable writable var _n_kwonce
: TKwonce
1336 # A polymorphic invocation of a method
1337 # The form of the invocation (name, arguments, etc) are specific
1338 abstract class ASendExpr
1340 # The receiver of the method invocation
1341 readable writable var _n_expr
: AExpr
1345 # A binary operation on a method
1346 abstract class ABinopExpr
1348 # The second operand of the operation
1349 # Note: the receiver (`n_expr`) is the first operand
1350 readable writable var _n_expr2
: AExpr
1354 # Something that is boolean expression
1355 abstract class ABoolExpr
1362 readable writable var _n_expr
: AExpr
1363 readable writable var _n_expr2
: AExpr
1367 # A `and` expression
1370 readable writable var _n_expr
: AExpr
1371 readable writable var _n_expr2
: AExpr
1375 # A `or else` expression
1378 readable writable var _n_expr
: AExpr
1379 readable writable var _n_expr2
: AExpr
1383 # A `implies` expression
1386 readable writable var _n_expr
: AExpr
1387 readable writable var _n_expr2
: AExpr
1391 # A `not` expression
1394 readable writable var _n_kwnot
: TKwnot
1395 readable writable var _n_expr
: AExpr
1439 # A type-ckeck expression. eg `x isa T`
1442 readable writable var _n_expr
: AExpr
1443 readable writable var _n_type
: AType
1457 # A `<=>` expression
1477 # A unary minus expression. eg `-x`
1480 readable writable var _n_minus
: TMinus
1484 # An explicit instantiation. eg `new T`
1487 readable writable var _n_kwnew
: TKwnew
1488 readable writable var _n_type
: AType
1490 # The name of the named-constructor, if any
1491 readable writable var _n_id
: nullable TId = null
1492 readable writable var _n_args
: AExprs
1496 # Whatever is a old-style attribute access
1497 abstract class AAttrFormExpr
1500 # The receiver of the attribute
1501 readable writable var _n_expr
: AExpr
1503 # The name of the attribute
1504 readable writable var _n_id
: TAttrid
1509 # The read of an attribute. eg `x._a`
1514 # The assignment of an attribute. eg `x._a=y`
1515 class AAttrAssignExpr
1517 super AAssignFormExpr
1520 # Whatever looks-like a call with a standard method and any number of arguments.
1521 abstract class ACallFormExpr
1524 # The name of the method
1525 readable writable var _n_id
: TId
1527 # The arguments of the call
1528 readable writable var _n_args
: AExprs
1532 # A complex setter call (standard or brackets)
1533 abstract class ASendReassignFormExpr
1535 super AReassignFormExpr
1538 # A complex attribute assignment. eg `x._a+=y`
1539 class AAttrReassignExpr
1541 super AReassignFormExpr
1544 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
1545 # 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`.
1546 # Semantic analysis have to transform them to instance of `AVarExpr`.
1551 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
1552 # 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`.
1553 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
1554 class ACallAssignExpr
1556 super AAssignFormExpr
1559 # 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.
1560 # 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`.
1561 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
1562 class ACallReassignExpr
1564 super ASendReassignFormExpr
1567 # A call to `super`. OR a call of a super-constructor
1570 readable writable var _n_qualified
: nullable AQualified = null
1571 readable writable var _n_kwsuper
: TKwsuper
1572 readable writable var _n_args
: AExprs
1576 # A call to the `init` constructor.
1577 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a ACallFormExpr.
1580 readable writable var _n_kwinit
: TKwinit
1581 readable writable var _n_args
: AExprs
1585 # Whatever looks-like a call of the brackets `[]` operator.
1586 abstract class ABraFormExpr
1588 readable writable var _n_args
: AExprs
1592 # A call of the brackets operator. eg `x[y,z]`
1597 # A setter call of the bracket operator. eg `x[y,z]=t`
1598 class ABraAssignExpr
1600 super AAssignFormExpr
1603 # Whatever is an access to a local variable
1604 abstract class AVarFormExpr
1606 readable writable var _n_id
: TId
1610 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
1611 class ABraReassignExpr
1613 super ASendReassignFormExpr
1616 # A local variable read access.
1617 # The parser cannot instantiate them, see `ACallExpr`.
1622 # A local variable simple assigment access
1623 # The parser cannot instantiate them, see `ACallAssignExpr`.
1624 class AVarAssignExpr
1626 super AAssignFormExpr
1629 # A local variable complex assignment access
1630 # The parser cannot instantiate them, see `ACallReassignExpr`.
1631 class AVarReassignExpr
1633 super AReassignFormExpr
1636 # A literal range, open or closed
1637 abstract class ARangeExpr
1639 readable writable var _n_expr
: AExpr
1640 readable writable var _n_expr2
: AExpr
1644 # A closed literal range. eg `[x..y]`
1647 readable writable var _n_obra
: TObra
1648 readable writable var _n_cbra
: TCbra
1652 # An open literal range. eg `[x..y[`
1655 readable writable var _n_obra
: TObra
1656 readable writable var _n_cbra
: TObra
1660 # A literal array. eg. `[x,y,z]`
1663 readable writable var _n_exprs
: AExprs
1670 readable writable var _n_kwself
: nullable TKwself
1674 # When there is no explicit receiver, `self` is implicit
1675 class AImplicitSelfExpr
1679 # A `true` boolean literal constant
1682 readable writable var _n_kwtrue
: TKwtrue
1685 # A `false` boolean literal constant
1688 readable writable var _n_kwfalse
: TKwfalse
1691 # A `null` literal constant
1694 readable writable var _n_kwnull
: TKwnull
1697 # An integer literal
1701 # An integer literal in decimal format
1704 readable writable var _n_number
: TNumber
1707 # An integer literal in hexadecimal format
1710 readable writable var _n_hex_number
: THexNumber
1716 readable writable var _n_float
: TFloat
1719 # A character literal
1722 readable writable var _n_char
: TChar
1726 abstract class AStringFormExpr
1728 readable writable var _n_string
: Token
1732 # A simple string. eg. `"abc"`
1734 super AStringFormExpr
1737 # The start of a superstring. eg `"abc{`
1738 class AStartStringExpr
1739 super AStringFormExpr
1742 # The middle of a superstring. eg `}abc{`
1743 class AMidStringExpr
1744 super AStringFormExpr
1747 # The end of a superstrng. eg `}abc"`
1748 class AEndStringExpr
1749 super AStringFormExpr
1752 # A superstring literal. eg `"a{x}b{y}c"`
1753 # Each part is modelized a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
1754 class ASuperstringExpr
1756 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1760 # A simple parenthesis. eg `(x)`
1763 readable writable var _n_opar
: TOpar
1764 readable writable var _n_cpar
: TCpar
1768 # Whatevej just contains (and mimic) an other expression
1769 abstract class AProxyExpr
1771 readable writable var _n_expr
: AExpr
1775 # A type cast. eg `x.as(T)`
1778 readable writable var _n_expr
: AExpr
1779 readable writable var _n_kwas
: TKwas
1780 readable writable var _n_opar
: nullable TOpar = null
1781 readable writable var _n_type
: AType
1782 readable writable var _n_cpar
: nullable TCpar = null
1786 # A as-not-null cast. eg `x.as(not null)`
1787 class AAsNotnullExpr
1789 readable writable var _n_expr
: AExpr
1790 readable writable var _n_kwas
: TKwas
1791 readable writable var _n_opar
: nullable TOpar = null
1792 readable writable var _n_kwnot
: TKwnot
1793 readable writable var _n_kwnull
: TKwnull
1794 readable writable var _n_cpar
: nullable TCpar = null
1798 # A is-set check of old-style attributes. eg `isset x._a`
1799 class AIssetAttrExpr
1801 readable writable var _n_kwisset
: TKwisset
1805 # A list of expression separated with commas (arguments for instance)
1806 abstract class AExprs
1808 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1812 class ADebugTypeExpr
1814 readable writable var _n_kwdebug
: TKwdebug
1815 readable writable var _n_kwtype
: TKwtype
1816 readable writable var _n_expr
: AExpr
1817 readable writable var _n_type
: AType
1821 # A simple list of expressions
1826 # A list of expressions enclosed in parentheses
1829 readable writable var _n_opar
: TOpar
1830 readable writable var _n_cpar
: TCpar
1834 # A list of expressions enclosed in brackets
1837 readable writable var _n_obra
: TObra
1838 readable writable var _n_cbra
: TCbra
1842 # A complex assignment operator. eg `+=`
1843 abstract class AAssignOp
1848 readable writable var _n_pluseq
: TPluseq
1851 class AMinusAssignOp
1853 readable writable var _n_minuseq
: TMinuseq
1859 readable writable var _n_quad
: nullable TQuad = null
1860 readable var _n_path
: ANodes[TId] = new ANodes[TId](self)
1861 readable writable var _n_id
: TId
1866 readable writable var _n_kwin
: TKwin
1867 readable writable var _n_string
: TString
1870 class AExternCodeBlock
1872 readable writable var _n_in_language
: nullable AInLanguage = null
1873 readable writable var _n_extern_code_segment
: TExternCodeSegment
1878 readable writable var _n_quad
: nullable TQuad = null
1879 readable var _n_id
: ANodes[TId] = new ANodes[TId](self)
1880 readable writable var _n_classid
: nullable TClassid = null
1884 # A documentation of a definition
1885 # It contains the block of comments just above the declaration
1888 readable var _n_comment
: ANodes[TComment] = new ANodes[TComment](self)
1894 readable writable var _n_at
: nullable TAt = null
1895 readable writable var _n_opar
: nullable TOpar = null
1896 readable var _n_items
: ANodes[AAnnotation] = new ANodes[AAnnotation](self)
1897 readable writable var _n_cpar
: nullable TCpar = null
1902 readable writable var _n_atid
: AAtid
1903 readable writable var _n_opar
: nullable TOpar = null
1904 readable var _n_args
: ANodes[AAtArg] = new ANodes[AAtArg](self)
1905 readable writable var _n_cpar
: nullable TCpar = null
1908 abstract class AAtArg
1913 readable writable var _n_type
: AType
1918 readable writable var _n_expr
: AExpr
1924 abstract class AAtid
1926 readable writable var _n_id
: Token
1938 class AKwreadableAtid
1941 class AKwwritableAtid
1948 # The root of the AST
1951 readable writable var _n_base
: nullable AModule
1952 readable writable var _n_eof
: EOF
1953 init(n_base
: nullable AModule, n_eof
: EOF)
1955 self._n_base
= n_base