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 # Protect form invalid instantiation of nodes
44 # Replace a child with an other node in the AST
45 private fun replace_child
(old_child
: ANode, new_child
: nullable ANode) is abstract
47 # Detach a node from its parent
48 # Aborts if the node is not detashable. use `replace_with` instead
49 # REQUIRE: parent != null
50 # REQUIRE: is_detachable
51 # ENDURE: parent == null
55 parent
.replace_child
(self, null)
59 # Replace itself with an other node in the AST
60 # REQUIRE: parent != null
61 # ENSURE: node.parent == old(parent)
62 # ENSURE: parent == null
63 fun replace_with
(node
: ANode)
66 parent
.replace_child
(self, node
)
70 # Visit all nodes in order.
71 # Thus, call `v.enter_visit(e)` for each child `e`
72 fun visit_all
(v
: Visitor) is abstract
76 # There is a specifc class (instead of a using Array) to track the parent/child relation when nodes are added or removed
77 class ANodes[E
: ANode]
79 private var parent
: ANode
80 private var items
= new Array[E
]
81 redef fun iterator
do return items
.iterator
82 redef fun length
do return items
.length
83 redef fun is_empty
do return items
.is_empty
102 var res
= items
.shift
114 redef fun []=(index
, e
)
116 hook_remove
(self[index
])
120 redef fun remove_at
(index
)
122 hook_remove
(items
[index
])
123 items
.remove_at
(index
)
125 private fun hook_add
(e
: E
)
127 #assert e.parent == null
130 private fun hook_remove
(e
: E
)
132 assert e
.parent
== parent
136 # Used in parent contructor to fill elements
137 private fun unsafe_add_all
(nodes
: Collection[Object])
139 var parent
= self.parent
147 private fun replace_child
(old_child
: ANode, new_child
: nullable ANode): Bool
149 var parent
= self.parent
150 for i
in [0..length
[ do
151 if self[i
] == old_child
then
152 if new_child
!= null then
153 assert new_child
isa E
155 new_child
.parent
= parent
165 private fun visit_all
(v
: Visitor)
167 for n
in self do v
.enter_visit
(n
)
171 # Ancestor of all tokens
172 # A token is a node that has a `text` but no children.
176 # The raw content on the token
177 fun text
: String is abstract
178 fun text
=(text
: String) is abstract
180 # The previous token in the Lexer.
181 # May have disapeared in the AST
182 var prev_token
: nullable Token
184 # The next token in the Lexer.
185 # May have disapeared in the AST
186 var next_token
: nullable Token
188 redef fun to_s
: String do
192 redef fun visit_all
(v
: Visitor) do end
193 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode) do end
196 # Ancestor of all productions
197 # A production is a node without text but that usually has children.
201 fun location
=(l
: Location) do _location
= l
203 # All the annotations attached directly to the node
204 readable writable var _n_annotations
: nullable AAnnotations = null
206 redef fun replace_with
(n
: ANode)
210 if n
._location
== null then n
._location
= _location
214 # Abstract standard visitor on the AST
215 abstract class Visitor
216 # What the visitor do when a node is visited
217 # Concrete visitors should implement this method.
219 protected fun visit
(e
: ANode) is abstract
221 # Ask the visitor to visit a given node.
222 # Usually automatically called by visit_all* methods.
223 # This method should not be redefined
224 fun enter_visit
(e
: nullable ANode)
226 if e
== null then return
227 var old
= _current_node
233 # The current visited node
234 readable writable var _current_node
: nullable ANode = null
237 # Token of end of line (basically `\n`)
246 # Token of a line of comments
247 # Starts with the `#` and contains the final end-of-line (if any)
252 # A token associated with a keyword
253 abstract class TokenKeyword
257 return "keyword '{text}'"
441 # A token associated with an operator (and other lookalike symbols)
442 abstract class TokenOperator
446 return "operator '{text}'"
513 # A class (or formal type) identifier. They start with an uppercase.
518 do return "type identifier '{text}'"
522 # A standard identifier (variable, method...). They start with a lowercase.
527 do return "identifier '{text}'"
531 # An attribute identifier. They start with an underscore.
536 do return "attribute '{text}'"
540 # A token of a literal value (string, integer, etc).
541 abstract class TokenLiteral
545 do return "literal value '{text}'"
575 do return "malformed string {text}"
584 do return "malformed character {text}"
588 class TExternCodeSegment
612 # The main node of a Nit source-file
616 readable writable var _n_moduledecl
: nullable AModuledecl = null
617 readable var _n_imports
: ANodes[AImport] = new ANodes[AImport](self)
618 readable var _n_extern_code_blocks
: ANodes[AExternCodeBlock] = new ANodes[AExternCodeBlock](self)
619 readable var _n_classdefs
: ANodes[AClassdef] = new ANodes[AClassdef](self)
622 # The declaration of the module with the documentation, name, and annotations
625 readable writable var _n_doc
: nullable ADoc = null
626 readable writable var _n_kwmodule
: TKwmodule
627 readable writable var _n_name
: AModuleName
630 # A import clause of a module
631 abstract class AImport
635 # A standard import clause. eg `import x`
638 readable writable var _n_visibility
: AVisibility
639 readable writable var _n_kwimport
: TKwimport
640 readable writable var _n_name
: AModuleName
643 # The special import clause of the kernel module. eg `import end`
646 readable writable var _n_visibility
: AVisibility
647 readable writable var _n_kwimport
: TKwimport
648 readable writable var _n_kwend
: TKwend
651 # A visibility modifier
653 # The public visibility is an empty production (no keyword).
655 # Note: even if some visibilities are only valid on some placse (for instance, no `protected` class or no `intrude` method)
656 # the parser has no such a restriction, therefore the semantic phases has to check that the visibilities make sense.
657 abstract class AVisibility
660 class APublicVisibility
663 class APrivateVisibility
665 readable writable var _n_kwprivate
: TKwprivate
667 class AProtectedVisibility
669 readable writable var _n_kwprotected
: TKwprotected
671 class AIntrudeVisibility
673 readable writable var _n_kwintrude
: TKwintrude
677 # While most definition are `AStdClassdef`
678 # There is tow special case of class definition
679 abstract class AClassdef super Prod
680 readable var _n_propdefs
: ANodes[APropdef] = new ANodes[APropdef](self)
683 # A standard class definition with a name, superclasses and properties
686 readable writable var _n_doc
: nullable ADoc = null
687 readable writable var _n_kwredef
: nullable TKwredef = null
688 readable writable var _n_visibility
: AVisibility
689 readable writable var _n_classkind
: AClasskind
690 readable writable var _n_id
: nullable TClassid = null
691 readable var _n_formaldefs
: ANodes[AFormaldef] = new ANodes[AFormaldef](self)
692 readable writable var _n_extern_code_block
: nullable AExternCodeBlock = null
693 readable var _n_superclasses
: ANodes[ASuperclass] = new ANodes[ASuperclass](self)
694 readable writable var _n_kwend
: TKwend
695 redef fun hot_location
do return n_id
.location
698 # The implicit class definition of the implicit main method
703 # The implicit class definition of the top-level methods
708 # The modifier for the kind of class (abstract, interface, etc.)
709 abstract class AClasskind
712 class AConcreteClasskind
714 readable writable var _n_kwclass
: TKwclass
716 class AAbstractClasskind
718 readable writable var _n_kwabstract
: TKwabstract
719 readable writable var _n_kwclass
: TKwclass
721 class AInterfaceClasskind
723 readable writable var _n_kwinterface
: TKwinterface
727 readable writable var _n_kwenum
: TKwenum
729 class AExternClasskind
731 readable writable var _n_kwextern
: TKwextern
732 readable writable var _n_kwclass
: nullable TKwclass = null
735 # The definition of a formal generic parameter type. eg `X: Y`
738 readable writable var _n_id
: TClassid
739 # The bound of the parameter type
740 readable writable var _n_type
: nullable AType = null
743 # A super-class. eg `super X`
746 readable writable var _n_kwsuper
: TKwsuper
747 readable writable var _n_type
: AType
750 # The definition of a property
751 abstract class APropdef
753 readable writable var _n_doc
: nullable ADoc = null
756 # A definition of an attribute
757 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
760 readable writable var _n_kwredef
: nullable TKwredef = null
761 readable writable var _n_visibility
: AVisibility
762 readable writable var _n_kwvar
: TKwvar
764 # The identifier for an old-style attribute (null if new-style)
765 readable writable var _n_id
: nullable TAttrid
767 # The identifier for a new-style attribute (null if old-style)
768 readable writable var _n_id2
: nullable TId
770 readable writable var _n_type
: nullable AType = null
771 readable writable var _n_readable
: nullable AAble = null
772 readable writable var _n_writable
: nullable AAble = null
774 # The initial value, if any
775 readable writable var _n_expr
: nullable AExpr = null
776 redef fun hot_location
778 if n_id
!= null then return n_id
.location
else return n_id2
.location
782 # A definition of all kind of method (including constructors)
783 abstract class AMethPropdef
785 readable writable var _n_kwredef
: nullable TKwredef = null
786 readable writable var _n_visibility
: nullable AVisibility
787 readable writable var _n_methid
: nullable AMethid = null
788 readable writable var _n_signature
: nullable ASignature
789 redef fun hot_location
791 if n_methid
!= null then
792 return n_methid
.location
799 # A method marked abstract
800 # *deferred* is a old synonynmous of *abstract* that comes from PRM, that comes from Eiffel.
801 class ADeferredMethPropdef
803 readable writable var _n_kwmeth
: TKwmeth
806 # A method marked intern
807 class AInternMethPropdef
809 readable writable var _n_kwmeth
: TKwmeth
812 # A method of a constructor marked extern
813 abstract class AExternPropdef
815 readable writable var _n_extern
: nullable TString = null
816 readable writable var _n_extern_calls
: nullable AExternCalls = null
817 readable writable var _n_extern_code_block
: nullable AExternCodeBlock = null
820 # A method marked extern
821 class AExternMethPropdef
823 readable writable var _n_kwmeth
: TKwmeth
826 # A method with a body
827 class AConcreteMethPropdef
829 readable writable var _n_kwmeth
: nullable TKwmeth
830 readable writable var _n_block
: nullable AExpr = null
834 abstract class AInitPropdef
838 # A constructor with a body
839 class AConcreteInitPropdef
840 super AConcreteMethPropdef
842 readable writable var _n_kwinit
: TKwinit
843 redef fun hot_location
do return n_kwinit
.location
846 # A constructor marked extern (defined with the `new` keyword)
847 class AExternInitPropdef
850 readable writable var _n_kwnew
: TKwnew
853 # The implicit main method
854 class AMainMethPropdef
855 super AConcreteMethPropdef
858 # Declaration of callbacks for extern methods
861 readable writable var _n_kwimport
: TKwimport
862 readable var _n_extern_calls
: ANodes[AExternCall] = new ANodes[AExternCall](self)
864 abstract class AExternCall
867 abstract class APropExternCall
870 class ALocalPropExternCall
871 super APropExternCall
872 readable writable var _n_methid
: AMethid
874 class AFullPropExternCall
875 super APropExternCall
876 readable writable var _n_type
: AType
877 readable writable var _n_dot
: nullable TDot = null
878 readable writable var _n_methid
: AMethid
880 class AInitPropExternCall
881 super APropExternCall
882 readable writable var _n_type
: AType
884 class ASuperExternCall
886 readable writable var _n_kwsuper
: TKwsuper
888 abstract class ACastExternCall
891 class ACastAsExternCall
892 super ACastExternCall
893 readable writable var _n_from_type
: AType
894 readable writable var _n_dot
: nullable TDot = null
895 readable writable var _n_kwas
: TKwas
896 readable writable var _n_to_type
: AType
898 class AAsNullableExternCall
899 super ACastExternCall
900 readable writable var _n_type
: AType
901 readable writable var _n_kwas
: TKwas
902 readable writable var _n_kwnullable
: TKwnullable
904 class AAsNotNullableExternCall
905 super ACastExternCall
906 readable writable var _n_type
: AType
907 readable writable var _n_kwas
: TKwas
908 readable writable var _n_kwnot
: TKwnot
909 readable writable var _n_kwnullable
: TKwnullable
912 # A definition of a virtual type
915 readable writable var _n_kwredef
: nullable TKwredef = null
916 readable writable var _n_visibility
: AVisibility
917 readable writable var _n_kwtype
: TKwtype
918 readable writable var _n_id
: TClassid
919 readable writable var _n_type
: AType
922 # A `writable` or `readable` modifier
925 readable writable var _n_visibility
: nullable AVisibility = null
926 readable writable var _n_kwredef
: nullable TKwredef = null
929 # A `readable` modifier
932 readable writable var _n_kwreadable
: TKwreadable
935 # A `writable` modifier
938 readable writable var _n_kwwritable
: TKwwritable
941 # The identifier of a method in a method declaration.
942 # There is a specific class because of operator and setters.
943 abstract class AMethid
948 readable writable var _n_id
: TId
952 readable writable var _n_plus
: TPlus
956 readable writable var _n_minus
: TMinus
960 readable writable var _n_star
: TStar
964 readable writable var _n_slash
: TSlash
968 readable writable var _n_percent
: TPercent
972 readable writable var _n_eq
: TEq
976 readable writable var _n_ne
: TNe
980 readable writable var _n_le
: TLe
984 readable writable var _n_ge
: TGe
988 readable writable var _n_lt
: TLt
992 readable writable var _n_gt
: TGt
996 readable writable var _n_ll
: TLl
1000 readable writable var _n_gg
: TGg
1004 readable writable var _n_obra
: TObra
1005 readable writable var _n_cbra
: TCbra
1007 class AStarshipMethid
1009 readable writable var _n_starship
: TStarship
1013 readable writable var _n_id
: TId
1014 readable writable var _n_assign
: TAssign
1016 class ABraassignMethid
1018 readable writable var _n_obra
: TObra
1019 readable writable var _n_cbra
: TCbra
1020 readable writable var _n_assign
: TAssign
1023 # A signature in a method definition. eg `(x,y:X,z:Z):T`
1026 readable writable var _n_opar
: nullable TOpar = null
1027 readable var _n_params
: ANodes[AParam] = new ANodes[AParam](self)
1028 readable writable var _n_cpar
: nullable TCpar = null
1029 readable writable var _n_type
: nullable AType = null
1032 # A parameter definition in a signature. eg `x:X`
1035 readable writable var _n_id
: TId
1036 readable writable var _n_type
: nullable AType = null
1037 readable writable var _n_dotdotdot
: nullable TDotdotdot = null
1040 # A static type. eg `nullable X[Y]`
1043 readable writable var _n_kwnullable
: nullable TKwnullable = null
1045 # The name of the class or of the formal type
1046 readable writable var _n_id
: TClassid
1048 # Type arguments for a generic type
1049 readable var _n_types
: ANodes[AType] = new ANodes[AType](self)
1052 # A label at the end of a block or in a break/continue statement. eg `label x`
1055 readable writable var _n_kwlabel
: TKwlabel
1056 readable writable var _n_id
: TId
1059 # Expression and statements
1060 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1061 abstract class AExpr
1065 # A sequence of AExpr (usually statements)
1066 # The last AExpr gives the value of the whole block
1069 readable var _n_expr
: ANodes[AExpr] = new ANodes[AExpr](self)
1070 readable writable var _n_kwend
: nullable TKwend = null
1073 # A declaration of a local variable. eg `var x: X = y`
1076 readable writable var _n_kwvar
: TKwvar
1077 readable writable var _n_id
: TId
1078 readable writable var _n_type
: nullable AType = null
1079 readable writable var _n_assign
: nullable TAssign = null
1081 # The initial value, if any
1082 readable writable var _n_expr
: nullable AExpr = null
1085 # A `return` statement. eg `return x`
1088 readable writable var _n_kwreturn
: nullable TKwreturn = null
1089 readable writable var _n_expr
: nullable AExpr = null
1092 # Something that has a label.
1093 abstract class ALabelable
1095 readable writable var _n_label
: nullable ALabel = null
1098 # A `break` statement.
1102 readable writable var _n_kwbreak
: TKwbreak
1103 readable writable var _n_expr
: nullable AExpr = null
1106 # An `abort` statement
1109 readable writable var _n_kwabort
: TKwabort
1112 # A `continue` statement
1116 readable writable var _n_kwcontinue
: nullable TKwcontinue = null
1117 readable writable var _n_expr
: nullable AExpr = null
1124 readable writable var _n_kwdo
: TKwdo
1125 readable writable var _n_block
: nullable AExpr = null
1131 readable writable var _n_kwif
: TKwif
1132 readable writable var _n_expr
: AExpr
1133 readable writable var _n_then
: nullable AExpr = null
1134 readable writable var _n_else
: nullable AExpr = null
1140 readable writable var _n_kwif
: TKwif
1141 readable writable var _n_expr
: AExpr
1142 readable writable var _n_kwthen
: TKwthen
1143 readable writable var _n_then
: AExpr
1144 readable writable var _n_kwelse
: TKwelse
1145 readable writable var _n_else
: AExpr
1148 # A `while` statement
1152 readable writable var _n_kwwhile
: TKwwhile
1153 readable writable var _n_expr
: AExpr
1154 readable writable var _n_kwdo
: TKwdo
1155 readable writable var _n_block
: nullable AExpr = null
1158 # A `loop` statement
1162 readable writable var _n_kwloop
: TKwloop
1163 readable writable var _n_block
: nullable AExpr = null
1170 readable writable var _n_kwfor
: TKwfor
1171 readable var _n_ids
: ANodes[TId] = new ANodes[TId](self)
1172 readable writable var _n_expr
: AExpr
1173 readable writable var _n_kwdo
: TKwdo
1174 readable writable var _n_block
: nullable AExpr = null
1177 # An `assert` statement
1180 readable writable var _n_kwassert
: TKwassert
1181 readable writable var _n_id
: nullable TId = null
1182 readable writable var _n_expr
: AExpr
1183 readable writable var _n_else
: nullable AExpr = null
1186 # Whatever is a simple assignment. eg `= something`
1187 abstract class AAssignFormExpr
1189 readable writable var _n_assign
: TAssign
1190 readable writable var _n_value
: AExpr
1193 # Whatever is a combined assignment. eg `+= something`
1194 abstract class AReassignFormExpr
1196 readable writable var _n_assign_op
: AAssignOp
1197 readable writable var _n_value
: AExpr
1200 # A `once` expression. eg `once x`
1203 readable writable var _n_kwonce
: TKwonce
1206 # A polymorphic invocation of a method
1207 # The form of the invocation (name, arguments, etc) are specific
1208 abstract class ASendExpr
1210 # The receiver of the method invocation
1211 readable writable var _n_expr
: AExpr
1214 # A binary operation on a method
1215 abstract class ABinopExpr
1217 # The second operand of the operation
1218 # Note: the receiver (`n_expr`) is the first operand
1219 readable writable var _n_expr2
: AExpr
1222 # Something that is boolean expression
1223 abstract class ABoolExpr
1230 readable writable var _n_expr
: AExpr
1231 readable writable var _n_expr2
: AExpr
1234 # A `and` expression
1237 readable writable var _n_expr
: AExpr
1238 readable writable var _n_expr2
: AExpr
1241 # A `or else` expression
1244 readable writable var _n_expr
: AExpr
1245 readable writable var _n_expr2
: AExpr
1248 # A `implies` expression
1251 readable writable var _n_expr
: AExpr
1252 readable writable var _n_expr2
: AExpr
1255 # A `not` expression
1258 readable writable var _n_kwnot
: TKwnot
1259 readable writable var _n_expr
: AExpr
1302 # A type-ckeck expression. eg `x isa T`
1305 readable writable var _n_expr
: AExpr
1306 readable writable var _n_type
: AType
1319 # A `<=>` expression
1339 # A unary minus expression. eg `-x`
1342 readable writable var _n_minus
: TMinus
1345 # An explicit instantiation. eg `new T`
1348 readable writable var _n_kwnew
: TKwnew
1349 readable writable var _n_type
: AType
1351 # The name of the named-constructor, if any
1352 readable writable var _n_id
: nullable TId = null
1353 readable writable var _n_args
: AExprs
1356 # Whatever is a old-style attribute access
1357 abstract class AAttrFormExpr
1360 # The receiver of the attribute
1361 readable writable var _n_expr
: AExpr
1363 # The name of the attribute
1364 readable writable var _n_id
: TAttrid
1367 # The read of an attribute. eg `x._a`
1372 # The assignment of an attribute. eg `x._a=y`
1373 class AAttrAssignExpr
1375 super AAssignFormExpr
1378 # Whatever looks-like a call with a standard method and any number of arguments.
1379 abstract class ACallFormExpr
1382 # The name of the method
1383 readable writable var _n_id
: TId
1385 # The arguments of the call
1386 readable writable var _n_args
: AExprs
1389 # A complex setter call (standard or brackets)
1390 abstract class ASendReassignFormExpr
1392 super AReassignFormExpr
1395 # A complex attribute assignment. eg `x._a+=y`
1396 class AAttrReassignExpr
1398 super AReassignFormExpr
1401 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
1402 # 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`.
1403 # Semantic analysis have to transform them to instance of `AVarExpr`.
1408 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
1409 # 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`.
1410 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
1411 class ACallAssignExpr
1413 super AAssignFormExpr
1416 # 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.
1417 # 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`.
1418 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
1419 class ACallReassignExpr
1421 super ASendReassignFormExpr
1424 # A call to `super`. OR a call of a super-constructor
1427 readable writable var _n_qualified
: nullable AQualified = null
1428 readable writable var _n_kwsuper
: TKwsuper
1429 readable writable var _n_args
: AExprs
1432 # A call to the `init` constructor.
1433 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a ACallFormExpr.
1436 readable writable var _n_kwinit
: TKwinit
1437 readable writable var _n_args
: AExprs
1440 # Whatever looks-like a call of the brackets `[]` operator.
1441 abstract class ABraFormExpr
1443 readable writable var _n_args
: AExprs
1446 # A call of the brackets operator. eg `x[y,z]`
1451 # A setter call of the bracket operator. eg `x[y,z]=t`
1452 class ABraAssignExpr
1454 super AAssignFormExpr
1457 # Whatever is an access to a local variable
1458 abstract class AVarFormExpr
1460 readable writable var _n_id
: TId
1463 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
1464 class ABraReassignExpr
1466 super ASendReassignFormExpr
1469 # A local variable read access.
1470 # The parser cannot instantiate them, see `ACallExpr`.
1475 # A local variable simple assigment access
1476 # The parser cannot instantiate them, see `ACallAssignExpr`.
1477 class AVarAssignExpr
1479 super AAssignFormExpr
1482 # A local variable complex assignment access
1483 # The parser cannot instantiate them, see `ACallReassignExpr`.
1484 class AVarReassignExpr
1486 super AReassignFormExpr
1489 # A literal range, open or closed
1490 abstract class ARangeExpr
1492 readable writable var _n_expr
: AExpr
1493 readable writable var _n_expr2
: AExpr
1496 # A closed literal range. eg `[x..y]`
1499 readable writable var _n_obra
: TObra
1500 readable writable var _n_cbra
: TCbra
1503 # An open literal range. eg `[x..y[`
1506 readable writable var _n_obra
: TObra
1507 readable writable var _n_cbra
: TObra
1510 # A literal array. eg. `[x,y,z]`
1513 readable writable var _n_exprs
: AExprs
1519 readable writable var _n_kwself
: nullable TKwself
1522 # When there is no explicit receiver, `self` is implicit
1523 class AImplicitSelfExpr
1527 # A `true` boolean literal constant
1530 readable writable var _n_kwtrue
: TKwtrue
1532 # A `false` boolean literal constant
1535 readable writable var _n_kwfalse
: TKwfalse
1537 # A `null` literal constant
1540 readable writable var _n_kwnull
: TKwnull
1542 # An integer literal
1545 readable writable var _n_number
: TNumber
1550 readable writable var _n_float
: TFloat
1552 # A character literal
1555 readable writable var _n_char
: TChar
1558 abstract class AStringFormExpr
1560 readable writable var _n_string
: Token
1563 # A simple string. eg. `"abc"`
1565 super AStringFormExpr
1568 # The start of a superstring. eg `"abc{`
1569 class AStartStringExpr
1570 super AStringFormExpr
1573 # The middle of a superstring. eg `}abc{`
1574 class AMidStringExpr
1575 super AStringFormExpr
1578 # The end of a superstrng. eg `}abc"`
1579 class AEndStringExpr
1580 super AStringFormExpr
1583 # A superstring literal. eg `"a{x}b{y}c"`
1584 # Each part is modelized a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
1585 class ASuperstringExpr
1587 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1590 # A simple parenthesis. eg `(x)`
1593 readable writable var _n_opar
: TOpar
1594 readable writable var _n_cpar
: TCpar
1597 # Whatevej just contains (and mimic) an other expression
1598 abstract class AProxyExpr
1600 readable writable var _n_expr
: AExpr
1603 # A type cast. eg `x.as(T)`
1606 readable writable var _n_expr
: AExpr
1607 readable writable var _n_kwas
: TKwas
1608 readable writable var _n_opar
: nullable TOpar = null
1609 readable writable var _n_type
: AType
1610 readable writable var _n_cpar
: nullable TCpar = null
1613 # A as-not-null cast. eg `x.as(not null)`
1614 class AAsNotnullExpr
1616 readable writable var _n_expr
: AExpr
1617 readable writable var _n_kwas
: TKwas
1618 readable writable var _n_opar
: nullable TOpar = null
1619 readable writable var _n_kwnot
: TKwnot
1620 readable writable var _n_kwnull
: TKwnull
1621 readable writable var _n_cpar
: nullable TCpar = null
1624 # A is-set check of old-style attributes. eg `isset x._a`
1625 class AIssetAttrExpr
1627 readable writable var _n_kwisset
: TKwisset
1630 # A list of expression separated with commas (arguments for instance)
1631 abstract class AExprs
1633 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1636 class ADebugTypeExpr
1638 readable writable var _n_kwdebug
: TKwdebug
1639 readable writable var _n_kwtype
: TKwtype
1640 readable writable var _n_expr
: AExpr
1641 readable writable var _n_type
: AType
1644 # A simple list of expressions
1649 # A list of expressions enclosed in parentheses
1652 readable writable var _n_opar
: TOpar
1653 readable writable var _n_cpar
: TCpar
1656 # A list of expressions enclosed in brackets
1659 readable writable var _n_obra
: TObra
1660 readable writable var _n_cbra
: TCbra
1663 # A complex assignment operator. eg `+=`
1664 abstract class AAssignOp
1669 readable writable var _n_pluseq
: TPluseq
1671 class AMinusAssignOp
1673 readable writable var _n_minuseq
: TMinuseq
1678 readable writable var _n_quad
: nullable TQuad = null
1679 readable var _n_path
: ANodes[TId] = new ANodes[TId](self)
1680 readable writable var _n_id
: TId
1684 readable writable var _n_kwin
: TKwin
1685 readable writable var _n_string
: TString
1687 class AExternCodeBlock
1689 readable writable var _n_in_language
: nullable AInLanguage = null
1690 readable writable var _n_extern_code_segment
: TExternCodeSegment
1694 readable writable var _n_quad
: nullable TQuad = null
1695 readable var _n_id
: ANodes[TId] = new ANodes[TId](self)
1696 readable writable var _n_classid
: nullable TClassid = null
1699 # A documentation of a definition
1700 # It contains the block of comments just above the declaration
1703 readable var _n_comment
: ANodes[TComment] = new ANodes[TComment](self)
1708 readable writable var _n_at
: nullable TAt = null
1709 readable writable var _n_opar
: nullable TOpar = null
1710 readable var _n_items
: ANodes[AAnnotation] = new ANodes[AAnnotation](self)
1711 readable writable var _n_cpar
: nullable TCpar = null
1715 readable writable var _n_atid
: AAtid
1716 readable writable var _n_opar
: nullable TOpar = null
1717 readable var _n_args
: ANodes[AAtArg] = new ANodes[AAtArg](self)
1718 readable writable var _n_cpar
: nullable TCpar = null
1720 abstract class AAtArg
1725 readable writable var _n_type
: AType
1729 readable writable var _n_expr
: AExpr
1734 abstract class AAtid
1736 readable writable var _n_id
: Token
1747 class AKwreadableAtid
1750 class AKwwritableAtid
1757 # The root of the AST
1760 readable writable var _n_base
: nullable AModule
1761 readable writable var _n_eof
: EOF
1762 init(n_base
: nullable AModule, n_eof
: EOF)
1764 self._n_base
= n_base