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
137 # Ancestor of all tokens
138 # A token is a node that has a `text` but no children.
142 # The raw content on the token
143 fun text
: String is abstract
144 fun text
=(text
: String) is abstract
146 # The previous token in the Lexer.
147 # May have disapeared in the AST
148 var prev_token
: nullable Token
150 # The next token in the Lexer.
151 # May have disapeared in the AST
152 var next_token
: nullable Token
154 redef fun to_s
: String do
158 redef fun visit_all
(v
: Visitor) do end
159 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode) do end
162 # Ancestor of all productions
163 # A production is a node without text but that usually has children.
167 fun location
=(l
: Location) do _location
= l
169 # All the annotations attached directly to the node
170 readable writable var _n_annotations
: nullable AAnnotations = null
172 redef fun replace_with
(n
: ANode)
176 if n
._location
== null then n
._location
= _location
180 # Abstract standard visitor on the AST
181 abstract class Visitor
182 # What the visitor do when a node is visited
183 # Concrete visitors should implement this method.
185 protected fun visit
(e
: ANode) is abstract
187 # Ask the visitor to visit a given node.
188 # Usually automatically called by visit_all* methods.
189 # This method should not be redefined
190 fun enter_visit
(e
: nullable ANode)
192 if e
== null then return
193 var old
= _current_node
199 # The current visited node
200 readable writable var _current_node
: nullable ANode = null
203 # Token of end of line (basically `\n`)
212 # Token of a line of comments
213 # Starts with the `#` and contains the final end-of-line (if any)
218 # A token associated with a keyword
219 abstract class TokenKeyword
223 return "keyword '{text}'"
404 # A token associated with an operator (and other lookalike symbols)
405 abstract class TokenOperator
409 return "operator '{text}'"
476 # A class (or formal type) identifier. They start with an uppercase.
481 do return "type identifier '{text}'"
485 # A standard identifier (variable, method...). They start with a lowercase.
490 do return "identifier '{text}'"
494 # An attribute identifier. They start with an underscore.
499 do return "attribute '{text}'"
503 # A token of a literal value (string, integer, etc).
504 abstract class TokenLiteral
508 do return "literal value '{text}'"
538 do return "malformed string {text}"
547 do return "malformed character {text}"
551 class TExternCodeSegment
575 # The main node of a Nit source-file
579 readable writable var _n_moduledecl
: nullable AModuledecl = null
580 readable var _n_imports
: ANodes[AImport] = new ANodes[AImport](self)
581 readable var _n_extern_code_blocks
: ANodes[AExternCodeBlock] = new ANodes[AExternCodeBlock](self)
582 readable var _n_classdefs
: ANodes[AClassdef] = new ANodes[AClassdef](self)
585 # The declaration of the module with the documentation, name, and annotations
588 readable writable var _n_doc
: nullable ADoc = null
589 readable writable var _n_kwmodule
: TKwmodule
590 readable writable var _n_name
: AModuleName
593 # A import clause of a module
594 abstract class AImport
598 # A standard import clause. eg `import x`
601 readable writable var _n_visibility
: AVisibility
602 readable writable var _n_kwimport
: TKwimport
603 readable writable var _n_name
: AModuleName
606 # The special import clause of the kernel module. eg `import end`
609 readable writable var _n_visibility
: AVisibility
610 readable writable var _n_kwimport
: TKwimport
611 readable writable var _n_kwend
: TKwend
614 # A visibility modifier
616 # The public visibility is an empty production (no keyword).
618 # Note: even if some visibilities are only valid on some placse (for instance, no `protected` class or no `intrude` method)
619 # the parser has no such a restriction, therefore the semantic phases has to check that the visibilities make sense.
620 abstract class AVisibility
623 class APublicVisibility
626 class APrivateVisibility
628 readable writable var _n_kwprivate
: TKwprivate
630 class AProtectedVisibility
632 readable writable var _n_kwprotected
: TKwprotected
634 class AIntrudeVisibility
636 readable writable var _n_kwintrude
: TKwintrude
640 # While most definition are `AStdClassdef`
641 # There is tow special case of class definition
642 abstract class AClassdef super Prod
643 readable var _n_propdefs
: ANodes[APropdef] = new ANodes[APropdef](self)
646 # A standard class definition with a name, superclasses and properties
649 readable writable var _n_doc
: nullable ADoc = null
650 readable writable var _n_kwredef
: nullable TKwredef = null
651 readable writable var _n_visibility
: AVisibility
652 readable writable var _n_classkind
: AClasskind
653 readable writable var _n_id
: nullable TClassid = null
654 readable var _n_formaldefs
: ANodes[AFormaldef] = new ANodes[AFormaldef](self)
655 readable writable var _n_extern_code_block
: nullable AExternCodeBlock = null
656 readable var _n_superclasses
: ANodes[ASuperclass] = new ANodes[ASuperclass](self)
657 readable writable var _n_kwend
: TKwend
658 redef fun hot_location
do return n_id
.location
661 # The implicit class definition of the implicit main method
666 # The implicit class definition of the top-level methods
671 # The modifier for the kind of class (abstract, interface, etc.)
672 abstract class AClasskind
675 class AConcreteClasskind
677 readable writable var _n_kwclass
: TKwclass
679 class AAbstractClasskind
681 readable writable var _n_kwabstract
: TKwabstract
682 readable writable var _n_kwclass
: TKwclass
684 class AInterfaceClasskind
686 readable writable var _n_kwinterface
: TKwinterface
690 readable writable var _n_kwenum
: TKwenum
692 class AExternClasskind
694 readable writable var _n_kwextern
: TKwextern
695 readable writable var _n_kwclass
: nullable TKwclass = null
698 # The definition of a formal generic parameter type. eg `X: Y`
701 readable writable var _n_id
: TClassid
702 # The bound of the parameter type
703 readable writable var _n_type
: nullable AType = null
706 # A super-class. eg `super X`
709 readable writable var _n_kwsuper
: TKwsuper
710 readable writable var _n_type
: AType
713 # The definition of a property
714 abstract class APropdef
716 readable writable var _n_doc
: nullable ADoc = null
719 # A definition of an attribute
720 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
723 readable writable var _n_kwredef
: nullable TKwredef = null
724 readable writable var _n_visibility
: AVisibility
725 readable writable var _n_kwvar
: TKwvar
727 # The identifier for an old-style attribute (null if new-style)
728 readable writable var _n_id
: nullable TAttrid
730 # The identifier for a new-style attribute (null if old-style)
731 readable writable var _n_id2
: nullable TId
733 readable writable var _n_type
: nullable AType = null
734 readable writable var _n_readable
: nullable AAble = null
735 readable writable var _n_writable
: nullable AAble = null
737 # The initial value, if any
738 readable writable var _n_expr
: nullable AExpr = null
739 redef fun hot_location
741 if n_id
!= null then return n_id
.location
else return n_id2
.location
745 # A definition of all kind of method (including constructors)
746 abstract class AMethPropdef
748 readable writable var _n_kwredef
: nullable TKwredef = null
749 readable writable var _n_visibility
: nullable AVisibility
750 readable writable var _n_methid
: nullable AMethid = null
751 readable writable var _n_signature
: nullable ASignature
752 redef fun hot_location
754 if n_methid
!= null then
755 return n_methid
.location
762 # A method marked abstract
763 # *deferred* is a old synonynmous of *abstract* that comes from PRM, that comes from Eiffel.
764 class ADeferredMethPropdef
766 readable writable var _n_kwmeth
: TKwmeth
769 # A method marked intern
770 class AInternMethPropdef
772 readable writable var _n_kwmeth
: TKwmeth
775 # A method of a constructor marked extern
776 abstract class AExternPropdef
778 readable writable var _n_extern
: nullable TString = null
779 readable writable var _n_extern_calls
: nullable AExternCalls = null
780 readable writable var _n_extern_code_block
: nullable AExternCodeBlock = null
783 # A method marked extern
784 class AExternMethPropdef
786 readable writable var _n_kwmeth
: TKwmeth
789 # A method with a body
790 class AConcreteMethPropdef
792 readable writable var _n_kwmeth
: nullable TKwmeth
793 readable writable var _n_block
: nullable AExpr = null
797 abstract class AInitPropdef
801 # A constructor with a body
802 class AConcreteInitPropdef
803 super AConcreteMethPropdef
805 readable writable var _n_kwinit
: TKwinit
806 redef fun hot_location
do return n_kwinit
.location
809 # A constructor marked extern (defined with the `new` keyword)
810 class AExternInitPropdef
813 readable writable var _n_kwnew
: TKwnew
816 # The implicit main method
817 class AMainMethPropdef
818 super AConcreteMethPropdef
821 # Declaration of callbacks for extern methods
824 readable writable var _n_kwimport
: TKwimport
825 readable var _n_extern_calls
: ANodes[AExternCall] = new ANodes[AExternCall](self)
827 abstract class AExternCall
830 abstract class APropExternCall
833 class ALocalPropExternCall
834 super APropExternCall
835 readable writable var _n_methid
: AMethid
837 class AFullPropExternCall
838 super APropExternCall
839 readable writable var _n_classid
: TClassid
840 readable writable var _n_quad
: nullable TQuad = null
841 readable writable var _n_methid
: AMethid
843 class AInitPropExternCall
844 super APropExternCall
845 readable writable var _n_classid
: TClassid
847 class ASuperExternCall
849 readable writable var _n_kwsuper
: TKwsuper
851 abstract class ACastExternCall
854 class ACastAsExternCall
855 super ACastExternCall
856 readable writable var _n_from_type
: AType
857 readable writable var _n_kwas
: TKwas
858 readable writable var _n_to_type
: AType
860 class AAsNullableExternCall
861 super ACastExternCall
862 readable writable var _n_type
: AType
863 readable writable var _n_kwas
: TKwas
864 readable writable var _n_kwnullable
: TKwnullable
866 class AAsNotNullableExternCall
867 super ACastExternCall
868 readable writable var _n_type
: AType
869 readable writable var _n_kwas
: TKwas
870 readable writable var _n_kwnot
: TKwnot
871 readable writable var _n_kwnullable
: TKwnullable
874 # A definition of a virtual type
877 readable writable var _n_kwredef
: nullable TKwredef = null
878 readable writable var _n_visibility
: AVisibility
879 readable writable var _n_kwtype
: TKwtype
880 readable writable var _n_id
: TClassid
881 readable writable var _n_type
: AType
884 # A `writable` or `readable` modifier
887 readable writable var _n_visibility
: nullable AVisibility = null
888 readable writable var _n_kwredef
: nullable TKwredef = null
891 # A `readable` modifier
894 readable writable var _n_kwreadable
: TKwreadable
897 # A `writable` modifier
900 readable writable var _n_kwwritable
: TKwwritable
903 # The identifier of a method in a method declaration.
904 # There is a specific class because of operator and setters.
905 abstract class AMethid
910 readable writable var _n_id
: TId
914 readable writable var _n_plus
: TPlus
918 readable writable var _n_minus
: TMinus
922 readable writable var _n_star
: TStar
926 readable writable var _n_slash
: TSlash
930 readable writable var _n_percent
: TPercent
934 readable writable var _n_eq
: TEq
938 readable writable var _n_ne
: TNe
942 readable writable var _n_le
: TLe
946 readable writable var _n_ge
: TGe
950 readable writable var _n_lt
: TLt
954 readable writable var _n_gt
: TGt
958 readable writable var _n_ll
: TLl
962 readable writable var _n_gg
: TGg
966 readable writable var _n_obra
: TObra
967 readable writable var _n_cbra
: TCbra
969 class AStarshipMethid
971 readable writable var _n_starship
: TStarship
975 readable writable var _n_id
: TId
976 readable writable var _n_assign
: TAssign
978 class ABraassignMethid
980 readable writable var _n_obra
: TObra
981 readable writable var _n_cbra
: TCbra
982 readable writable var _n_assign
: TAssign
985 # A signature in a method definition. eg `(x,y:X,z:Z):T`
988 readable writable var _n_opar
: nullable TOpar = null
989 readable var _n_params
: ANodes[AParam] = new ANodes[AParam](self)
990 readable writable var _n_cpar
: nullable TCpar = null
991 readable writable var _n_type
: nullable AType = null
994 # A parameter definition in a signature. eg `x:X`
997 readable writable var _n_id
: TId
998 readable writable var _n_type
: nullable AType = null
999 readable writable var _n_dotdotdot
: nullable TDotdotdot = null
1002 # A static type. eg `nullable X[Y]`
1005 readable writable var _n_kwnullable
: nullable TKwnullable = null
1007 # The name of the class or of the formal type
1008 readable writable var _n_id
: TClassid
1010 # Type arguments for a generic type
1011 readable var _n_types
: ANodes[AType] = new ANodes[AType](self)
1014 # A label at the end of a block or in a break/continue statement. eg `label x`
1017 readable writable var _n_kwlabel
: TKwlabel
1018 readable writable var _n_id
: TId
1021 # Expression and statements
1022 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1023 abstract class AExpr
1027 # A sequence of AExpr (usually statements)
1028 # The last AExpr gives the value of the whole block
1031 readable var _n_expr
: ANodes[AExpr] = new ANodes[AExpr](self)
1032 readable writable var _n_kwend
: nullable TKwend = null
1035 # A declaration of a local variable. eg `var x: X = y`
1038 readable writable var _n_kwvar
: TKwvar
1039 readable writable var _n_id
: TId
1040 readable writable var _n_type
: nullable AType = null
1041 readable writable var _n_assign
: nullable TAssign = null
1043 # The initial value, if any
1044 readable writable var _n_expr
: nullable AExpr = null
1047 # A `return` statement. eg `return x`
1050 readable writable var _n_kwreturn
: nullable TKwreturn = null
1051 readable writable var _n_expr
: nullable AExpr = null
1054 # Something that has a label.
1055 abstract class ALabelable
1057 readable writable var _n_label
: nullable ALabel = null
1060 # A `break` statement.
1064 readable writable var _n_kwbreak
: TKwbreak
1065 readable writable var _n_expr
: nullable AExpr = null
1068 # An `abort` statement
1071 readable writable var _n_kwabort
: TKwabort
1074 # A `continue` statement
1078 readable writable var _n_kwcontinue
: nullable TKwcontinue = null
1079 readable writable var _n_expr
: nullable AExpr = null
1086 readable writable var _n_kwdo
: TKwdo
1087 readable writable var _n_block
: nullable AExpr = null
1093 readable writable var _n_kwif
: TKwif
1094 readable writable var _n_expr
: AExpr
1095 readable writable var _n_then
: nullable AExpr = null
1096 readable writable var _n_else
: nullable AExpr = null
1102 readable writable var _n_kwif
: TKwif
1103 readable writable var _n_expr
: AExpr
1104 readable writable var _n_kwthen
: TKwthen
1105 readable writable var _n_then
: AExpr
1106 readable writable var _n_kwelse
: TKwelse
1107 readable writable var _n_else
: AExpr
1110 # A `while` statement
1114 readable writable var _n_kwwhile
: TKwwhile
1115 readable writable var _n_expr
: AExpr
1116 readable writable var _n_kwdo
: TKwdo
1117 readable writable var _n_block
: nullable AExpr = null
1120 # A `loop` statement
1124 readable writable var _n_kwloop
: TKwloop
1125 readable writable var _n_block
: nullable AExpr = null
1132 readable writable var _n_kwfor
: TKwfor
1133 readable var _n_ids
: ANodes[TId] = new ANodes[TId](self)
1134 readable writable var _n_expr
: AExpr
1135 readable writable var _n_kwdo
: TKwdo
1136 readable writable var _n_block
: nullable AExpr = null
1139 # An `assert` statement
1142 readable writable var _n_kwassert
: TKwassert
1143 readable writable var _n_id
: nullable TId = null
1144 readable writable var _n_expr
: AExpr
1145 readable writable var _n_else
: nullable AExpr = null
1148 # Whatever is a simple assignment. eg `= something`
1149 abstract class AAssignFormExpr
1151 readable writable var _n_assign
: TAssign
1152 readable writable var _n_value
: AExpr
1155 # Whatever is a combined assignment. eg `+= something`
1156 abstract class AReassignFormExpr
1158 readable writable var _n_assign_op
: AAssignOp
1159 readable writable var _n_value
: AExpr
1162 # A `once` expression. eg `once x`
1165 readable writable var _n_kwonce
: TKwonce
1168 # A polymorphic invocation of a method
1169 # The form of the invocation (name, arguments, etc) are specific
1170 abstract class ASendExpr
1172 # The receiver of the method invocation
1173 readable writable var _n_expr
: AExpr
1176 # A binary operation on a method
1177 abstract class ABinopExpr
1179 # The second operand of the operation
1180 # Note: the receiver (`n_expr`) is the first operand
1181 readable writable var _n_expr2
: AExpr
1184 # Something that is boolean expression
1185 abstract class ABoolExpr
1192 readable writable var _n_expr
: AExpr
1193 readable writable var _n_expr2
: AExpr
1196 # A `and` expression
1199 readable writable var _n_expr
: AExpr
1200 readable writable var _n_expr2
: AExpr
1203 # A `or else` expression
1206 readable writable var _n_expr
: AExpr
1207 readable writable var _n_expr2
: AExpr
1210 # A `implies` expression
1213 readable writable var _n_expr
: AExpr
1214 readable writable var _n_expr2
: AExpr
1217 # A `not` expression
1220 readable writable var _n_kwnot
: TKwnot
1221 readable writable var _n_expr
: AExpr
1232 readable writable var _n_expr
: AExpr
1233 readable writable var _n_expr2
: AExpr
1271 # A type-ckeck expression. eg `x isa T`
1274 readable writable var _n_expr
: AExpr
1275 readable writable var _n_type
: AType
1288 # A `<=>` expression
1308 # A unary minus expression. eg `-x`
1311 readable writable var _n_minus
: TMinus
1314 # An explicit instantiation. eg `new T`
1317 readable writable var _n_kwnew
: TKwnew
1318 readable writable var _n_type
: AType
1320 # The name of the named-constructor, if any
1321 readable writable var _n_id
: nullable TId = null
1322 readable writable var _n_args
: AExprs
1325 # Whatever is a old-style attribute access
1326 abstract class AAttrFormExpr
1329 # The receiver of the attribute
1330 readable writable var _n_expr
: AExpr
1332 # The name of the attribute
1333 readable writable var _n_id
: TAttrid
1336 # The read of an attribute. eg `x._a`
1341 # The assignment of an attribute. eg `x._a=y`
1342 class AAttrAssignExpr
1344 super AAssignFormExpr
1347 # Whatever looks-like a call with a standard method and any number of arguments.
1348 abstract class ACallFormExpr
1351 # The name of the method
1352 readable writable var _n_id
: TId
1354 # The arguments of the call
1355 readable writable var _n_args
: AExprs
1358 # A complex setter call (standard or brackets)
1359 abstract class ASendReassignFormExpr
1361 super AReassignFormExpr
1364 # A complex attribute assignment. eg `x._a+=y`
1365 class AAttrReassignExpr
1367 super AReassignFormExpr
1370 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
1371 # 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`.
1372 # Semantic analysis have to transform them to instance of `AVarExpr`.
1377 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
1378 # 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`.
1379 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
1380 class ACallAssignExpr
1382 super AAssignFormExpr
1385 # 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.
1386 # 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`.
1387 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
1388 class ACallReassignExpr
1390 super ASendReassignFormExpr
1393 # A call to `super`. OR a call of a super-constructor
1396 readable writable var _n_qualified
: nullable AQualified = null
1397 readable writable var _n_kwsuper
: TKwsuper
1398 readable writable var _n_args
: AExprs
1401 # A call to the `init` constructor.
1402 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a ACallFormExpr.
1405 readable writable var _n_kwinit
: TKwinit
1406 readable writable var _n_args
: AExprs
1409 # Whatever looks-like a call of the brackets `[]` operator.
1410 abstract class ABraFormExpr
1412 readable writable var _n_args
: AExprs
1415 # A call of the brackets operator. eg `x[y,z]`
1420 # A setter call of the bracket operator. eg `x[y,z]=t`
1421 class ABraAssignExpr
1423 super AAssignFormExpr
1426 # Whatever is an access to a local variable
1427 abstract class AVarFormExpr
1429 readable writable var _n_id
: TId
1432 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
1433 class ABraReassignExpr
1435 super ASendReassignFormExpr
1438 # A local variable read access.
1439 # The parser cannot instantiate them, see `ACallExpr`.
1444 # A local variable simple assigment access
1445 # The parser cannot instantiate them, see `ACallAssignExpr`.
1446 class AVarAssignExpr
1448 super AAssignFormExpr
1451 # A local variable complex assignment access
1452 # The parser cannot instantiate them, see `ACallReassignExpr`.
1453 class AVarReassignExpr
1455 super AReassignFormExpr
1458 # A literal range, open or closed
1459 abstract class ARangeExpr
1461 readable writable var _n_expr
: AExpr
1462 readable writable var _n_expr2
: AExpr
1465 # A closed literal range. eg `[x..y]`
1468 readable writable var _n_obra
: TObra
1469 readable writable var _n_cbra
: TCbra
1472 # An open literal range. eg `[x..y[`
1475 readable writable var _n_obra
: TObra
1476 readable writable var _n_cbra
: TObra
1479 # A literal array. eg. `[x,y,z]`
1482 readable writable var _n_exprs
: AExprs
1488 readable writable var _n_kwself
: nullable TKwself
1491 # When there is no explicit receiver, `self` is implicit
1492 class AImplicitSelfExpr
1496 # A `true` boolean literal constant
1499 readable writable var _n_kwtrue
: TKwtrue
1501 # A `false` boolean literal constant
1504 readable writable var _n_kwfalse
: TKwfalse
1506 # A `null` literal constant
1509 readable writable var _n_kwnull
: TKwnull
1511 # An integer literal
1514 readable writable var _n_number
: TNumber
1519 readable writable var _n_float
: TFloat
1521 # A character literal
1524 readable writable var _n_char
: TChar
1527 abstract class AStringFormExpr
1529 readable writable var _n_string
: Token
1532 # A simple string. eg. `"abc"`
1534 super AStringFormExpr
1537 # The start of a superstring. eg `"abc{`
1538 class AStartStringExpr
1539 super AStringFormExpr
1542 # The middle of a superstring. eg `}abc{`
1543 class AMidStringExpr
1544 super AStringFormExpr
1547 # The end of a superstrng. eg `}abc"`
1548 class AEndStringExpr
1549 super AStringFormExpr
1552 # A superstring literal. eg `"a{x}b{y}c"`
1553 # Each part is modelized a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
1554 class ASuperstringExpr
1556 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1559 # A simple parenthesis. eg `(x)`
1562 readable writable var _n_opar
: TOpar
1563 readable writable var _n_cpar
: TCpar
1566 # Whatevej just contains (and mimic) an other expression
1567 abstract class AProxyExpr
1569 readable writable var _n_expr
: AExpr
1572 # A type cast. eg `x.as(T)`
1575 readable writable var _n_expr
: AExpr
1576 readable writable var _n_kwas
: TKwas
1577 readable writable var _n_opar
: TOpar
1578 readable writable var _n_type
: AType
1579 readable writable var _n_cpar
: TCpar
1582 # A as-not-null cast. eg `x.as(not null)`
1583 class AAsNotnullExpr
1585 readable writable var _n_expr
: AExpr
1586 readable writable var _n_kwas
: TKwas
1587 readable writable var _n_opar
: TOpar
1588 readable writable var _n_kwnot
: TKwnot
1589 readable writable var _n_kwnull
: TKwnull
1590 readable writable var _n_cpar
: TCpar
1593 # A is-set check of old-style attributes. eg `isset x._a`
1594 class AIssetAttrExpr
1596 readable writable var _n_kwisset
: TKwisset
1599 # A list of expression separated with commas (arguments for instance)
1600 abstract class AExprs
1602 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1605 class ADebugTypeExpr
1607 readable writable var _n_kwdebug
: TKwdebug
1608 readable writable var _n_kwtype
: TKwtype
1609 readable writable var _n_expr
: AExpr
1610 readable writable var _n_type
: AType
1613 # A simple list of expressions
1618 # A list of expressions enclosed in parentheses
1621 readable writable var _n_opar
: TOpar
1622 readable writable var _n_cpar
: TCpar
1625 # A list of expressions enclosed in brackets
1628 readable writable var _n_obra
: TObra
1629 readable writable var _n_cbra
: TCbra
1632 # A complex assignment operator. eg `+=`
1633 abstract class AAssignOp
1638 readable writable var _n_pluseq
: TPluseq
1640 class AMinusAssignOp
1642 readable writable var _n_minuseq
: TMinuseq
1647 readable writable var _n_quad
: nullable TQuad = null
1648 readable var _n_path
: ANodes[TId] = new ANodes[TId](self)
1649 readable writable var _n_id
: TId
1653 readable writable var _n_kwin
: TKwin
1654 readable writable var _n_string
: TString
1656 class AExternCodeBlock
1658 readable writable var _n_in_language
: nullable AInLanguage = null
1659 readable writable var _n_extern_code_segment
: TExternCodeSegment
1663 readable writable var _n_quad
: nullable TQuad = null
1664 readable var _n_id
: ANodes[TId] = new ANodes[TId](self)
1665 readable writable var _n_classid
: nullable TClassid = null
1668 # A documentation of a definition
1669 # It contains the block of comments just above the declaration
1672 readable var _n_comment
: ANodes[TComment] = new ANodes[TComment](self)
1677 readable writable var _n_at
: nullable TAt = null
1678 readable writable var _n_opar
: nullable TOpar = null
1679 readable var _n_items
: ANodes[AAnnotation] = new ANodes[AAnnotation](self)
1680 readable writable var _n_cpar
: nullable TCpar = null
1684 readable writable var _n_atid
: AAtid
1685 readable writable var _n_opar
: nullable TOpar = null
1686 readable var _n_args
: ANodes[AAtArg] = new ANodes[AAtArg](self)
1687 readable writable var _n_cpar
: nullable TCpar = null
1689 abstract class AAtArg
1694 readable writable var _n_type
: AType
1698 readable writable var _n_expr
: AExpr
1703 abstract class AAtid
1705 readable writable var _n_id
: Token
1716 class AKwreadableAtid
1719 class AKwwritableAtid
1726 # The root of the AST
1729 readable writable var _n_base
: nullable AModule
1730 readable writable var _n_eof
: EOF
1731 init(n_base
: nullable AModule, n_eof
: EOF)
1733 self._n_base
= n_base