3cc52967e503c897640d0cf926bc7ada3034aeb8
1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # AST nodes of the Nit language
16 # Was previously based on parser_abs.nit.
21 # Root of the AST class-hierarchy
23 # Location is set during AST building. Once built, location cannon be null.
24 # However, manual instantiated nodes may need more care.
25 var location
: Location is writable, noinit
27 # The location of the important part of the node (identifier or whatever)
28 fun hot_location
: Location do return location
30 # Display a message for the colored location of the node
31 fun debug
(message
: String)
33 sys
.stderr
.write
"{hot_location} {self.class_name}: {message}\n{hot_location.colored_line("0;32")}\n"
36 # Parent of the node in the AST
37 var parent
: nullable ANode = null
39 # The topmost ancestor of the element
40 # This just apply `parent` until the first one
46 if p
== null then return res
51 # The most specific common parent between `self` and `other`
52 # Return null if the two node are unrelated (distinct root)
53 fun common_parent
(other
: ANode): nullable ANode
55 # First, get the same depth
56 var s
: nullable ANode = self
57 var o
: nullable ANode = other
58 var d
= s
.depth
- o
.depth
67 assert o
.depth
== s
.depth
68 # Second, go up until same in found
76 # Number of nodes between `self` and the `root` of the AST
77 # ENSURE `self == self.root implies result == 0 `
78 # ENSURE `self != self.root implies result == self.parent.depth + 1`
85 if p
== null then return res
91 # Replace a child with an other node in the AST
92 private fun replace_child
(old_child
: ANode, new_child
: nullable ANode) is abstract
94 # Detach a node from its parent
95 # Aborts if the node is not detashable. use `replace_with` instead
96 # REQUIRE: parent != null
97 # REQUIRE: is_detachable
98 # ENDURE: parent == null
101 assert parent
!= null
102 parent
.replace_child
(self, null)
106 # Replace itself with an other node in the AST
107 # REQUIRE: parent != null
108 # ENSURE: node.parent == old(parent)
109 # ENSURE: parent == null
110 fun replace_with
(node
: ANode)
112 assert parent
!= null
113 parent
.replace_child
(self, node
)
117 # Visit all nodes in order.
118 # Thus, call `v.enter_visit(e)` for each child `e`
119 fun visit_all
(v
: Visitor) is abstract
122 # A sequence of nodes
123 # There is a specifc class (instead of a using Array) to track the parent/child relation when nodes are added or removed
124 class ANodes[E
: ANode]
126 private var parent
: ANode
127 private var items
= new Array[E
]
128 redef fun iterator
do return items
.iterator
129 redef fun length
do return items
.length
130 redef fun is_empty
do return items
.is_empty
149 var res
= items
.shift
161 redef fun []=(index
, e
)
163 hook_remove
(self[index
])
167 redef fun remove_at
(index
)
169 hook_remove
(items
[index
])
170 items
.remove_at
(index
)
172 private fun hook_add
(e
: E
)
174 #assert e.parent == null
177 private fun hook_remove
(e
: E
)
179 assert e
.parent
== parent
183 # Used in parent contructor to fill elements
184 private fun unsafe_add_all
(nodes
: Collection[Object])
186 var parent
= self.parent
194 private fun replace_child
(old_child
: ANode, new_child
: nullable ANode): Bool
196 var parent
= self.parent
197 for i
in [0..length
[ do
198 if self[i
] == old_child
then
199 if new_child
!= null then
200 assert new_child
isa E
202 new_child
.parent
= parent
212 private fun visit_all
(v
: Visitor)
214 for n
in self do v
.enter_visit
(n
)
218 # Ancestor of all tokens
219 # A token is a node that has a `text` but no children.
223 # The raw content on the token
224 fun text
: String is abstract
225 fun text
=(text
: String) is abstract
227 # The previous token in the Lexer.
228 # May have disapeared in the AST
229 var prev_token
: nullable Token = null
231 # The next token in the Lexer.
232 # May have disapeared in the AST
233 var next_token
: nullable Token = null
235 # The verbatim blank text between `prev_token` and `self`
236 fun blank_before
: String
238 if prev_token
== null then return ""
239 var from
= prev_token
.location
.pend
+1
240 var to
= location
.pstart
241 return location
.file
.string
.substring
(from
,to-from
)
244 redef fun to_s
: String do
248 redef fun visit_all
(v
: Visitor) do end
249 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode) do end
252 redef class SourceFile
253 # The first token parser by the lexer
254 # May have disapeared in the final AST
255 var first_token
: nullable Token = null
257 # The first token parser by the lexer
258 # May have disapeared in the final AST
259 var last_token
: nullable Token = null
262 # Ancestor of all productions
263 # A production is a node without text but that usually has children.
267 # All the annotations attached directly to the node
268 var n_annotations
: nullable AAnnotations = null is writable
270 redef fun replace_with
(n
: ANode)
274 if not isset n
._location
and isset _location
then n
._location
= _location
278 # Abstract standard visitor on the AST
279 abstract class Visitor
280 # What the visitor do when a node is visited
281 # Concrete visitors should implement this method.
283 protected fun visit
(e
: ANode) is abstract
285 # Ask the visitor to visit a given node.
286 # Usually automatically called by visit_all* methods.
287 # This method should not be redefined
288 fun enter_visit
(e
: nullable ANode)
290 if e
== null then return
291 var old
= _current_node
297 # The current visited node
298 var current_node
: nullable ANode = null is writable
301 # Token of end of line (basically `\n`)
310 # Token of a line of comments
311 # Starts with the `#` and contains the final end-of-line (if any)
316 # A token associated with a keyword
317 abstract class TokenKeyword
321 return "keyword '{text}'"
505 # A token associated with an operator (and other lookalike symbols)
506 abstract class TokenOperator
510 return "operator '{text}'"
577 # A class (or formal type) identifier. They start with an uppercase.
582 do return "type identifier '{text}'"
586 # A standard identifier (variable, method...). They start with a lowercase.
591 do return "identifier '{text}'"
595 # An attribute identifier. They start with an underscore.
600 do return "attribute '{text}'"
604 # A token of a literal value (string, integer, etc).
605 abstract class TokenLiteral
609 do return "literal value '{text}'"
642 do return "malformed string {text}"
651 do return "malformed character {text}"
655 class TExternCodeSegment
679 # The main node of a Nit source-file
683 var n_moduledecl
: nullable AModuledecl = null is writable
684 var n_imports
: ANodes[AImport] = new ANodes[AImport](self)
685 var n_extern_code_blocks
: ANodes[AExternCodeBlock] = new ANodes[AExternCodeBlock](self)
686 var n_classdefs
: ANodes[AClassdef] = new ANodes[AClassdef](self)
689 # The declaration of the module with the documentation, name, and annotations
692 var n_doc
: nullable ADoc = null is writable
693 var n_kwredef
: nullable TKwredef = null is writable
694 var n_visibility
: AVisibility is writable, noinit
695 var n_kwmodule
: TKwmodule is writable, noinit
696 var n_name
: AModuleName is writable, noinit
699 # A import clause of a module
700 abstract class AImport
704 # A standard import clause. eg `import x`
707 var n_visibility
: AVisibility is writable, noinit
708 var n_kwimport
: TKwimport is writable, noinit
709 var n_name
: AModuleName is writable, noinit
712 # The special import clause of the kernel module. eg `import end`
715 var n_visibility
: AVisibility is writable, noinit
716 var n_kwimport
: TKwimport is writable, noinit
717 var n_kwend
: TKwend is writable, noinit
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
731 var n_kwpublic
: nullable TKwpublic is writable
733 class APrivateVisibility
735 var n_kwprivate
: TKwprivate is writable, noinit
737 class AProtectedVisibility
739 var n_kwprotected
: TKwprotected is writable, noinit
741 class AIntrudeVisibility
743 var n_kwintrude
: TKwintrude is writable, noinit
747 # While most definition are `AStdClassdef`
748 # There is tow special case of class definition
749 abstract class AClassdef
751 var n_propdefs
: ANodes[APropdef] = new ANodes[APropdef](self)
754 # A standard class definition with a name, superclasses and properties
757 var n_doc
: nullable ADoc = null is writable
758 var n_kwredef
: nullable TKwredef = null is writable
759 var n_visibility
: AVisibility is writable, noinit
760 var n_classkind
: AClasskind is writable, noinit
761 var n_id
: nullable TClassid = null is writable
762 var n_formaldefs
: ANodes[AFormaldef] = new ANodes[AFormaldef](self)
763 var n_extern_code_block
: nullable AExternCodeBlock = null is writable
764 var n_superclasses
: ANodes[ASuperclass] = new ANodes[ASuperclass](self)
765 var n_kwend
: TKwend is writable, noinit
766 redef fun hot_location
do return n_id
.location
769 # The implicit class definition of the implicit main method
774 # The implicit class definition of the top-level methods
779 # The modifier for the kind of class (abstract, interface, etc.)
780 abstract class AClasskind
783 class AConcreteClasskind
785 var n_kwclass
: TKwclass is writable, noinit
787 class AAbstractClasskind
789 var n_kwabstract
: TKwabstract is writable, noinit
790 var n_kwclass
: TKwclass is writable, noinit
792 class AInterfaceClasskind
794 var n_kwinterface
: TKwinterface is writable, noinit
798 var n_kwenum
: TKwenum is writable, noinit
800 class AExternClasskind
802 var n_kwextern
: TKwextern is writable, noinit
803 var n_kwclass
: nullable TKwclass = null is writable
806 # The definition of a formal generic parameter type. eg `X: Y`
809 var n_id
: TClassid is writable, noinit
810 # The bound of the parameter type
811 var n_type
: nullable AType = null is writable
814 # A super-class. eg `super X`
817 var n_kwsuper
: TKwsuper is writable, noinit
818 var n_type
: AType is writable, noinit
821 # The definition of a property
822 abstract class APropdef
824 var n_doc
: nullable ADoc = null is writable
825 var n_kwredef
: nullable TKwredef = null is writable
826 var n_visibility
: nullable AVisibility = null is writable
829 # A definition of an attribute
830 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
833 var n_kwvar
: TKwvar is writable, noinit
835 # The identifier for an old-style attribute (null if new-style)
836 var n_id
: nullable TAttrid is writable
838 # The identifier for a new-style attribute (null if old-style)
839 var n_id2
: nullable TId is writable
841 var n_type
: nullable AType = null is writable
842 var n_readable
: nullable AAble = null is writable
843 var n_writable
: nullable AAble = null is writable
845 # The initial value, if any
846 var n_expr
: nullable AExpr = null is writable
847 redef fun hot_location
849 if n_id
!= null then return n_id
.location
else return n_id2
.location
853 # A definition of all kind of method (including constructors)
854 abstract class AMethPropdef
856 var n_kwmeth
: nullable TKwmeth = null is writable
857 var n_kwinit
: nullable TKwinit = null is writable
858 var n_kwnew
: nullable TKwnew = null is writable
859 var n_methid
: nullable AMethid = null is writable
860 var n_signature
: nullable ASignature = null is writable
861 var n_block
: nullable AExpr = null is writable
862 var n_extern
: nullable TString = null is writable
863 var n_extern_calls
: nullable AExternCalls = null is writable
864 var n_extern_code_block
: nullable AExternCodeBlock = null is writable
865 redef fun hot_location
867 if n_methid
!= null then
868 return n_methid
.location
869 else if n_kwinit
!= null then
870 return n_kwinit
.location
871 else if n_kwnew
!= null then
872 return n_kwnew
.location
879 # A method marked abstract
880 # *deferred* is a old synonynmous of *abstract* that comes from PRM, that comes from Eiffel.
881 class ADeferredMethPropdef
885 # A method marked intern
886 class AInternMethPropdef
890 # A method of a constructor marked extern
891 abstract class AExternPropdef
895 # A method marked extern
896 class AExternMethPropdef
900 # A method with a body
901 class AConcreteMethPropdef
906 abstract class AInitPropdef
910 # A constructor with a body
911 class AConcreteInitPropdef
912 super AConcreteMethPropdef
916 class AInternNewPropdef
917 super AInternMethPropdef
921 # A constructor marked extern (defined with the `new` keyword)
922 class AExternInitPropdef
927 # The implicit main method
928 class AMainMethPropdef
929 super AConcreteMethPropdef
932 # Declaration of callbacks for extern methods
935 var n_kwimport
: TKwimport is writable, noinit
936 var n_extern_calls
: ANodes[AExternCall] = new ANodes[AExternCall](self)
938 abstract class AExternCall
941 abstract class APropExternCall
944 class ALocalPropExternCall
945 super APropExternCall
946 var n_methid
: AMethid is writable, noinit
948 class AFullPropExternCall
949 super APropExternCall
950 var n_type
: AType is writable, noinit
951 var n_dot
: nullable TDot = null is writable
952 var n_methid
: AMethid is writable, noinit
954 class AInitPropExternCall
955 super APropExternCall
956 var n_type
: AType is writable, noinit
958 class ASuperExternCall
960 var n_kwsuper
: TKwsuper is writable, noinit
962 abstract class ACastExternCall
965 class ACastAsExternCall
966 super ACastExternCall
967 var n_from_type
: AType is writable, noinit
968 var n_dot
: nullable TDot = null is writable
969 var n_kwas
: TKwas is writable, noinit
970 var n_to_type
: AType is writable, noinit
972 class AAsNullableExternCall
973 super ACastExternCall
974 var n_type
: AType is writable, noinit
975 var n_kwas
: TKwas is writable, noinit
976 var n_kwnullable
: TKwnullable is writable, noinit
978 class AAsNotNullableExternCall
979 super ACastExternCall
980 var n_type
: AType is writable, noinit
981 var n_kwas
: TKwas is writable, noinit
982 var n_kwnot
: TKwnot is writable, noinit
983 var n_kwnullable
: TKwnullable is writable, noinit
986 # A definition of a virtual type
989 var n_kwtype
: TKwtype is writable, noinit
990 var n_id
: TClassid is writable, noinit
991 var n_type
: AType is writable, noinit
994 # A `writable` or `readable` modifier
997 var n_visibility
: nullable AVisibility = null is writable
998 var n_kwredef
: nullable TKwredef = null is writable
1001 # A `readable` modifier
1004 var n_kwreadable
: TKwreadable is writable, noinit
1007 # A `writable` modifier
1010 var n_kwwritable
: TKwwritable is writable, noinit
1013 # The identifier of a method in a method declaration.
1014 # There is a specific class because of operator and setters.
1015 abstract class AMethid
1020 var n_id
: TId is writable, noinit
1024 var n_plus
: TPlus is writable, noinit
1028 var n_minus
: TMinus is writable, noinit
1032 var n_star
: TStar is writable, noinit
1036 var n_slash
: TSlash is writable, noinit
1038 class APercentMethid
1040 var n_percent
: TPercent is writable, noinit
1044 var n_eq
: TEq is writable, noinit
1048 var n_ne
: TNe is writable, noinit
1052 var n_le
: TLe is writable, noinit
1056 var n_ge
: TGe is writable, noinit
1060 var n_lt
: TLt is writable, noinit
1064 var n_gt
: TGt is writable, noinit
1068 var n_ll
: TLl is writable, noinit
1072 var n_gg
: TGg is writable, noinit
1076 var n_obra
: TObra is writable, noinit
1077 var n_cbra
: TCbra is writable, noinit
1079 class AStarshipMethid
1081 var n_starship
: TStarship is writable, noinit
1085 var n_id
: TId is writable, noinit
1086 var n_assign
: TAssign is writable, noinit
1088 class ABraassignMethid
1090 var n_obra
: TObra is writable, noinit
1091 var n_cbra
: TCbra is writable, noinit
1092 var n_assign
: TAssign is writable, noinit
1095 # A signature in a method definition. eg `(x,y:X,z:Z):T`
1098 var n_opar
: nullable TOpar = null is writable
1099 var n_params
: ANodes[AParam] = new ANodes[AParam](self)
1100 var n_cpar
: nullable TCpar = null is writable
1101 var n_type
: nullable AType = null is writable
1104 # A parameter definition in a signature. eg `x:X`
1107 var n_id
: TId is writable, noinit
1108 var n_type
: nullable AType = null is writable
1109 var n_dotdotdot
: nullable TDotdotdot = null is writable
1112 # A static type. eg `nullable X[Y]`
1115 var n_kwnullable
: nullable TKwnullable = null is writable
1117 # The name of the class or of the formal type
1118 var n_id
: TClassid is writable, noinit
1120 # Type arguments for a generic type
1121 var n_types
: ANodes[AType] = new ANodes[AType](self)
1124 # A label at the end of a block or in a break/continue statement. eg `label x`
1127 var n_kwlabel
: TKwlabel is writable, noinit
1128 var n_id
: nullable TId is writable
1131 # Expression and statements
1132 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1133 abstract class AExpr
1137 # A sequence of AExpr (usually statements)
1138 # The last AExpr gives the value of the whole block
1141 var n_expr
: ANodes[AExpr] = new ANodes[AExpr](self)
1142 var n_kwend
: nullable TKwend = null is writable
1145 # A declaration of a local variable. eg `var x: X = y`
1148 var n_kwvar
: TKwvar is writable, noinit
1149 var n_id
: TId is writable, noinit
1150 var n_type
: nullable AType = null is writable
1151 var n_assign
: nullable TAssign = null is writable
1153 # The initial value, if any
1154 var n_expr
: nullable AExpr = null is writable
1157 # A `return` statement. eg `return x`
1160 var n_kwreturn
: nullable TKwreturn = null is writable
1161 var n_expr
: nullable AExpr = null is writable
1164 # Something that has a label.
1165 abstract class ALabelable
1167 var n_label
: nullable ALabel = null is writable
1170 # A `break` statement.
1174 var n_kwbreak
: TKwbreak is writable, noinit
1175 var n_expr
: nullable AExpr = null is writable
1178 # An `abort` statement
1181 var n_kwabort
: TKwabort is writable, noinit
1184 # A `continue` statement
1188 var n_kwcontinue
: nullable TKwcontinue = null is writable
1189 var n_expr
: nullable AExpr = null is writable
1196 var n_kwdo
: TKwdo is writable, noinit
1197 var n_block
: nullable AExpr = null is writable
1203 var n_kwif
: TKwif is writable, noinit
1204 var n_expr
: AExpr is writable, noinit
1205 var n_then
: nullable AExpr = null is writable
1206 var n_else
: nullable AExpr = null is writable
1212 var n_kwif
: TKwif is writable, noinit
1213 var n_expr
: AExpr is writable, noinit
1214 var n_kwthen
: TKwthen is writable, noinit
1215 var n_then
: AExpr is writable, noinit
1216 var n_kwelse
: TKwelse is writable, noinit
1217 var n_else
: AExpr is writable, noinit
1220 # A `while` statement
1224 var n_kwwhile
: TKwwhile is writable, noinit
1225 var n_expr
: AExpr is writable, noinit
1226 var n_kwdo
: TKwdo is writable, noinit
1227 var n_block
: nullable AExpr = null is writable
1230 # A `loop` statement
1234 var n_kwloop
: TKwloop is writable, noinit
1235 var n_block
: nullable AExpr = null is writable
1242 var n_kwfor
: TKwfor is writable, noinit
1243 var n_ids
: ANodes[TId] = new ANodes[TId](self)
1244 var n_expr
: AExpr is writable, noinit
1245 var n_kwdo
: TKwdo is writable, noinit
1246 var n_block
: nullable AExpr = null is writable
1249 # An `assert` statement
1252 var n_kwassert
: TKwassert is writable, noinit
1253 var n_id
: nullable TId = null is writable
1254 var n_expr
: AExpr is writable, noinit
1255 var n_else
: nullable AExpr = null is writable
1258 # Whatever is a simple assignment. eg `= something`
1259 abstract class AAssignFormExpr
1261 var n_assign
: TAssign is writable, noinit
1262 var n_value
: AExpr is writable, noinit
1265 # Whatever is a combined assignment. eg `+= something`
1266 abstract class AReassignFormExpr
1268 var n_assign_op
: AAssignOp is writable, noinit
1269 var n_value
: AExpr is writable, noinit
1272 # A `once` expression. eg `once x`
1275 var n_kwonce
: TKwonce is writable, noinit
1278 # A polymorphic invocation of a method
1279 # The form of the invocation (name, arguments, etc) are specific
1280 abstract class ASendExpr
1282 # The receiver of the method invocation
1283 var n_expr
: AExpr is writable, noinit
1286 # A binary operation on a method
1287 abstract class ABinopExpr
1289 # The second operand of the operation
1290 # Note: the receiver (`n_expr`) is the first operand
1291 var n_expr2
: AExpr is writable, noinit
1294 # Something that is boolean expression
1295 abstract class ABoolExpr
1302 var n_expr
: AExpr is writable, noinit
1303 var n_expr2
: AExpr is writable, noinit
1306 # A `and` expression
1309 var n_expr
: AExpr is writable, noinit
1310 var n_expr2
: AExpr is writable, noinit
1313 # A `or else` expression
1316 var n_expr
: AExpr is writable, noinit
1317 var n_expr2
: AExpr is writable, noinit
1320 # A `implies` expression
1323 var n_expr
: AExpr is writable, noinit
1324 var n_expr2
: AExpr is writable, noinit
1327 # A `not` expression
1330 var n_kwnot
: TKwnot is writable, noinit
1331 var n_expr
: AExpr is writable, noinit
1374 # A type-ckeck expression. eg `x isa T`
1377 var n_expr
: AExpr is writable, noinit
1378 var n_type
: AType is writable, noinit
1391 # A `<=>` expression
1411 # A unary minus expression. eg `-x`
1414 var n_minus
: TMinus is writable, noinit
1417 # An explicit instantiation. eg `new T`
1420 var n_kwnew
: TKwnew is writable, noinit
1421 var n_type
: AType is writable, noinit
1423 # The name of the named-constructor, if any
1424 var n_id
: nullable TId = null is writable
1425 var n_args
: AExprs is writable, noinit
1428 # Whatever is a old-style attribute access
1429 abstract class AAttrFormExpr
1432 # The receiver of the attribute
1433 var n_expr
: AExpr is writable, noinit
1435 # The name of the attribute
1436 var n_id
: TAttrid is writable, noinit
1440 # The read of an attribute. eg `x._a`
1445 # The assignment of an attribute. eg `x._a=y`
1446 class AAttrAssignExpr
1448 super AAssignFormExpr
1451 # Whatever looks-like a call with a standard method and any number of arguments.
1452 abstract class ACallFormExpr
1455 # The name of the method
1456 var n_id
: TId is writable, noinit
1458 # The arguments of the call
1459 var n_args
: AExprs is writable, noinit
1462 # A complex setter call (standard or brackets)
1463 abstract class ASendReassignFormExpr
1465 super AReassignFormExpr
1468 # A complex attribute assignment. eg `x._a+=y`
1469 class AAttrReassignExpr
1471 super AReassignFormExpr
1474 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
1475 # 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`.
1476 # Semantic analysis have to transform them to instance of `AVarExpr`.
1481 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
1482 # 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`.
1483 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
1484 class ACallAssignExpr
1486 super AAssignFormExpr
1489 # 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.
1490 # 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`.
1491 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
1492 class ACallReassignExpr
1494 super ASendReassignFormExpr
1497 # A call to `super`. OR a call of a super-constructor
1500 var n_qualified
: nullable AQualified = null is writable
1501 var n_kwsuper
: TKwsuper is writable, noinit
1502 var n_args
: AExprs is writable, noinit
1505 # A call to the `init` constructor.
1506 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a ACallFormExpr.
1509 var n_kwinit
: TKwinit is writable, noinit
1510 var n_args
: AExprs is writable, noinit
1513 # Whatever looks-like a call of the brackets `[]` operator.
1514 abstract class ABraFormExpr
1516 var n_args
: AExprs is writable, noinit
1519 # A call of the brackets operator. eg `x[y,z]`
1524 # A setter call of the bracket operator. eg `x[y,z]=t`
1525 class ABraAssignExpr
1527 super AAssignFormExpr
1530 # Whatever is an access to a local variable
1531 abstract class AVarFormExpr
1533 var n_id
: TId is writable, noinit
1536 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
1537 class ABraReassignExpr
1539 super ASendReassignFormExpr
1542 # A local variable read access.
1543 # The parser cannot instantiate them, see `ACallExpr`.
1548 # A local variable simple assigment access
1549 # The parser cannot instantiate them, see `ACallAssignExpr`.
1550 class AVarAssignExpr
1552 super AAssignFormExpr
1555 # A local variable complex assignment access
1556 # The parser cannot instantiate them, see `ACallReassignExpr`.
1557 class AVarReassignExpr
1559 super AReassignFormExpr
1562 # A literal range, open or closed
1563 abstract class ARangeExpr
1565 var n_expr
: AExpr is writable, noinit
1566 var n_expr2
: AExpr is writable, noinit
1569 # A closed literal range. eg `[x..y]`
1572 var n_obra
: TObra is writable, noinit
1573 var n_cbra
: TCbra is writable, noinit
1576 # An open literal range. eg `[x..y[`
1579 var n_obra
: TObra is writable, noinit
1580 var n_cbra
: TObra is writable, noinit
1583 # A literal array. eg. `[x,y,z]`
1586 var n_exprs
: AExprs is writable, noinit
1592 var n_kwself
: nullable TKwself is writable
1595 # When there is no explicit receiver, `self` is implicit
1596 class AImplicitSelfExpr
1600 # A `true` boolean literal constant
1603 var n_kwtrue
: TKwtrue is writable, noinit
1605 # A `false` boolean literal constant
1608 var n_kwfalse
: TKwfalse is writable, noinit
1610 # A `null` literal constant
1613 var n_kwnull
: TKwnull is writable, noinit
1615 # An integer literal
1619 # An integer literal in decimal format
1622 var n_number
: TNumber is writable, noinit
1624 # An integer literal in hexadecimal format
1627 var n_hex_number
: THexNumber is writable, noinit
1632 var n_float
: TFloat is writable, noinit
1634 # A character literal
1637 var n_char
: TChar is writable, noinit
1640 abstract class AStringFormExpr
1642 var n_string
: Token is writable, noinit
1645 # A simple string. eg. `"abc"`
1647 super AStringFormExpr
1650 # The start of a superstring. eg `"abc{`
1651 class AStartStringExpr
1652 super AStringFormExpr
1655 # The middle of a superstring. eg `}abc{`
1656 class AMidStringExpr
1657 super AStringFormExpr
1660 # The end of a superstrng. eg `}abc"`
1661 class AEndStringExpr
1662 super AStringFormExpr
1665 # A superstring literal. eg `"a{x}b{y}c"`
1666 # Each part is modelized a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
1667 class ASuperstringExpr
1669 var n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1672 # A simple parenthesis. eg `(x)`
1675 var n_opar
: TOpar is writable, noinit
1676 var n_cpar
: TCpar is writable, noinit
1679 # Whatevej just contains (and mimic) an other expression
1680 abstract class AProxyExpr
1682 var n_expr
: AExpr is writable, noinit
1685 # A type cast. eg `x.as(T)`
1688 var n_expr
: AExpr is writable, noinit
1689 var n_kwas
: TKwas is writable, noinit
1690 var n_opar
: nullable TOpar = null is writable
1691 var n_type
: AType is writable, noinit
1692 var n_cpar
: nullable TCpar = null is writable
1695 # A as-not-null cast. eg `x.as(not null)`
1696 class AAsNotnullExpr
1698 var n_expr
: AExpr is writable, noinit
1699 var n_kwas
: TKwas is writable, noinit
1700 var n_opar
: nullable TOpar = null is writable
1701 var n_kwnot
: TKwnot is writable, noinit
1702 var n_kwnull
: TKwnull is writable, noinit
1703 var n_cpar
: nullable TCpar = null is writable
1706 # A is-set check of old-style attributes. eg `isset x._a`
1707 class AIssetAttrExpr
1709 var n_kwisset
: TKwisset is writable, noinit
1712 # A elyspis notation used to pass an expression as it in a vararg parameter
1715 var n_expr
: AExpr is writable, noinit
1716 var n_dotdotdot
: TDotdotdot is writable, noinit
1719 # A list of expression separated with commas (arguments for instance)
1720 abstract class AExprs
1722 var n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1726 class ADebugTypeExpr
1728 var n_kwdebug
: TKwdebug is writable, noinit
1729 var n_kwtype
: TKwtype is writable, noinit
1730 var n_expr
: AExpr is writable, noinit
1731 var n_type
: AType is writable, noinit
1734 # A simple list of expressions
1739 # A list of expressions enclosed in parentheses
1742 var n_opar
: TOpar is writable, noinit
1743 var n_cpar
: TCpar is writable, noinit
1746 # A list of expressions enclosed in brackets
1749 var n_obra
: TObra is writable, noinit
1750 var n_cbra
: TCbra is writable, noinit
1753 # A complex assignment operator. eg `+=`
1754 abstract class AAssignOp
1759 var n_pluseq
: TPluseq is writable, noinit
1761 class AMinusAssignOp
1763 var n_minuseq
: TMinuseq is writable, noinit
1768 var n_quad
: nullable TQuad = null is writable
1769 var n_path
: ANodes[TId] = new ANodes[TId](self)
1770 var n_id
: TId is writable, noinit
1774 var n_kwin
: TKwin is writable, noinit
1775 var n_string
: TString is writable, noinit
1777 class AExternCodeBlock
1779 var n_in_language
: nullable AInLanguage = null is writable
1780 var n_extern_code_segment
: TExternCodeSegment is writable, noinit
1784 var n_quad
: nullable TQuad = null is writable
1785 var n_id
: ANodes[TId] = new ANodes[TId](self)
1786 var n_classid
: nullable TClassid = null is writable
1789 # A documentation of a definition
1790 # It contains the block of comments just above the declaration
1793 var n_comment
: ANodes[TComment] = new ANodes[TComment](self)
1798 var n_at
: nullable TAt = null is writable
1799 var n_opar
: nullable TOpar = null is writable
1800 var n_items
: ANodes[AAnnotation] = new ANodes[AAnnotation](self)
1801 var n_cpar
: nullable TCpar = null is writable
1805 var n_doc
: nullable ADoc = null is writable
1806 var n_kwredef
: nullable TKwredef = null is writable
1807 var n_visibility
: nullable AVisibility is writable
1808 var n_atid
: AAtid is writable, noinit
1809 var n_opar
: nullable TOpar = null is writable
1810 var n_args
: ANodes[AAtArg] = new ANodes[AAtArg](self)
1811 var n_cpar
: nullable TCpar = null is writable
1813 abstract class AAtArg
1818 var n_type
: AType is writable, noinit
1822 var n_expr
: AExpr is writable, noinit
1827 abstract class AAtid
1829 var n_id
: Token is writable, noinit
1840 class AKwreadableAtid
1843 class AKwwritableAtid
1850 # The root of the AST
1853 var n_base
: nullable AModule is writable
1854 var n_eof
: EOF is writable, noinit
1855 init(n_base
: nullable AModule, n_eof
: EOF)
1857 self._n_base
= n_base