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}'"
401 # A token associated with an operator (and other lookalike symbols)
402 abstract class TokenOperator
406 return "operator '{text}'"
473 # A class (or formal type) identifier. They start with an uppercase.
478 do return "type identifier '{text}'"
482 # A standard identifier (variable, method...). They start with a lowercase.
487 do return "identifier '{text}'"
491 # An attribute identifier. They start with an underscore.
496 do return "attribute '{text}'"
500 # A token of a literal value (string, integer, etc).
501 abstract class TokenLiteral
505 do return "literal value '{text}'"
535 do return "malformed string {text}"
544 do return "malformed character {text}"
548 class TExternCodeSegment
572 # The main node of a Nit source-file
576 readable writable var _n_moduledecl
: nullable AModuledecl = null
577 readable var _n_imports
: ANodes[AImport] = new ANodes[AImport](self)
578 readable var _n_extern_code_blocks
: ANodes[AExternCodeBlock] = new ANodes[AExternCodeBlock](self)
579 readable var _n_classdefs
: ANodes[AClassdef] = new ANodes[AClassdef](self)
582 # The declaration of the module with the documentation, name, and annotations
585 readable writable var _n_doc
: nullable ADoc = null
586 readable writable var _n_kwmodule
: TKwmodule
587 readable writable var _n_name
: AModuleName
590 # A import clause of a module
591 abstract class AImport
595 # A standard import clause. eg `import x`
598 readable writable var _n_visibility
: AVisibility
599 readable writable var _n_kwimport
: TKwimport
600 readable writable var _n_name
: AModuleName
603 # The special import clause of the kernel module. eg `import end`
606 readable writable var _n_visibility
: AVisibility
607 readable writable var _n_kwimport
: TKwimport
608 readable writable var _n_kwend
: TKwend
611 # A visibility modifier
613 # The public visibility is an empty production (no keyword).
615 # Note: even if some visibilities are only valid on some placse (for instance, no `protected` class or no `intrude` method)
616 # the parser has no such a restriction, therefore the semantic phases has to check that the visibilities make sense.
617 abstract class AVisibility
620 class APublicVisibility
623 class APrivateVisibility
625 readable writable var _n_kwprivate
: TKwprivate
627 class AProtectedVisibility
629 readable writable var _n_kwprotected
: TKwprotected
631 class AIntrudeVisibility
633 readable writable var _n_kwintrude
: TKwintrude
637 # While most definition are `AStdClassdef`
638 # There is tow special case of class definition
639 abstract class AClassdef super Prod
640 readable var _n_propdefs
: ANodes[APropdef] = new ANodes[APropdef](self)
643 # A standard class definition with a name, superclasses and properties
646 readable writable var _n_doc
: nullable ADoc = null
647 readable writable var _n_kwredef
: nullable TKwredef = null
648 readable writable var _n_visibility
: AVisibility
649 readable writable var _n_classkind
: AClasskind
650 readable writable var _n_id
: nullable TClassid = null
651 readable var _n_formaldefs
: ANodes[AFormaldef] = new ANodes[AFormaldef](self)
652 readable writable var _n_extern_code_block
: nullable AExternCodeBlock = null
653 readable var _n_superclasses
: ANodes[ASuperclass] = new ANodes[ASuperclass](self)
654 readable writable var _n_kwend
: TKwend
655 redef fun hot_location
do return n_id
.location
658 # The implicit class definition of the implicit main method
663 # The implicit class definition of the top-level methods
668 # The modifier for the kind of class (abstract, interface, etc.)
669 abstract class AClasskind
672 class AConcreteClasskind
674 readable writable var _n_kwclass
: TKwclass
676 class AAbstractClasskind
678 readable writable var _n_kwabstract
: TKwabstract
679 readable writable var _n_kwclass
: TKwclass
681 class AInterfaceClasskind
683 readable writable var _n_kwinterface
: TKwinterface
687 readable writable var _n_kwenum
: TKwenum
689 class AExternClasskind
691 readable writable var _n_kwextern
: TKwextern
692 readable writable var _n_kwclass
: nullable TKwclass = null
695 # The definition of a formal generic parameter type. eg `X: Y`
698 readable writable var _n_id
: TClassid
699 # The bound of the parameter type
700 readable writable var _n_type
: nullable AType = null
703 # A super-class. eg `super X`
706 readable writable var _n_kwsuper
: TKwsuper
707 readable writable var _n_type
: AType
710 # The definition of a property
711 abstract class APropdef
713 readable writable var _n_doc
: nullable ADoc = null
716 # A definition of an attribute
717 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
720 readable writable var _n_kwredef
: nullable TKwredef = null
721 readable writable var _n_visibility
: AVisibility
722 readable writable var _n_kwvar
: TKwvar
724 # The identifier for an old-style attribute (null if new-style)
725 readable writable var _n_id
: nullable TAttrid
727 # The identifier for a new-style attribute (null if old-style)
728 readable writable var _n_id2
: nullable TId
730 readable writable var _n_type
: nullable AType = null
731 readable writable var _n_readable
: nullable AAble = null
732 readable writable var _n_writable
: nullable AAble = null
734 # The initial value, if any
735 readable writable var _n_expr
: nullable AExpr = null
736 redef fun hot_location
738 if n_id
!= null then return n_id
.location
else return n_id2
.location
742 # A definition of all kind of method (including constructors)
743 abstract class AMethPropdef
745 readable writable var _n_kwredef
: nullable TKwredef = null
746 readable writable var _n_visibility
: nullable AVisibility
747 readable writable var _n_methid
: nullable AMethid = null
748 readable writable var _n_signature
: nullable ASignature
749 redef fun hot_location
751 if n_methid
!= null then
752 return n_methid
.location
759 # A method marked abstract
760 # *deferred* is a old synonynmous of *abstract* that comes from PRM, that comes from Eiffel.
761 class ADeferredMethPropdef
763 readable writable var _n_kwmeth
: TKwmeth
766 # A method marked intern
767 class AInternMethPropdef
769 readable writable var _n_kwmeth
: TKwmeth
772 # A method of a constructor marked extern
773 abstract class AExternPropdef
775 readable writable var _n_extern
: nullable TString = null
776 readable writable var _n_extern_calls
: nullable AExternCalls = null
777 readable writable var _n_extern_code_block
: nullable AExternCodeBlock = null
780 # A method marked extern
781 class AExternMethPropdef
783 readable writable var _n_kwmeth
: TKwmeth
786 # A method with a body
787 class AConcreteMethPropdef
789 readable writable var _n_kwmeth
: nullable TKwmeth
790 readable writable var _n_block
: nullable AExpr = null
794 abstract class AInitPropdef
798 # A constructor with a body
799 class AConcreteInitPropdef
800 super AConcreteMethPropdef
802 readable writable var _n_kwinit
: TKwinit
803 redef fun hot_location
do return n_kwinit
.location
806 # A constructor marked extern (defined with the `new` keyword)
807 class AExternInitPropdef
810 readable writable var _n_kwnew
: TKwnew
813 # The implicit main method
814 class AMainMethPropdef
815 super AConcreteMethPropdef
818 # Declaration of callbacks for extern methods
821 readable writable var _n_kwimport
: TKwimport
822 readable var _n_extern_calls
: ANodes[AExternCall] = new ANodes[AExternCall](self)
824 abstract class AExternCall
827 abstract class APropExternCall
830 class ALocalPropExternCall
831 super APropExternCall
832 readable writable var _n_methid
: AMethid
834 class AFullPropExternCall
835 super APropExternCall
836 readable writable var _n_classid
: TClassid
837 readable writable var _n_quad
: nullable TQuad = null
838 readable writable var _n_methid
: AMethid
840 class AInitPropExternCall
841 super APropExternCall
842 readable writable var _n_classid
: TClassid
844 class ASuperExternCall
846 readable writable var _n_kwsuper
: TKwsuper
848 abstract class ACastExternCall
851 class ACastAsExternCall
852 super ACastExternCall
853 readable writable var _n_from_type
: AType
854 readable writable var _n_kwas
: TKwas
855 readable writable var _n_to_type
: AType
857 class AAsNullableExternCall
858 super ACastExternCall
859 readable writable var _n_type
: AType
860 readable writable var _n_kwas
: TKwas
861 readable writable var _n_kwnullable
: TKwnullable
863 class AAsNotNullableExternCall
864 super ACastExternCall
865 readable writable var _n_type
: AType
866 readable writable var _n_kwas
: TKwas
867 readable writable var _n_kwnot
: TKwnot
868 readable writable var _n_kwnullable
: TKwnullable
871 # A definition of a virtual type
874 readable writable var _n_kwredef
: nullable TKwredef = null
875 readable writable var _n_visibility
: AVisibility
876 readable writable var _n_kwtype
: TKwtype
877 readable writable var _n_id
: TClassid
878 readable writable var _n_type
: AType
881 # A `writable` or `readable` modifier
884 readable writable var _n_visibility
: nullable AVisibility = null
885 readable writable var _n_kwredef
: nullable TKwredef = null
888 # A `readable` modifier
891 readable writable var _n_kwreadable
: TKwreadable
894 # A `writable` modifier
897 readable writable var _n_kwwritable
: TKwwritable
900 # The identifier of a method in a method declaration.
901 # There is a specific class because of operator and setters.
902 abstract class AMethid
907 readable writable var _n_id
: TId
911 readable writable var _n_plus
: TPlus
915 readable writable var _n_minus
: TMinus
919 readable writable var _n_star
: TStar
923 readable writable var _n_slash
: TSlash
927 readable writable var _n_percent
: TPercent
931 readable writable var _n_eq
: TEq
935 readable writable var _n_ne
: TNe
939 readable writable var _n_le
: TLe
943 readable writable var _n_ge
: TGe
947 readable writable var _n_lt
: TLt
951 readable writable var _n_gt
: TGt
955 readable writable var _n_ll
: TLl
959 readable writable var _n_gg
: TGg
963 readable writable var _n_obra
: TObra
964 readable writable var _n_cbra
: TCbra
966 class AStarshipMethid
968 readable writable var _n_starship
: TStarship
972 readable writable var _n_id
: TId
973 readable writable var _n_assign
: TAssign
975 class ABraassignMethid
977 readable writable var _n_obra
: TObra
978 readable writable var _n_cbra
: TCbra
979 readable writable var _n_assign
: TAssign
982 # A signature in a method definition. eg `(x,y:X,z:Z):T`
985 readable writable var _n_opar
: nullable TOpar = null
986 readable var _n_params
: ANodes[AParam] = new ANodes[AParam](self)
987 readable writable var _n_cpar
: nullable TCpar = null
988 readable writable var _n_type
: nullable AType = null
989 readable var _n_closure_decls
: ANodes[AClosureDecl] = new ANodes[AClosureDecl](self)
992 # A parameter definition in a signature. eg `x:X`
995 readable writable var _n_id
: TId
996 readable writable var _n_type
: nullable AType = null
997 readable writable var _n_dotdotdot
: nullable TDotdotdot = null
1002 readable writable var _n_kwbreak
: nullable TKwbreak = null
1003 readable writable var _n_bang
: TBang
1004 readable writable var _n_id
: TId
1005 readable writable var _n_signature
: ASignature
1006 readable writable var _n_expr
: nullable AExpr = null
1009 # A static type. eg `nullable X[Y]`
1012 readable writable var _n_kwnullable
: nullable TKwnullable = null
1014 # The name of the class or of the formal type
1015 readable writable var _n_id
: TClassid
1017 # Type arguments for a generic type
1018 readable var _n_types
: ANodes[AType] = new ANodes[AType](self)
1021 # A label at the end of a block or in a break/continue statement. eg `label x`
1024 readable writable var _n_kwlabel
: TKwlabel
1025 readable writable var _n_id
: TId
1028 # Expression and statements
1029 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1030 abstract class AExpr
1034 # A sequence of AExpr (usually statements)
1035 # The last AExpr gives the value of the whole block
1038 readable var _n_expr
: ANodes[AExpr] = new ANodes[AExpr](self)
1039 readable writable var _n_kwend
: nullable TKwend = null
1042 # A declaration of a local variable. eg `var x: X = y`
1045 readable writable var _n_kwvar
: TKwvar
1046 readable writable var _n_id
: TId
1047 readable writable var _n_type
: nullable AType = null
1048 readable writable var _n_assign
: nullable TAssign = null
1050 # The initial value, if any
1051 readable writable var _n_expr
: nullable AExpr = null
1054 # A `return` statement. eg `return x`
1057 readable writable var _n_kwreturn
: nullable TKwreturn = null
1058 readable writable var _n_expr
: nullable AExpr = null
1061 # Something that has a label.
1062 abstract class ALabelable
1064 readable writable var _n_label
: nullable ALabel = null
1067 # A `break` statement.
1071 readable writable var _n_kwbreak
: TKwbreak
1072 readable writable var _n_expr
: nullable AExpr = null
1075 # An `abort` statement
1078 readable writable var _n_kwabort
: TKwabort
1081 # A `continue` statement
1085 readable writable var _n_kwcontinue
: nullable TKwcontinue = null
1086 readable writable var _n_expr
: nullable AExpr = null
1093 readable writable var _n_kwdo
: TKwdo
1094 readable writable var _n_block
: nullable AExpr = null
1100 readable writable var _n_kwif
: TKwif
1101 readable writable var _n_expr
: AExpr
1102 readable writable var _n_then
: nullable AExpr = null
1103 readable writable var _n_else
: nullable AExpr = null
1109 readable writable var _n_kwif
: TKwif
1110 readable writable var _n_expr
: AExpr
1111 readable writable var _n_kwthen
: TKwthen
1112 readable writable var _n_then
: AExpr
1113 readable writable var _n_kwelse
: TKwelse
1114 readable writable var _n_else
: AExpr
1117 # A `while` statement
1121 readable writable var _n_kwwhile
: TKwwhile
1122 readable writable var _n_expr
: AExpr
1123 readable writable var _n_kwdo
: TKwdo
1124 readable writable var _n_block
: nullable AExpr = null
1127 # A `loop` statement
1131 readable writable var _n_kwloop
: TKwloop
1132 readable writable var _n_block
: nullable AExpr = null
1139 readable writable var _n_kwfor
: TKwfor
1140 readable var _n_ids
: ANodes[TId] = new ANodes[TId](self)
1141 readable writable var _n_expr
: AExpr
1142 readable writable var _n_kwdo
: TKwdo
1143 readable writable var _n_block
: nullable AExpr = null
1146 # An `assert` statement
1149 readable writable var _n_kwassert
: TKwassert
1150 readable writable var _n_id
: nullable TId = null
1151 readable writable var _n_expr
: AExpr
1152 readable writable var _n_else
: nullable AExpr = null
1155 # Whatever is a simple assignment. eg `= something`
1156 abstract class AAssignFormExpr
1158 readable writable var _n_assign
: TAssign
1159 readable writable var _n_value
: AExpr
1162 # Whatever is a combined assignment. eg `+= something`
1163 abstract class AReassignFormExpr
1165 readable writable var _n_assign_op
: AAssignOp
1166 readable writable var _n_value
: AExpr
1169 # A `once` expression. eg `once x`
1172 readable writable var _n_kwonce
: TKwonce
1175 # A polymorphic invocation of a method
1176 # The form of the invocation (name, arguments, etc) are specific
1177 abstract class ASendExpr
1179 # The receiver of the method invocation
1180 readable writable var _n_expr
: AExpr
1181 readable var _n_closure_defs
: ANodes[AClosureDef] = new ANodes[AClosureDef](self)
1184 # A binary operation on a method
1185 abstract class ABinopExpr
1187 # The second operand of the operation
1188 # Note: the receiver (`n_expr`) is the first operand
1189 readable writable var _n_expr2
: AExpr
1192 # Something that is boolean expression
1193 abstract class ABoolExpr
1200 readable writable var _n_expr
: AExpr
1201 readable writable var _n_expr2
: AExpr
1204 # A `and` expression
1207 readable writable var _n_expr
: AExpr
1208 readable writable var _n_expr2
: AExpr
1211 # A `or else` expression
1214 readable writable var _n_expr
: AExpr
1215 readable writable var _n_expr2
: AExpr
1218 # A `implies` expression
1221 readable writable var _n_expr
: AExpr
1222 readable writable var _n_expr2
: AExpr
1225 # A `not` expression
1228 readable writable var _n_kwnot
: TKwnot
1229 readable writable var _n_expr
: AExpr
1240 readable writable var _n_expr
: AExpr
1241 readable writable var _n_expr2
: AExpr
1279 # A type-ckeck expression. eg `x isa T`
1282 readable writable var _n_expr
: AExpr
1283 readable writable var _n_type
: AType
1296 # A `<=>` expression
1316 # A unary minus expression. eg `-x`
1319 readable writable var _n_minus
: TMinus
1322 # An explicit instantiation. eg `new T`
1325 readable writable var _n_kwnew
: TKwnew
1326 readable writable var _n_type
: AType
1328 # The name of the named-constructor, if any
1329 readable writable var _n_id
: nullable TId = null
1330 readable writable var _n_args
: AExprs
1333 # Whatever is a old-style attribute access
1334 abstract class AAttrFormExpr
1337 # The receiver of the attribute
1338 readable writable var _n_expr
: AExpr
1340 # The name of the attribute
1341 readable writable var _n_id
: TAttrid
1344 # The read of an attribute. eg `x._a`
1349 # The assignment of an attribute. eg `x._a=y`
1350 class AAttrAssignExpr
1352 super AAssignFormExpr
1355 # Whatever looks-like a call with a standard method and any number of arguments.
1356 abstract class ACallFormExpr
1359 # The name of the method
1360 readable writable var _n_id
: TId
1362 # The arguments of the call
1363 readable writable var _n_args
: AExprs
1366 # A complex setter call (standard or brackets)
1367 abstract class ASendReassignFormExpr
1369 super AReassignFormExpr
1372 # A complex attribute assignment. eg `x._a+=y`
1373 class AAttrReassignExpr
1375 super AReassignFormExpr
1378 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
1379 # 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`.
1380 # Semantic analysis have to transform them to instance of `AVarExpr`.
1385 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
1386 # 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`.
1387 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
1388 class ACallAssignExpr
1390 super AAssignFormExpr
1393 # 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.
1394 # 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`.
1395 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
1396 class ACallReassignExpr
1398 super ASendReassignFormExpr
1401 # A call to `super`. OR a call of a super-constructor
1404 readable writable var _n_qualified
: nullable AQualified = null
1405 readable writable var _n_kwsuper
: TKwsuper
1406 readable writable var _n_args
: AExprs
1409 # A call to the `init` constructor.
1410 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a ACallFormExpr.
1413 readable writable var _n_kwinit
: TKwinit
1414 readable writable var _n_args
: AExprs
1417 # Whatever looks-like a call of the brackets `[]` operator.
1418 abstract class ABraFormExpr
1420 readable writable var _n_args
: AExprs
1423 # A call of the brackets operator. eg `x[y,z]`
1428 # A setter call of the bracket operator. eg `x[y,z]=t`
1429 class ABraAssignExpr
1431 super AAssignFormExpr
1434 # Whatever is an access to a local variable
1435 abstract class AVarFormExpr
1437 readable writable var _n_id
: TId
1440 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
1441 class ABraReassignExpr
1443 super ASendReassignFormExpr
1446 class AClosureCallExpr
1448 readable writable var _n_id
: TId
1449 readable writable var _n_args
: AExprs
1450 readable var _n_closure_defs
: ANodes[AClosureDef] = new ANodes[AClosureDef](self)
1453 # A local variable read access.
1454 # The parser cannot instantiate them, see `ACallExpr`.
1459 # A local variable simple assigment access
1460 # The parser cannot instantiate them, see `ACallAssignExpr`.
1461 class AVarAssignExpr
1463 super AAssignFormExpr
1466 # A local variable complex assignment access
1467 # The parser cannot instantiate them, see `ACallReassignExpr`.
1468 class AVarReassignExpr
1470 super AReassignFormExpr
1473 # A literal range, open or closed
1474 abstract class ARangeExpr
1476 readable writable var _n_expr
: AExpr
1477 readable writable var _n_expr2
: AExpr
1480 # A closed literal range. eg `[x..y]`
1483 readable writable var _n_obra
: TObra
1484 readable writable var _n_cbra
: TCbra
1487 # An open literal range. eg `[x..y[`
1490 readable writable var _n_obra
: TObra
1491 readable writable var _n_cbra
: TObra
1494 # A literal array. eg. `[x,y,z]`
1497 readable writable var _n_exprs
: AExprs
1503 readable writable var _n_kwself
: nullable TKwself
1506 # When there is no explicit receiver, `self` is implicit
1507 class AImplicitSelfExpr
1511 # A `true` boolean literal constant
1514 readable writable var _n_kwtrue
: TKwtrue
1516 # A `false` boolean literal constant
1519 readable writable var _n_kwfalse
: TKwfalse
1521 # A `null` literal constant
1524 readable writable var _n_kwnull
: TKwnull
1526 # An integer literal
1529 readable writable var _n_number
: TNumber
1534 readable writable var _n_float
: TFloat
1536 # A character literal
1539 readable writable var _n_char
: TChar
1542 abstract class AStringFormExpr
1544 readable writable var _n_string
: Token
1547 # A simple string. eg. `"abc"`
1549 super AStringFormExpr
1552 # The start of a superstring. eg `"abc{`
1553 class AStartStringExpr
1554 super AStringFormExpr
1557 # The middle of a superstring. eg `}abc{`
1558 class AMidStringExpr
1559 super AStringFormExpr
1562 # The end of a superstrng. eg `}abc"`
1563 class AEndStringExpr
1564 super AStringFormExpr
1567 # A superstring literal. eg `"a{x}b{y}c"`
1568 # Each part is modelized a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
1569 class ASuperstringExpr
1571 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1574 # A simple parenthesis. eg `(x)`
1577 readable writable var _n_opar
: TOpar
1578 readable writable var _n_cpar
: TCpar
1581 # Whatevej just contains (and mimic) an other expression
1582 abstract class AProxyExpr
1584 readable writable var _n_expr
: AExpr
1587 # A type cast. eg `x.as(T)`
1590 readable writable var _n_expr
: AExpr
1591 readable writable var _n_kwas
: TKwas
1592 readable writable var _n_opar
: TOpar
1593 readable writable var _n_type
: AType
1594 readable writable var _n_cpar
: TCpar
1597 # A as-not-null cast. eg `x.as(not null)`
1598 class AAsNotnullExpr
1600 readable writable var _n_expr
: AExpr
1601 readable writable var _n_kwas
: TKwas
1602 readable writable var _n_opar
: TOpar
1603 readable writable var _n_kwnot
: TKwnot
1604 readable writable var _n_kwnull
: TKwnull
1605 readable writable var _n_cpar
: TCpar
1608 # A is-set check of old-style attributes. eg `isset x._a`
1609 class AIssetAttrExpr
1611 readable writable var _n_kwisset
: TKwisset
1614 # A list of expression separated with commas (arguments for instance)
1615 abstract class AExprs
1617 readable var _n_exprs
: ANodes[AExpr] = new ANodes[AExpr](self)
1620 class ADebugTypeExpr
1622 readable writable var _n_kwdebug
: TKwdebug
1623 readable writable var _n_kwtype
: TKwtype
1624 readable writable var _n_expr
: AExpr
1625 readable writable var _n_type
: AType
1628 # A simple list of expressions
1633 # A list of expressions enclosed in parentheses
1636 readable writable var _n_opar
: TOpar
1637 readable writable var _n_cpar
: TCpar
1640 # A list of expressions enclosed in brackets
1643 readable writable var _n_obra
: TObra
1644 readable writable var _n_cbra
: TCbra
1647 # A complex assignment operator. eg `+=`
1648 abstract class AAssignOp
1653 readable writable var _n_pluseq
: TPluseq
1655 class AMinusAssignOp
1657 readable writable var _n_minuseq
: TMinuseq
1662 readable writable var _n_bang
: TBang
1663 readable writable var _n_id
: AClosureId
1664 readable var _n_ids
: ANodes[TId] = new ANodes[TId](self)
1665 readable writable var _n_kwdo
: nullable TKwdo = null
1666 readable writable var _n_expr
: nullable AExpr = null
1667 redef fun hot_location
do return n_id
.location
1669 abstract class AClosureId
1672 class ASimpleClosureId
1674 readable writable var _n_id
: TId
1676 class ABreakClosureId
1678 readable writable var _n_kwbreak
: TKwbreak
1682 readable writable var _n_quad
: nullable TQuad = null
1683 readable var _n_path
: ANodes[TId] = new ANodes[TId](self)
1684 readable writable var _n_id
: TId
1688 readable writable var _n_kwin
: TKwin
1689 readable writable var _n_string
: TString
1691 class AExternCodeBlock
1693 readable writable var _n_in_language
: nullable AInLanguage = null
1694 readable writable var _n_extern_code_segment
: TExternCodeSegment
1698 readable writable var _n_quad
: nullable TQuad = null
1699 readable var _n_id
: ANodes[TId] = new ANodes[TId](self)
1700 readable writable var _n_classid
: nullable TClassid = null
1703 # A documentation of a definition
1704 # It contains the block of comments just above the declaration
1707 readable var _n_comment
: ANodes[TComment] = new ANodes[TComment](self)
1712 readable writable var _n_at
: nullable TAt = null
1713 readable writable var _n_opar
: nullable TOpar = null
1714 readable var _n_items
: ANodes[AAnnotation] = new ANodes[AAnnotation](self)
1715 readable writable var _n_cpar
: nullable TCpar = null
1719 readable writable var _n_atid
: AAtid
1720 readable writable var _n_opar
: nullable TOpar = null
1721 readable var _n_args
: ANodes[AAtArg] = new ANodes[AAtArg](self)
1722 readable writable var _n_cpar
: nullable TCpar = null
1724 abstract class AAtArg
1729 readable writable var _n_type
: AType
1733 readable writable var _n_expr
: AExpr
1738 abstract class AAtid
1740 readable writable var _n_id
: Token
1751 class AKwreadableAtid
1754 class AKwwritableAtid
1761 # The root of the AST
1764 readable writable var _n_base
: nullable AModule
1765 readable writable var _n_eof
: EOF
1766 init(n_base
: nullable AModule, n_eof
: EOF)
1768 self._n_base
= n_base