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}'"
578 do return "malformed string {text}"
587 do return "malformed character {text}"
591 class TExternCodeSegment
615 # The main node of a Nit source-file
619 readable writable var _n_moduledecl
: nullable AModuledecl = null
620 readable var _n_imports
: ANodes[AImport] = new ANodes[AImport](self)
621 readable var _n_extern_code_blocks
: ANodes[AExternCodeBlock] = new ANodes[AExternCodeBlock](self)
622 readable var _n_classdefs
: ANodes[AClassdef] = new ANodes[AClassdef](self)
625 # The declaration of the module with the documentation, name, and annotations
628 readable writable var _n_doc
: nullable ADoc = null
629 readable writable var _n_kwmodule
: TKwmodule
630 readable writable var _n_name
: AModuleName
633 # A import clause of a module
634 abstract class AImport
638 # A standard import clause. eg `import x`
641 readable writable var _n_visibility
: AVisibility
642 readable writable var _n_kwimport
: TKwimport
643 readable writable var _n_name
: AModuleName
646 # The special import clause of the kernel module. eg `import end`
649 readable writable var _n_visibility
: AVisibility
650 readable writable var _n_kwimport
: TKwimport
651 readable writable var _n_kwend
: TKwend
654 # A visibility modifier
656 # The public visibility is an empty production (no keyword).
658 # Note: even if some visibilities are only valid on some placse (for instance, no `protected` class or no `intrude` method)
659 # the parser has no such a restriction, therefore the semantic phases has to check that the visibilities make sense.
660 abstract class AVisibility
663 class APublicVisibility
666 class APrivateVisibility
668 readable writable var _n_kwprivate
: TKwprivate
670 class AProtectedVisibility
672 readable writable var _n_kwprotected
: TKwprotected
674 class AIntrudeVisibility
676 readable writable var _n_kwintrude
: TKwintrude
680 # While most definition are `AStdClassdef`
681 # There is tow special case of class definition
682 abstract class AClassdef super Prod
683 readable var _n_propdefs
: ANodes[APropdef] = new ANodes[APropdef](self)
686 # A standard class definition with a name, superclasses and properties
689 readable writable var _n_doc
: nullable ADoc = null
690 readable writable var _n_kwredef
: nullable TKwredef = null
691 readable writable var _n_visibility
: AVisibility
692 readable writable var _n_classkind
: AClasskind
693 readable writable var _n_id
: nullable TClassid = null
694 readable var _n_formaldefs
: ANodes[AFormaldef] = new ANodes[AFormaldef](self)
695 readable writable var _n_extern_code_block
: nullable AExternCodeBlock = null
696 readable var _n_superclasses
: ANodes[ASuperclass] = new ANodes[ASuperclass](self)
697 readable writable var _n_kwend
: TKwend
698 redef fun hot_location
do return n_id
.location
701 # The implicit class definition of the implicit main method
706 # The implicit class definition of the top-level methods
711 # The modifier for the kind of class (abstract, interface, etc.)
712 abstract class AClasskind
715 class AConcreteClasskind
717 readable writable var _n_kwclass
: TKwclass
719 class AAbstractClasskind
721 readable writable var _n_kwabstract
: TKwabstract
722 readable writable var _n_kwclass
: TKwclass
724 class AInterfaceClasskind
726 readable writable var _n_kwinterface
: TKwinterface
730 readable writable var _n_kwenum
: TKwenum
732 class AExternClasskind
734 readable writable var _n_kwextern
: TKwextern
735 readable writable var _n_kwclass
: nullable TKwclass = null
738 # The definition of a formal generic parameter type. eg `X: Y`
741 readable writable var _n_id
: TClassid
742 # The bound of the parameter type
743 readable writable var _n_type
: nullable AType = null
746 # A super-class. eg `super X`
749 readable writable var _n_kwsuper
: TKwsuper
750 readable writable var _n_type
: AType
753 # The definition of a property
754 abstract class APropdef
756 readable writable var _n_doc
: nullable ADoc = null
759 # A definition of an attribute
760 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
763 readable writable var _n_kwredef
: nullable TKwredef = null
764 readable writable var _n_visibility
: AVisibility
765 readable writable var _n_kwvar
: TKwvar
767 # The identifier for an old-style attribute (null if new-style)
768 readable writable var _n_id
: nullable TAttrid
770 # The identifier for a new-style attribute (null if old-style)
771 readable writable var _n_id2
: nullable TId
773 readable writable var _n_type
: nullable AType = null
774 readable writable var _n_readable
: nullable AAble = null
775 readable writable var _n_writable
: nullable AAble = null
777 # The initial value, if any
778 readable writable var _n_expr
: nullable AExpr = null
779 redef fun hot_location
781 if n_id
!= null then return n_id
.location
else return n_id2
.location
785 # A definition of all kind of method (including constructors)
786 abstract class AMethPropdef
788 readable writable var _n_kwredef
: nullable TKwredef = null
789 readable writable var _n_visibility
: nullable AVisibility
790 readable writable var _n_methid
: nullable AMethid = null
791 readable writable var _n_signature
: nullable ASignature
792 redef fun hot_location
794 if n_methid
!= null then
795 return n_methid
.location
802 # A method marked abstract
803 # *deferred* is a old synonynmous of *abstract* that comes from PRM, that comes from Eiffel.
804 class ADeferredMethPropdef
806 readable writable var _n_kwmeth
: TKwmeth
809 # A method marked intern
810 class AInternMethPropdef
812 readable writable var _n_kwmeth
: TKwmeth
815 # A method of a constructor marked extern
816 abstract class AExternPropdef
818 readable writable var _n_extern
: nullable TString = null
819 readable writable var _n_extern_calls
: nullable AExternCalls = null
820 readable writable var _n_extern_code_block
: nullable AExternCodeBlock = null
823 # A method marked extern
824 class AExternMethPropdef
826 readable writable var _n_kwmeth
: TKwmeth
829 # A method with a body
830 class AConcreteMethPropdef
832 readable writable var _n_kwmeth
: nullable TKwmeth
833 readable writable var _n_block
: nullable AExpr = null
837 abstract class AInitPropdef
841 # A constructor with a body
842 class AConcreteInitPropdef
843 super AConcreteMethPropdef
845 readable writable var _n_kwinit
: TKwinit
846 redef fun hot_location
do return n_kwinit
.location
849 # A constructor marked extern (defined with the `new` keyword)
850 class AExternInitPropdef
853 readable writable var _n_kwnew
: TKwnew
856 # The implicit main method
857 class AMainMethPropdef
858 super AConcreteMethPropdef
861 # Declaration of callbacks for extern methods
864 readable writable var _n_kwimport
: TKwimport
865 readable var _n_extern_calls
: ANodes[AExternCall] = new ANodes[AExternCall](self)
867 abstract class AExternCall
870 abstract class APropExternCall
873 class ALocalPropExternCall
874 super APropExternCall
875 readable writable var _n_methid
: AMethid
877 class AFullPropExternCall
878 super APropExternCall
879 readable writable var _n_type
: AType
880 readable writable var _n_dot
: nullable TDot = null
881 readable writable var _n_methid
: AMethid
883 class AInitPropExternCall
884 super APropExternCall
885 readable writable var _n_type
: AType
887 class ASuperExternCall
889 readable writable var _n_kwsuper
: TKwsuper
891 abstract class ACastExternCall
894 class ACastAsExternCall
895 super ACastExternCall
896 readable writable var _n_from_type
: AType
897 readable writable var _n_dot
: nullable TDot = null
898 readable writable var _n_kwas
: TKwas
899 readable writable var _n_to_type
: AType
901 class AAsNullableExternCall
902 super ACastExternCall
903 readable writable var _n_type
: AType
904 readable writable var _n_kwas
: TKwas
905 readable writable var _n_kwnullable
: TKwnullable
907 class AAsNotNullableExternCall
908 super ACastExternCall
909 readable writable var _n_type
: AType
910 readable writable var _n_kwas
: TKwas
911 readable writable var _n_kwnot
: TKwnot
912 readable writable var _n_kwnullable
: TKwnullable
915 # A definition of a virtual type
918 readable writable var _n_kwredef
: nullable TKwredef = null
919 readable writable var _n_visibility
: AVisibility
920 readable writable var _n_kwtype
: TKwtype
921 readable writable var _n_id
: TClassid
922 readable writable var _n_type
: AType
925 # A `writable` or `readable` modifier
928 readable writable var _n_visibility
: nullable AVisibility = null
929 readable writable var _n_kwredef
: nullable TKwredef = null
932 # A `readable` modifier
935 readable writable var _n_kwreadable
: TKwreadable
938 # A `writable` modifier
941 readable writable var _n_kwwritable
: TKwwritable
944 # The identifier of a method in a method declaration.
945 # There is a specific class because of operator and setters.
946 abstract class AMethid
951 readable writable var _n_id
: TId
955 readable writable var _n_plus
: TPlus
959 readable writable var _n_minus
: TMinus
963 readable writable var _n_star
: TStar
967 readable writable var _n_slash
: TSlash
971 readable writable var _n_percent
: TPercent
975 readable writable var _n_eq
: TEq
979 readable writable var _n_ne
: TNe
983 readable writable var _n_le
: TLe
987 readable writable var _n_ge
: TGe
991 readable writable var _n_lt
: TLt
995 readable writable var _n_gt
: TGt
999 readable writable var _n_ll
: TLl
1003 readable writable var _n_gg
: TGg
1007 readable writable var _n_obra
: TObra
1008 readable writable var _n_cbra
: TCbra
1010 class AStarshipMethid
1012 readable writable var _n_starship
: TStarship
1016 readable writable var _n_id
: TId
1017 readable writable var _n_assign
: TAssign
1019 class ABraassignMethid
1021 readable writable var _n_obra
: TObra
1022 readable writable var _n_cbra
: TCbra
1023 readable writable var _n_assign
: TAssign
1026 # A signature in a method definition. eg `(x,y:X,z:Z):T`
1029 readable writable var _n_opar
: nullable TOpar = null
1030 readable var _n_params
: ANodes[AParam] = new ANodes[AParam](self)
1031 readable writable var _n_cpar
: nullable TCpar = null
1032 readable writable var _n_type
: nullable AType = null
1035 # A parameter definition in a signature. eg `x:X`
1038 readable writable var _n_id
: TId
1039 readable writable var _n_type
: nullable AType = null
1040 readable writable var _n_dotdotdot
: nullable TDotdotdot = null
1043 # A static type. eg `nullable X[Y]`
1046 readable writable var _n_kwnullable
: nullable TKwnullable = null
1048 # The name of the class or of the formal type
1049 readable writable var _n_id
: TClassid
1051 # Type arguments for a generic type
1052 readable var _n_types
: ANodes[AType] = new ANodes[AType](self)
1055 # A label at the end of a block or in a break/continue statement. eg `label x`
1058 readable writable var _n_kwlabel
: TKwlabel
1059 readable writable var _n_id
: TId
1062 # Expression and statements
1063 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1064 abstract class AExpr
1068 # A sequence of AExpr (usually statements)
1069 # The last AExpr gives the value of the whole block
1072 readable var _n_expr
: ANodes[AExpr] = new ANodes[AExpr](self)
1073 readable writable var _n_kwend
: nullable TKwend = null
1076 # A declaration of a local variable. eg `var x: X = y`
1079 readable writable var _n_kwvar
: TKwvar
1080 readable writable var _n_id
: TId
1081 readable writable var _n_type
: nullable AType = null
1082 readable writable var _n_assign
: nullable TAssign = null
1084 # The initial value, if any
1085 readable writable var _n_expr
: nullable AExpr = null
1088 # A `return` statement. eg `return x`
1091 readable writable var _n_kwreturn
: nullable TKwreturn = null
1092 readable writable var _n_expr
: nullable AExpr = null
1095 # Something that has a label.
1096 abstract class ALabelable
1098 readable writable var _n_label
: nullable ALabel = null
1101 # A `break` statement.
1105 readable writable var _n_kwbreak
: TKwbreak
1106 readable writable var _n_expr
: nullable AExpr = null
1109 # An `abort` statement
1112 readable writable var _n_kwabort
: TKwabort
1115 # A `continue` statement
1119 readable writable var _n_kwcontinue
: nullable TKwcontinue = null
1120 readable writable var _n_expr
: nullable AExpr = null
1127 readable writable var _n_kwdo
: TKwdo
1128 readable writable var _n_block
: nullable AExpr = null
1134 readable writable var _n_kwif
: TKwif
1135 readable writable var _n_expr
: AExpr
1136 readable writable var _n_then
: nullable AExpr = null
1137 readable writable var _n_else
: nullable AExpr = null
1143 readable writable var _n_kwif
: TKwif
1144 readable writable var _n_expr
: AExpr
1145 readable writable var _n_kwthen
: TKwthen
1146 readable writable var _n_then
: AExpr
1147 readable writable var _n_kwelse
: TKwelse
1148 readable writable var _n_else
: AExpr
1151 # A `while` statement
1155 readable writable var _n_kwwhile
: TKwwhile
1156 readable writable var _n_expr
: AExpr
1157 readable writable var _n_kwdo
: TKwdo
1158 readable writable var _n_block
: nullable AExpr = null
1161 # A `loop` statement
1165 readable writable var _n_kwloop
: TKwloop
1166 readable writable var _n_block
: nullable AExpr = null
1173 readable writable var _n_kwfor
: TKwfor
1174 readable var _n_ids
: ANodes[TId] = new ANodes[TId](self)
1175 readable writable var _n_expr
: AExpr
1176 readable writable var _n_kwdo
: TKwdo
1177 readable writable var _n_block
: nullable AExpr = null
1180 # An `assert` statement
1183 readable writable var _n_kwassert
: TKwassert
1184 readable writable var _n_id
: nullable TId = null
1185 readable writable var _n_expr
: AExpr
1186 readable writable var _n_else
: nullable AExpr = null
1189 # Whatever is a simple assignment. eg `= something`
1190 abstract class AAssignFormExpr
1192 readable writable var _n_assign
: TAssign
1193 readable writable var _n_value
: AExpr
1196 # Whatever is a combined assignment. eg `+= something`
1197 abstract class AReassignFormExpr
1199 readable writable var _n_assign_op
: AAssignOp
1200 readable writable var _n_value
: AExpr
1203 # A `once` expression. eg `once x`
1206 readable writable var _n_kwonce
: TKwonce
1209 # A polymorphic invocation of a method
1210 # The form of the invocation (name, arguments, etc) are specific
1211 abstract class ASendExpr
1213 # The receiver of the method invocation
1214 readable writable var _n_expr
: AExpr
1217 # A binary operation on a method
1218 abstract class ABinopExpr
1220 # The second operand of the operation
1221 # Note: the receiver (`n_expr`) is the first operand
1222 readable writable var _n_expr2
: AExpr
1225 # Something that is boolean expression
1226 abstract class ABoolExpr
1233 readable writable var _n_expr
: AExpr
1234 readable writable var _n_expr2
: AExpr
1237 # A `and` expression
1240 readable writable var _n_expr
: AExpr
1241 readable writable var _n_expr2
: AExpr
1244 # A `or else` expression
1247 readable writable var _n_expr
: AExpr
1248 readable writable var _n_expr2
: AExpr
1251 # A `implies` expression
1254 readable writable var _n_expr
: AExpr
1255 readable writable var _n_expr2
: AExpr
1258 # A `not` expression
1261 readable writable var _n_kwnot
: TKwnot
1262 readable writable var _n_expr
: AExpr
1305 # A type-ckeck expression. eg `x isa T`
1308 readable writable var _n_expr
: AExpr
1309 readable writable var _n_type
: AType
1322 # A `<=>` expression
1342 # A unary minus expression. eg `-x`
1345 readable writable var _n_minus
: TMinus
1348 # An explicit instantiation. eg `new T`
1351 readable writable var _n_kwnew
: TKwnew
1352 readable writable var _n_type
: AType
1354 # The name of the named-constructor, if any
1355 readable writable var _n_id
: nullable TId = null
1356 readable writable var _n_args
: AExprs
1359 # Whatever is a old-style attribute access
1360 abstract class AAttrFormExpr
1363 # The receiver of the attribute
1364 readable writable var _n_expr
: AExpr
1366 # The name of the attribute
1367 readable writable var _n_id
: TAttrid
1370 # The read of an attribute. eg `x._a`
1375 # The assignment of an attribute. eg `x._a=y`
1376 class AAttrAssignExpr
1378 super AAssignFormExpr
1381 # Whatever looks-like a call with a standard method and any number of arguments.
1382 abstract class ACallFormExpr
1385 # The name of the method
1386 readable writable var _n_id
: TId
1388 # The arguments of the call
1389 readable writable var _n_args
: AExprs
1392 # A complex setter call (standard or brackets)
1393 abstract class ASendReassignFormExpr
1395 super AReassignFormExpr
1398 # A complex attribute assignment. eg `x._a+=y`
1399 class AAttrReassignExpr
1401 super AReassignFormExpr
1404 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
1405 # 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`.
1406 # Semantic analysis have to transform them to instance of `AVarExpr`.
1411 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
1412 # 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`.
1413 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
1414 class ACallAssignExpr
1416 super AAssignFormExpr
1419 # 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.
1420 # 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`.
1421 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
1422 class ACallReassignExpr
1424 super ASendReassignFormExpr
1427 # A call to `super`. OR a call of a super-constructor
1430 readable writable var _n_qualified
: nullable AQualified = null
1431 readable writable var _n_kwsuper
: TKwsuper
1432 readable writable var _n_args
: AExprs
1435 # A call to the `init` constructor.
1436 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a ACallFormExpr.
1439 readable writable var _n_kwinit
: TKwinit
1440 readable writable var _n_args
: AExprs
1443 # Whatever looks-like a call of the brackets `[]` operator.
1444 abstract class ABraFormExpr
1446 readable writable var _n_args
: AExprs
1449 # A call of the brackets operator. eg `x[y,z]`
1454 # A setter call of the bracket operator. eg `x[y,z]=t`
1455 class ABraAssignExpr
1457 super AAssignFormExpr
1460 # Whatever is an access to a local variable
1461 abstract class AVarFormExpr
1463 readable writable var _n_id
: TId
1466 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
1467 class ABraReassignExpr
1469 super ASendReassignFormExpr
1472 # A local variable read access.
1473 # The parser cannot instantiate them, see `ACallExpr`.
1478 # A local variable simple assigment access
1479 # The parser cannot instantiate them, see `ACallAssignExpr`.
1480 class AVarAssignExpr
1482 super AAssignFormExpr
1485 # A local variable complex assignment access
1486 # The parser cannot instantiate them, see `ACallReassignExpr`.
1487 class AVarReassignExpr
1489 super AReassignFormExpr
1492 # A literal range, open or closed
1493 abstract class ARangeExpr
1495 readable writable var _n_expr
: AExpr
1496 readable writable var _n_expr2
: AExpr
1499 # A closed literal range. eg `[x..y]`
1502 readable writable var _n_obra
: TObra
1503 readable writable var _n_cbra
: TCbra
1506 # An open literal range. eg `[x..y[`
1509 readable writable var _n_obra
: TObra
1510 readable writable var _n_cbra
: TObra
1513 # A literal array. eg. `[x,y,z]`
1516 readable writable var _n_exprs
: AExprs
1522 readable writable var _n_kwself
: nullable TKwself
1525 # When there is no explicit receiver, `self` is implicit
1526 class AImplicitSelfExpr
1530 # A `true` boolean literal constant
1533 readable writable var _n_kwtrue
: TKwtrue
1535 # A `false` boolean literal constant
1538 readable writable var _n_kwfalse
: TKwfalse
1540 # A `null` literal constant
1543 readable writable var _n_kwnull
: TKwnull
1545 # An integer literal
1549 # An integer literal in decimal format
1552 readable writable var _n_number
: TNumber
1554 # An integer literal in hexadecimal format
1557 readable writable var _n_hex_number
: THexNumber
1562 readable writable var _n_float
: TFloat
1564 # A character literal
1567 readable writable var _n_char
: TChar
1570 abstract class AStringFormExpr
1572 readable writable var _n_string
: Token
1575 # A simple string. eg. `"abc"`
1577 super AStringFormExpr
1580 # The start of a superstring. eg `"abc{`
1581 class AStartStringExpr
1582 super AStringFormExpr
1585 # The middle of a superstring. eg `}abc{`
1586 class AMidStringExpr
1587 super AStringFormExpr
1590 # The end of a superstrng. eg `}abc"`
1591 class AEndStringExpr
1592 super AStringFormExpr
1595 # A superstring literal. eg `"a{x}b{y}c"`
1596 # Each part is modelized a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
1597 class ASuperstringExpr
1599 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1602 # A simple parenthesis. eg `(x)`
1605 readable writable var _n_opar
: TOpar
1606 readable writable var _n_cpar
: TCpar
1609 # Whatevej just contains (and mimic) an other expression
1610 abstract class AProxyExpr
1612 readable writable var _n_expr
: AExpr
1615 # A type cast. eg `x.as(T)`
1618 readable writable var _n_expr
: AExpr
1619 readable writable var _n_kwas
: TKwas
1620 readable writable var _n_opar
: nullable TOpar = null
1621 readable writable var _n_type
: AType
1622 readable writable var _n_cpar
: nullable TCpar = null
1625 # A as-not-null cast. eg `x.as(not null)`
1626 class AAsNotnullExpr
1628 readable writable var _n_expr
: AExpr
1629 readable writable var _n_kwas
: TKwas
1630 readable writable var _n_opar
: nullable TOpar = null
1631 readable writable var _n_kwnot
: TKwnot
1632 readable writable var _n_kwnull
: TKwnull
1633 readable writable var _n_cpar
: nullable TCpar = null
1636 # A is-set check of old-style attributes. eg `isset x._a`
1637 class AIssetAttrExpr
1639 readable writable var _n_kwisset
: TKwisset
1642 # A list of expression separated with commas (arguments for instance)
1643 abstract class AExprs
1645 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1648 class ADebugTypeExpr
1650 readable writable var _n_kwdebug
: TKwdebug
1651 readable writable var _n_kwtype
: TKwtype
1652 readable writable var _n_expr
: AExpr
1653 readable writable var _n_type
: AType
1656 # A simple list of expressions
1661 # A list of expressions enclosed in parentheses
1664 readable writable var _n_opar
: TOpar
1665 readable writable var _n_cpar
: TCpar
1668 # A list of expressions enclosed in brackets
1671 readable writable var _n_obra
: TObra
1672 readable writable var _n_cbra
: TCbra
1675 # A complex assignment operator. eg `+=`
1676 abstract class AAssignOp
1681 readable writable var _n_pluseq
: TPluseq
1683 class AMinusAssignOp
1685 readable writable var _n_minuseq
: TMinuseq
1690 readable writable var _n_quad
: nullable TQuad = null
1691 readable var _n_path
: ANodes[TId] = new ANodes[TId](self)
1692 readable writable var _n_id
: TId
1696 readable writable var _n_kwin
: TKwin
1697 readable writable var _n_string
: TString
1699 class AExternCodeBlock
1701 readable writable var _n_in_language
: nullable AInLanguage = null
1702 readable writable var _n_extern_code_segment
: TExternCodeSegment
1706 readable writable var _n_quad
: nullable TQuad = null
1707 readable var _n_id
: ANodes[TId] = new ANodes[TId](self)
1708 readable writable var _n_classid
: nullable TClassid = null
1711 # A documentation of a definition
1712 # It contains the block of comments just above the declaration
1715 readable var _n_comment
: ANodes[TComment] = new ANodes[TComment](self)
1720 readable writable var _n_at
: nullable TAt = null
1721 readable writable var _n_opar
: nullable TOpar = null
1722 readable var _n_items
: ANodes[AAnnotation] = new ANodes[AAnnotation](self)
1723 readable writable var _n_cpar
: nullable TCpar = null
1727 readable writable var _n_atid
: AAtid
1728 readable writable var _n_opar
: nullable TOpar = null
1729 readable var _n_args
: ANodes[AAtArg] = new ANodes[AAtArg](self)
1730 readable writable var _n_cpar
: nullable TCpar = null
1732 abstract class AAtArg
1737 readable writable var _n_type
: AType
1741 readable writable var _n_expr
: AExpr
1746 abstract class AAtid
1748 readable writable var _n_id
: Token
1759 class AKwreadableAtid
1762 class AKwwritableAtid
1769 # The root of the AST
1772 readable writable var _n_base
: nullable AModule
1773 readable writable var _n_eof
: EOF
1774 init(n_base
: nullable AModule, n_eof
: EOF)
1776 self._n_base
= n_base