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 private import console
23 # Root of the AST class-hierarchy
25 # Location is set during AST building. Once built, location can not be null.
26 # However, manual instantiated nodes may need more care.
27 var location
: Location is writable, noinit
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 sys
.stderr
.write
"{hot_location} {self.class_name}: {message}\n{hot_location.colored_line("0;32")}\n"
38 # Is `self` a token or a pure-structural production like `AQId`?
39 fun is_structural
: Bool do return false
41 # Write the subtree on stdout.
43 # Visit the subtree and display it with additional and useful information.
45 # By default, this displays all kind of nodes and the corresponding lines of codes.
47 # See `ASTDump` for details.
48 fun dump_tree
(display_structural
, display_line
: nullable Bool)
50 var d
= new ASTDump(display_structural
or else true, display_line
or else true)
52 d
.write_to
(sys
.stdout
)
55 # Information to display on a node
57 # Refine this method to add additional information on each node type.
58 fun dump_info
(v
: ASTDump): String do return ""
60 # Parent of the node in the AST
61 var parent
: nullable ANode = null
63 # The topmost ancestor of the element
64 # This just apply `parent` until the first one
70 if p
== null then return res
75 # The most specific common parent between `self` and `other`
76 # Return null if the two node are unrelated (distinct root)
77 fun common_parent
(other
: ANode): nullable ANode
79 # First, get the same depth
80 var s
: nullable ANode = self
81 var o
: nullable ANode = other
82 var d
= s
.depth
- o
.depth
91 assert o
.depth
== s
.depth
92 # Second, go up until same in found
100 # Number of nodes between `self` and the `root` of the AST
101 # ENSURE `self == self.root implies result == 0 `
102 # ENSURE `self != self.root implies result == self.parent.depth + 1`
109 if p
== null then return res
115 # Replace a child with an other node in the AST
116 private fun replace_child
(old_child
: ANode, new_child
: nullable ANode) is abstract
118 # Detach a node from its parent
119 # Aborts if the node is not detachable. use `replace_with` instead
120 # REQUIRE: parent != null
121 # REQUIRE: is_detachable
122 # ENDURE: parent == null
125 assert parent
!= null
126 parent
.replace_child
(self, null)
130 # Replace itself with an other node in the AST
131 # REQUIRE: parent != null
132 # ENSURE: node.parent == old(parent)
133 # ENSURE: parent == null
134 fun replace_with
(node
: ANode)
136 assert parent
!= null
137 parent
.replace_child
(self, node
)
141 # Visit all nodes in order.
142 # Thus, call `v.enter_visit(e)` for each child `e`
143 fun visit_all
(v
: Visitor) is abstract
145 # Do a deep search and return an array of tokens that match a given text
146 fun collect_tokens_by_text
(text
: String): Array[Token]
148 var v
= new CollectTokensByTextVisitor(text
)
153 # Do a deep search and return an array of node that are annotated
154 # The attached node can be retrieved by two invocations of parent
155 fun collect_annotations_by_name
(name
: String): Array[AAnnotation]
157 var v
= new CollectAnnotationsByNameVisitor(name
)
163 private class CollectTokensByTextVisitor
166 var result
= new Array[Token]
167 redef fun visit
(node
)
170 if node
isa Token and node
.text
== text
then result
.add
(node
)
174 private class CollectAnnotationsByNameVisitor
177 var result
= new Array[AAnnotation]
178 redef fun visit
(node
)
181 if node
isa AAnnotation and node
.n_atid
.n_id
.text
== name
then result
.add
(node
)
185 # A helper class to handle (print) Nit AST as an OrderedTree
188 super OrderedTree[ANode]
190 # Reference to the last parent in the Ordered Tree
191 # Is used to handle the initial node parent and workaround possible inconsistent `ANode::parent`
192 private var last_parent
: nullable ANode = null
194 # Display tokens and structural production?
196 # Should tokens (and structural production like AQId) be displayed?
197 var display_structural
: Bool
201 # Should each new line be displayed (numbered and in gray)?
202 var display_line
: Bool
204 # Current line number (when printing lines)
209 if not display_structural
and n
.is_structural
then return
217 redef fun write_line
(o
, n
, p
)
220 var ls
= n
.location
.line_start
221 var file
= n
.location
.file
223 if ls
> line
and file
!= null then
224 if line
== 0 then line
= ls
- 1
227 o
.write
"{line}\t{file.get_line(line)}\n".light_gray
238 return "{n.class_name} {n.dump_info(self)} @{n.location}"
242 fun yellow
(s
: String): String do return s
.yellow
245 fun red
(s
: String): String do return s
.red
248 # A sequence of nodes
249 # It is a specific class (instead of using a Array) to track the parent/child relation when nodes are added or removed
250 class ANodes[E
: ANode]
252 private var parent
: ANode
253 private var items
= new Array[E
]
254 redef fun iterator
do return items
.iterator
255 redef fun reverse_iterator
do return items
.reverse_iterator
256 redef fun length
do return items
.length
257 redef fun is_empty
do return items
.is_empty
276 var res
= items
.shift
288 redef fun []=(index
, e
)
290 hook_remove
(self[index
])
294 redef fun remove_at
(index
)
296 hook_remove
(items
[index
])
297 items
.remove_at
(index
)
299 private fun hook_add
(e
: E
)
301 #assert e.parent == null
304 private fun hook_remove
(e
: E
)
306 assert e
.parent
== parent
310 # Used in parent constructor to fill elements
311 private fun unsafe_add_all
(nodes
: Collection[Object])
313 var parent
= self.parent
321 private fun replace_child
(old_child
: ANode, new_child
: nullable ANode): Bool
323 var parent
= self.parent
324 for i
in [0..length
[ do
325 if self[i
] == old_child
then
326 if new_child
!= null then
327 assert new_child
isa E
329 new_child
.parent
= parent
339 private fun visit_all
(v
: Visitor)
341 for n
in self do v
.enter_visit
(n
)
345 # Ancestor of all tokens
346 # A token is a node that has a `text` but no children.
350 # The raw content on the token
351 fun text
: String is abstract
353 # The raw content on the token
354 fun text
=(text
: String) is abstract
356 # The previous token in the Lexer.
357 # May have disappeared in the AST
358 var prev_token
: nullable Token = null
360 # The next token in the Lexer.
361 # May have disappeared in the AST
362 var next_token
: nullable Token = null
364 # Is `self` a token discarded from the AST?
366 # Loose tokens are not present in the AST.
367 # It means they were identified by the lexer but were discarded by the parser.
368 # It also means that they are not visited or manipulated by AST-related functions.
370 # Each loose token is attached to the non-loose token that precedes or follows it.
371 # The rules are the following:
373 # * tokens that follow a non-loose token on a same line are attached to it.
375 # * other tokens, thus that precede a non-loose token on the same line or the next one,
376 # are attached to this one. See `prev_looses`.
378 # Loose tokens are mostly end of lines (`TEol`) and comments (`TComment`).
379 # Whitespace are ignored by the lexer, so they are not even considered as loose tokens.
380 # See `blank_before` to get the whitespace that separate tokens.
383 redef fun is_structural
do return true
385 redef fun dump_info
(v
) do return " {text.escape_to_c}"
387 # Loose tokens that precede `self`.
389 # These tokens start the line or belong to a line with only loose tokens.
390 var prev_looses
= new Array[Token] is lazy
392 # Loose tokens that follow `self`
394 # These tokens are on the same line than `self`.
395 var next_looses
= new Array[Token] is lazy
397 # The verbatim blank text between `prev_token` and `self`
398 fun blank_before
: String
400 if prev_token
== null then return ""
401 var from
= prev_token
.location
.pend
+1
402 var to
= location
.pstart
403 return location
.file
.string
.substring
(from
,to-from
)
406 redef fun to_s
: String do
410 redef fun visit_all
(v
: Visitor) do end
411 redef fun replace_child
(old_child
: ANode, new_child
: nullable ANode) do end
414 redef class SourceFile
415 # The first token parser by the lexer
416 # May have disappeared in the final AST
417 var first_token
: nullable Token = null
419 # The first token parser by the lexer
420 # May have disappeared in the final AST
421 var last_token
: nullable Token = null
424 # Ancestor of all productions
425 # A production is a node without text but that usually has children.
429 # All the annotations attached directly to the node
430 var n_annotations
: nullable AAnnotations = null is writable
432 # Return all its annotations of a given name in the order of their declaration
433 # Retun an empty array if no such an annotation.
434 fun get_annotations
(name
: String): Array[AAnnotation]
436 var res
= new Array[AAnnotation]
437 var nas
= n_annotations
438 if nas
!= null then for na
in nas
.n_items
do
439 if na
.name
!= name
then continue
442 if self isa AClassdef then for na
in n_propdefs
do
443 if na
isa AAnnotPropdef then
444 if na
.name
!= name
then continue
452 redef fun replace_with
(n
: ANode)
456 if not isset n
._location
and isset _location
then n
._location
= _location
460 # Abstract standard visitor on the AST
461 abstract class Visitor
462 # What the visitor do when a node is visited
463 # Concrete visitors should implement this method.
465 protected fun visit
(e
: ANode) is abstract
467 # Ask the visitor to visit a given node.
468 # Usually automatically called by visit_all* methods.
469 # This method should not be redefined
470 fun enter_visit
(e
: nullable ANode)
472 if e
== null then return
473 var old
= _current_node
479 # The current visited node
480 var current_node
: nullable ANode = null is writable
483 # Token of end of line (basically `\n`)
492 # Token of a line of comments
493 # Starts with the `#` and contains the final end-of-line (if any)
498 # A token associated with a keyword
499 abstract class TokenKeyword
503 return "keyword '{text}'"
507 # The deprecated keyword `package`.
512 # The keyword `module`
517 # The keyword `import`
522 # The keyword `class`
527 # The keyword `abstract`
532 # The keyword `interface`
537 # The keywords `enum` and `universal`
542 # The keyword `subset`
567 # The keyword `redef`
582 # The keyword `catch`
592 # The keyword `extern`
597 # The keyword `public`
602 # The keyword `protected`
607 # The keyword `private`
612 # The keyword `intrude`
632 # The keyword `while`
662 # The keyword `implies`
672 # The keyword `return`
677 # The keyword `continue`
682 # The keyword `break`
687 # The keyword `abort`
692 # The keyword `assert`
712 # The keyword `super`
727 # The keyword `false`
742 # The keyword `nullable`
747 # The keyword `isset`
752 # The keyword `label`
762 # The keyword `yield`
767 # The special keyword `__DEBUG__`
812 # A token associated with an operator (and other lookalike symbols)
813 abstract class TokenOperator
817 return "operator '{text}'"
1001 # A class (or formal type) identifier. They start with an uppercase.
1006 do return "type identifier '{text}'"
1010 # A standard identifier (variable, method...). They start with a lowercase.
1015 do return "identifier '{text}'"
1019 # An attribute identifier. They start with an underscore.
1024 do return "attribute '{text}'"
1028 # A token of a literal value (string, integer, etc).
1029 abstract class TokenLiteral
1033 do return "literal value '{text}'"
1042 # A literal floating point number
1047 # A literal character
1057 # The starting part of a super string (between `"` and `{`)
1062 # The middle part of a super string (between `}` and `{`)
1067 # The final part of a super string (between `}` and `"`)
1072 # A malformed string
1077 do return "malformed string {text}"
1081 # A malformed triple quoted string
1091 do return "malformed character {text}"
1095 # A extern code block
1096 class TExternCodeSegment
1100 # A malformed extern code block
1105 do return "malformed extern segment {text}"
1114 return "end of file"
1118 # A mark of an error
1122 # A lexical error (unexpected character)
1126 # A syntactic error (unexpected token)
1131 # The main node of a Nit source-file
1135 # The declaration part of the module
1136 var n_moduledecl
: nullable AModuledecl = null is writable
1138 # List of importation clauses
1139 var n_imports
= new ANodes[AImport](self)
1141 # List of extern blocks
1142 var n_extern_code_blocks
= new ANodes[AExternCodeBlock](self)
1144 # List of class definition (including top-level methods and the main)
1145 var n_classdefs
= new ANodes[AClassdef](self)
1148 # Abstract class for definition of entities
1149 abstract class ADefinition
1152 var n_doc
: nullable ADoc = null is writable
1154 # The `redef` keyword
1155 var n_kwredef
: nullable TKwredef = null is writable
1157 # The declared visibility
1158 var n_visibility
: nullable AVisibility = null is writable
1161 # The declaration of the module with the documentation, name, and annotations
1165 # The `module` keyword
1166 var n_kwmodule
: TKwmodule is writable, noinit
1168 # The declared module name
1169 var n_name
: AModuleName is writable, noinit
1172 # A import clause of a module
1173 abstract class AImport
1176 # The declared visibility
1177 var n_visibility
: AVisibility is writable, noinit
1179 # The `import` keyword
1180 var n_kwimport
: TKwimport is writable, noinit
1183 # A standard import clause. eg `import x`
1186 # The imported module name
1187 var n_name
: AModuleName is writable, noinit
1190 # The special import clause of the kernel module. eg `import end`
1193 # The `end` keyword, that indicate the root module
1194 var n_kwend
: TKwend is writable, noinit
1197 # A visibility modifier
1199 # The public visibility is an empty production (no keyword).
1201 # Note: even if some visibilities are only valid on some placse (for instance, no `protected` class or no `intrude` method)
1202 # the parser has no such a restriction, therefore the semantic phases has to check that the visibilities make sense.
1203 abstract class AVisibility
1207 # An implicit or explicit public visibility modifier
1208 class APublicVisibility
1210 # The `public` keyword, if any
1211 var n_kwpublic
: nullable TKwpublic = null is writable
1213 # An explicit private visibility modifier
1214 class APrivateVisibility
1216 # The `private` keyword
1217 var n_kwprivate
: TKwprivate is writable, noinit
1219 # An explicit protected visibility modifier
1220 class AProtectedVisibility
1222 # The `protected` keyword
1223 var n_kwprotected
: TKwprotected is writable, noinit
1225 # An explicit intrude visibility modifier
1226 class AIntrudeVisibility
1228 # The `intrude` keyword
1229 var n_kwintrude
: TKwintrude is writable, noinit
1232 # A class definition
1234 # While most definitions are `AStdClassdef`s,
1235 # there are 2 special cases of class definitions.
1236 abstract class AClassdef
1238 # All the declared properties (including the main method)
1239 var n_propdefs
= new ANodes[APropdef](self)
1242 # A standard class definition with a name, superclasses and properties
1247 # The class kind (interface, abstract class, etc.)
1248 var n_classkind
: AClasskind is writable, noinit
1250 # The name of the class
1251 var n_qid
: nullable AQclassid = null is writable
1254 var n_obra
: nullable TObra = null is writable
1256 # The list of formal parameter types
1257 var n_formaldefs
= new ANodes[AFormaldef](self)
1260 var n_cbra
: nullable TCbra = null is writable
1262 # The extern block code
1263 var n_extern_code_block
: nullable AExternCodeBlock = null is writable
1266 var n_kwend
: TKwend is writable, noinit
1268 fun n_superclasses
: Array[ASuperPropdef] do
1269 return [for d
in n_propdefs
do if d
isa ASuperPropdef then d
]
1272 redef fun hot_location
do return n_qid
.location
1275 # The implicit class definition of the implicit main method
1280 # The implicit class definition of the top-level methods
1285 # The modifier for the kind of class (abstract, interface, etc.)
1286 abstract class AClasskind
1290 # A default, or concrete class modifier (just `class`)
1291 class AConcreteClasskind
1294 # The `class` keyword.
1295 var n_kwclass
: TKwclass is writable, noinit
1298 # An abstract class modifier (`abstract class`)
1299 class AAbstractClasskind
1302 # The `abstract` keyword.
1303 var n_kwabstract
: TKwabstract is writable, noinit
1305 # The `class` keyword.
1306 var n_kwclass
: TKwclass is writable, noinit
1309 # An interface class modifier (`interface`)
1310 class AInterfaceClasskind
1313 # The `interface` keyword.
1314 var n_kwinterface
: TKwinterface is writable, noinit
1317 # An enum/universal class modifier (`enum class`)
1318 class AEnumClasskind
1321 # The `enum` keyword.
1322 var n_kwenum
: TKwenum is writable, noinit
1325 # An extern class modifier (`extern class`)
1326 class AExternClasskind
1329 # The `extern` keyword.
1330 var n_kwextern
: TKwextern is writable, noinit
1332 # The `class` keyword.
1333 var n_kwclass
: nullable TKwclass = null is writable
1336 class ASubsetClasskind
1339 # The `subset` keyword.
1340 var n_kwsubset
: TKwsubset is writable, noinit
1342 redef fun visit_all
(v
) do
1343 # TODO: Remove this redefinition once generated from the grammar.
1344 v
.enter_visit
(n_kwsubset
)
1348 # The definition of a formal generic parameter type. eg `X: Y`
1352 # The name of the parameter type
1353 var n_id
: TClassid is writable, noinit
1355 # The bound of the parameter type
1356 var n_type
: nullable AType = null is writable
1359 # The definition of a property
1360 abstract class APropdef
1364 # A definition of an attribute
1365 # For historical reason, old-syle and new-style attributes use the same `ANode` sub-class
1370 var n_kwvar
: TKwvar is writable, noinit
1372 # The identifier for a new-style attribute
1373 var n_id2
: TId is writable, noinit
1375 # The declared type of the attribute
1376 var n_type
: nullable AType = null is writable
1379 var n_assign
: nullable TAssign = null is writable
1381 # The initial value, if any (set with `=`)
1382 var n_expr
: nullable AExpr = null is writable
1385 var n_kwdo
: nullable TKwdo = null is writable
1387 # The initial value, if any (set with `do return`)
1388 var n_block
: nullable AExpr = null is writable
1391 var n_kwend
: nullable TKwend = null is writable
1393 redef fun hot_location
1395 return n_id2
.location
1399 # A definition of all kind of method (including constructors)
1403 # The `fun` keyword, if any
1404 var n_kwmeth
: nullable TKwmeth = null is writable
1406 # The `init` keyword, if any
1407 var n_kwinit
: nullable TKwinit = null is writable
1409 # The `isa` keyword, if any
1410 var n_kwisa
: nullable TKwisa = null is writable
1412 # The `new` keyword, if any
1413 var n_kwnew
: nullable TKwnew = null is writable
1415 # The name of the method, if any
1416 var n_methid
: nullable AMethid = null is writable
1418 # The signature of the method, if any
1419 var n_signature
: nullable ASignature = null is writable
1422 var n_kwdo
: nullable TKwdo = null is writable
1424 # The body (in Nit) of the method, if any
1425 var n_block
: nullable AExpr = null is writable
1428 var n_kwend
: nullable TKwend = null is writable
1430 # The list of declared callbacks (for extern methods)
1431 var n_extern_calls
: nullable AExternCalls = null is writable
1433 # The body (in extern code) of the method, if any
1434 var n_extern_code_block
: nullable AExternCodeBlock = null is writable
1436 redef fun hot_location
1438 if n_methid
!= null then
1439 return n_methid
.location
1440 else if n_kwinit
!= null then
1441 return n_kwinit
.location
1442 else if n_kwnew
!= null then
1443 return n_kwnew
.location
1450 # The implicit main method
1451 class AMainMethPropdef
1460 # A super-class. eg `super X`
1465 var n_kwsuper
: TKwsuper is writable, noinit
1467 # The super-class (indicated as a type)
1468 var n_type
: AType is writable, noinit
1472 # Declaration of callbacks for extern methods
1476 # The `import` keyword
1477 var n_kwimport
: TKwimport is writable, noinit
1479 # The list of declared callbacks
1480 var n_extern_calls
: ANodes[AExternCall] = new ANodes[AExternCall](self)
1483 # A single callback declaration
1484 abstract class AExternCall
1488 # A single callback declaration on a method
1489 abstract class APropExternCall
1493 # A single callback declaration on a method on the current receiver
1494 class ALocalPropExternCall
1495 super APropExternCall
1497 # The name of the called-back method
1498 var n_methid
: AMethid is writable, noinit
1501 # A single callback declaration on a method on an explicit receiver type.
1502 class AFullPropExternCall
1503 super APropExternCall
1505 # The type of the receiver of the called-back method
1506 var n_type
: AType is writable, noinit
1509 var n_dot
: nullable TDot = null is writable
1511 # The name of the called-back method
1512 var n_methid
: AMethid is writable, noinit
1515 # A single callback declaration on a method on a constructor
1516 class AInitPropExternCall
1517 super APropExternCall
1519 # The allocated type
1520 var n_type
: AType is writable, noinit
1523 # A single callback declaration on a `super` call
1524 class ASuperExternCall
1527 # The `super` keyword
1528 var n_kwsuper
: TKwsuper is writable, noinit
1531 # A single callback declaration on a cast
1532 abstract class ACastExternCall
1536 # A single callback declaration on a cast to a given type
1537 class ACastAsExternCall
1538 super ACastExternCall
1540 # The origin type of the cast
1541 var n_from_type
: AType is writable, noinit
1544 var n_dot
: nullable TDot = null is writable
1547 var n_kwas
: TKwas is writable, noinit
1549 # The destination of the cast
1550 var n_to_type
: AType is writable, noinit
1553 # A single callback declaration on a cast to a nullable type
1554 class AAsNullableExternCall
1555 super ACastExternCall
1557 # The origin type to cast as nullable
1558 var n_type
: AType is writable, noinit
1561 var n_kwas
: TKwas is writable, noinit
1563 # The `nullable` keyword
1564 var n_kwnullable
: TKwnullable is writable, noinit
1567 # A single callback declaration on a cast to a non-nullable type
1568 class AAsNotNullableExternCall
1569 super ACastExternCall
1571 # The destination type on a cast to not nullable
1572 var n_type
: AType is writable, noinit
1575 var n_kwas
: TKwas is writable, noinit
1578 var n_kwnot
: TKwnot is writable, noinit
1580 # The `nullable` keyword
1581 var n_kwnullable
: TKwnullable is writable, noinit
1584 # A definition of a virtual type
1588 # The `type` keyword
1589 var n_kwtype
: TKwtype is writable, noinit
1591 # The name of the virtual type
1592 var n_qid
: AQclassid is writable, noinit
1594 # The bound of the virtual type
1595 var n_type
: AType is writable, noinit
1598 # The identifier of a method in a method declaration.
1599 # There is a specific class because of operator and setters.
1600 abstract class AMethid
1604 # A method name with a simple identifier
1608 # The simple identifier
1609 var n_id
: TId is writable, noinit
1612 # A method name for an operator
1613 class AOperatorMethid
1616 # The associated operator symbol
1617 var n_op
: Token is writable, noinit
1621 super AOperatorMethid
1626 super AOperatorMethid
1631 super AOperatorMethid
1634 # A method name `**`
1635 class AStarstarMethid
1636 super AOperatorMethid
1641 super AOperatorMethid
1645 class APercentMethid
1646 super AOperatorMethid
1651 super AOperatorMethid
1656 super AOperatorMethid
1661 super AOperatorMethid
1666 super AOperatorMethid
1669 # A method name `==`
1671 super AOperatorMethid
1674 # A method name `!=`
1676 super AOperatorMethid
1679 # A method name `<=`
1681 super AOperatorMethid
1684 # A method name `>=`
1686 super AOperatorMethid
1691 super AOperatorMethid
1696 super AOperatorMethid
1699 # A method name `<<`
1701 super AOperatorMethid
1704 # A method name `>>`
1706 super AOperatorMethid
1709 # A method name `<=>`
1710 class AStarshipMethid
1711 super AOperatorMethid
1714 # A method name `[]`
1719 var n_obra
: TObra is writable, noinit
1722 var n_cbra
: TCbra is writable, noinit
1725 # A setter method name with a simple identifier (with a `=`)
1729 # The base identifier
1730 var n_id
: TId is writable, noinit
1733 var n_assign
: TAssign is writable, noinit
1736 # A method name `[]=`
1737 class ABraassignMethid
1741 var n_obra
: TObra is writable, noinit
1744 var n_cbra
: TCbra is writable, noinit
1747 var n_assign
: TAssign is writable, noinit
1750 # A potentially qualified simple identifier `foo::bar::baz`
1753 # The qualifier, if any
1754 var n_qualified
: nullable AQualified = null is writable
1756 # The final identifier
1757 var n_id
: TId is writable, noinit
1759 redef fun is_structural
do return true
1762 # A potentially qualified class identifier `foo::bar::Baz`
1765 # The qualifier, if any
1766 var n_qualified
: nullable AQualified = null is writable
1768 # The final identifier
1769 var n_id
: TClassid is writable, noinit
1771 redef fun is_structural
do return true
1774 # A signature in a method definition. eg `(x,y:X,z:Z):T`
1779 var n_opar
: nullable TOpar = null is writable
1781 # The list of parameters
1782 var n_params
= new ANodes[AParam](self)
1785 var n_cpar
: nullable TCpar = null is writable
1788 var n_type
: nullable AType = null is writable
1791 # A parameter definition in a signature. eg `x:X`
1795 # The name of the parameter
1796 var n_id
: TId is writable, noinit
1798 # The type of the parameter, if any
1799 var n_type
: nullable AType = null is writable
1801 # The `...` symbol to indicate varargs
1802 var n_dotdotdot
: nullable TDotdotdot = null is writable
1805 # A static type. eg `nullable X[Y]`
1808 # The `nullable` keyword
1809 var n_kwnullable
: nullable TKwnullable = null is writable
1811 # The name of the class or of the formal type
1812 var n_qid
: AQclassid is writable, noinit
1814 # The opening bracket
1815 var n_obra
: nullable TObra = null is writable
1817 # Type arguments for a generic type
1818 var n_types
= new ANodes[AType](self)
1820 # The closing bracket
1821 var n_cbra
: nullable TCbra = null is writable
1824 # A label at the end of a block or in a break/continue statement. eg `label x`
1828 # The `label` keyword
1829 var n_kwlabel
: TKwlabel is writable, noinit
1831 # The name of the label, if any
1832 var n_id
: nullable TId is writable, noinit
1835 # Expression and statements
1836 # From a AST point of view there is no distinction between statement and expressions (even if the parser has to distinguish them)
1837 abstract class AExpr
1841 # A sequence of `AExpr` (usually statements)
1842 # The last `AExpr` gives the value of the whole block
1846 # The list of statements in the bloc.
1847 # The last element is often considered as an expression that give the value of the whole block.
1848 var n_expr
= new ANodes[AExpr](self)
1851 var n_kwend
: nullable TKwend = null is writable
1854 # A declaration of a local variable. eg `var x: X = y`
1859 var n_kwvar
: nullable TKwvar = null is writable
1861 # The name of the local variable
1862 var n_id
: TId is writable, noinit
1864 # The declaration type of the local variable
1865 var n_type
: nullable AType = null is writable
1867 # The `=` symbol (for the initial value)
1868 var n_assign
: nullable TAssign = null is writable
1870 # The initial value, if any
1871 var n_expr
: nullable AExpr = null is writable
1874 # A `return` statement. eg `return x`
1878 # The `return` keyword
1879 var n_kwreturn
: nullable TKwreturn = null is writable
1882 # A `yield` statement. eg `yield x`
1886 # The `yield` keyword
1887 var n_kwyield
: nullable TKwyield = null is writable
1889 # The return value, if any
1890 var n_expr
: nullable AExpr = null is writable
1893 # Something that has a label.
1894 abstract class ALabelable
1897 # The associated label declatation
1898 var n_label
: nullable ALabel = null is writable
1901 # A `break` or a `continue`
1902 abstract class AEscapeExpr
1906 # The return value, if nay (unused currently)
1907 var n_expr
: nullable AExpr = null is writable
1910 # A `break` statement.
1914 # The `break` keyword
1915 var n_kwbreak
: TKwbreak is writable, noinit
1918 # An `abort` statement
1922 # The `abort` keyword
1923 var n_kwabort
: TKwabort is writable, noinit
1926 # A `continue` statement
1930 # The `continue` keyword.
1931 var n_kwcontinue
: nullable TKwcontinue = null is writable
1940 var n_kwdo
: TKwdo is writable, noinit
1942 # The list of statements of the `do`.
1943 var n_block
: nullable AExpr = null is writable
1945 # The `catch` keyword
1946 var n_kwcatch
: nullable TKwcatch = null is writable
1948 # The do catch block
1949 var n_catch
: nullable AExpr = null is writable
1957 var n_kwif
: TKwif is writable, noinit
1959 # The expression used as the condition of the `if`
1960 var n_expr
: AExpr is writable, noinit
1962 # The `then` keyword
1963 var n_kwthen
: TKwthen is writable, noinit
1965 # The body of the `then` part
1966 var n_then
: nullable AExpr = null is writable
1968 # The `else` keyword
1969 var n_kwelse
: nullable TKwelse = null is writable
1971 # The body of the `else` part
1972 var n_else
: nullable AExpr = null is writable
1975 # A `if` expression (ternary conditional). eg. `if true then 1 else 0`
1980 var n_kwif
: TKwif is writable, noinit
1982 # The expression used as the condition of the `if`
1983 var n_expr
: AExpr is writable, noinit
1985 # The `then` keyword
1986 var n_kwthen
: TKwthen is writable, noinit
1988 # The expression in the `then` part
1989 var n_then
: AExpr is writable, noinit
1991 # The `else` keyword
1992 var n_kwelse
: TKwelse is writable, noinit
1994 # The expression in the `else` part
1995 var n_else
: AExpr is writable, noinit
1998 # A `while` statement
2003 # The `while` keyword
2004 var n_kwwhile
: TKwwhile is writable, noinit
2006 # The expression used as the condition of the `while`
2007 var n_expr
: AExpr is writable, noinit
2010 var n_kwdo
: TKwdo is writable, noinit
2012 # The body of the loop
2013 var n_block
: nullable AExpr = null is writable
2016 # A `loop` statement
2021 # The `loop` keyword
2022 var n_kwloop
: TKwloop is writable, noinit
2024 # The body of the loop
2025 var n_block
: nullable AExpr = null is writable
2034 var n_kwfor
: TKwfor is writable, noinit
2036 # The list of groups to iterate
2037 var n_groups
= new ANodes[AForGroup](self)
2040 var n_kwdo
: TKwdo is writable, noinit
2042 # The body of the loop
2043 var n_block
: nullable AExpr = null is writable
2046 # A collection iterated by a for, its automatic variables and its implicit iterator.
2048 # Standard `for` iterate on a single collection.
2049 # Multiple `for` can iterate on more than one collection at once.
2053 # The list of name of the automatic variables
2054 var n_ids
= new ANodes[TId](self)
2057 var n_kwin
: TKwin is writable, noinit
2059 # The expression used as the collection to iterate on
2060 var n_expr
: AExpr is writable, noinit
2063 # A `with` statement
2068 # The `with` keyword
2069 var n_kwwith
: TKwwith is writable, noinit
2071 # The expression used to get the value to control
2072 var n_expr
: AExpr is writable, noinit
2075 var n_kwdo
: TKwdo is writable, noinit
2077 # The body of the loop
2078 var n_block
: nullable AExpr = null is writable
2081 # An `assert` statement
2085 # The `assert` keyword
2086 var n_kwassert
: TKwassert is writable, noinit
2088 # The name of the assert, if any
2089 var n_id
: nullable TId = null is writable
2091 # The expression used as the condition of the `assert`
2092 var n_expr
: AExpr is writable, noinit
2094 # The `else` keyword
2095 var n_kwelse
: nullable TKwelse = null is writable
2097 # The body to execute when the assert fails
2098 var n_else
: nullable AExpr = null is writable
2101 # Whatever is a simple assignment. eg `= something`
2102 abstract class AAssignFormExpr
2106 var n_assign
: TAssign is writable, noinit
2108 # The right-value to assign.
2109 var n_value
: AExpr is writable, noinit
2112 # Whatever is a combined assignment. eg `+= something`
2113 abstract class AReassignFormExpr
2116 # The combined operator (eg. `+=`)
2117 var n_assign_op
: AAssignOp is writable, noinit
2119 # The right-value to apply on the combined operator.
2120 var n_value
: AExpr is writable, noinit
2123 # A `once` expression. eg `once x`
2127 # The `once` keyword
2128 var n_kwonce
: TKwonce is writable, noinit
2130 # The expression to evaluate only one time
2131 var n_expr
: AExpr is writable, noinit
2134 # A polymorphic invocation of a method
2135 # The form of the invocation (name, arguments, etc.) are specific
2136 abstract class ASendExpr
2138 # The receiver of the method invocation
2139 var n_expr
: AExpr is writable, noinit
2142 # A binary operation on a method
2143 abstract class ABinopExpr
2147 var n_op
: Token is writable, noinit
2149 # The second operand of the operation
2150 # Note: the receiver (`n_expr`) is the first operand
2151 var n_expr2
: AExpr is writable, noinit
2153 # The name of the operator (eg '+')
2154 fun operator
: String is abstract
2157 # Something that is boolean expression
2158 abstract class ABoolExpr
2162 # Something that is binary boolean expression
2163 abstract class ABinBoolExpr
2166 # The first boolean operand
2167 var n_expr
: AExpr is writable, noinit
2170 var n_op
: Token is writable, noinit
2172 # The second boolean operand
2173 var n_expr2
: AExpr is writable, noinit
2181 # A `and` expression
2186 # A `or else` expression
2190 # The `else` keyword
2191 var n_kwelse
: TKwelse is writable, noinit
2194 # A `implies` expression
2199 # A `not` expression
2204 var n_kwnot
: TKwnot is writable, noinit
2206 # The boolean operand of the `not`
2207 var n_expr
: AExpr is writable, noinit
2210 # A `==` or a `!=` expression
2212 # Both have a similar effect on adaptive typing, so this class factorizes the common behavior.
2220 redef fun operator
do return "=="
2226 redef fun operator
do return "!="
2232 redef fun operator
do return "<"
2238 redef fun operator
do return "<="
2244 redef fun operator
do return "<<"
2250 redef fun operator
do return ">"
2256 redef fun operator
do return ">="
2262 redef fun operator
do return ">>"
2265 # A type-ckeck expression. eg `x isa T`
2269 # The expression to check
2270 var n_expr
: AExpr is writable, noinit
2273 var n_kwisa
: TKwisa is writable, noinit
2275 # The destination type to check to
2276 var n_type
: AType is writable, noinit
2282 redef fun operator
do return "+"
2288 redef fun operator
do return "-"
2291 # A `<=>` expression
2294 redef fun operator
do return "<=>"
2300 redef fun operator
do return "*"
2306 redef fun operator
do return "**"
2312 redef fun operator
do return "/"
2318 redef fun operator
do return "%"
2324 redef fun operator
do return "|"
2330 redef fun operator
do return "^"
2336 redef fun operator
do return "&"
2339 # A unary operation on a method
2340 abstract class AUnaryopExpr
2344 var n_op
: Token is writable, noinit
2346 # The name of the operator (eg '+')
2347 fun operator
: String is abstract
2350 # A unary minus expression. eg `-x`
2353 redef fun operator
do return "-"
2356 # A unary plus expression. eg `+x`
2359 redef fun operator
do return "+"
2362 # A unary `~` expression
2365 redef fun operator
do return "~"
2368 # An explicit instantiation. eg `new T`
2373 var n_kwnew
: TKwnew is writable, noinit
2375 # The `type` keyword
2376 var n_type
: AType is writable, noinit
2378 # The name of the named-constructor, if any
2379 var n_qid
: nullable AQid = null is writable
2381 # The arguments of the `new`
2382 var n_args
: AExprs is writable, noinit
2385 # Whatever is a old-style attribute access
2386 abstract class AAttrFormExpr
2389 # The receiver of the attribute
2390 var n_expr
: AExpr is writable, noinit
2392 # The name of the attribute
2393 var n_id
: TAttrid is writable, noinit
2397 # The read of an attribute. eg `x._a`
2402 # The assignment of an attribute. eg `x._a=y`
2403 class AAttrAssignExpr
2405 super AAssignFormExpr
2408 # Whatever looks-like a call with a standard method and any number of arguments.
2409 abstract class ACallFormExpr
2412 # The name of the method
2413 var n_qid
: AQid is writable, noinit
2415 # The arguments of the call
2416 var n_args
: AExprs is writable, noinit
2419 # A complex setter call (standard or brackets)
2420 abstract class ASendReassignFormExpr
2422 super AReassignFormExpr
2425 # A complex attribute assignment. eg `x._a+=y`
2426 class AAttrReassignExpr
2428 super AReassignFormExpr
2431 # A call with a standard method-name and any number of arguments. eg `x.m(y)`. OR just a simple id
2432 # 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`.
2433 # Semantic analysis have to transform them to instance of `AVarExpr`.
2438 # A setter call with a standard method-name and any number of arguments. eg `x.m(y)=z`. OR just a simple assignment.
2439 # 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`.
2440 # Semantic analysis have to transform them to instance of `AVarAssignExpr`.
2441 class ACallAssignExpr
2443 super AAssignFormExpr
2446 # 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.
2447 # Note: because the parser cannot distinguish a variable write with a complex setter call with an implicit receiver and no arguments, it always returns a `ACallReassignExpr`.
2448 # Semantic analysis have to transform them to instance of `AVarReassignExpr`.
2449 class ACallReassignExpr
2451 super ASendReassignFormExpr
2454 # A call to `super`. OR a call of a super-constructor
2458 # The qualifier part before the super (currenlty unused)
2459 var n_qualified
: nullable AQualified = null is writable
2461 # The `super` keyword
2462 var n_kwsuper
: TKwsuper is writable, noinit
2464 # The arguments of the super
2465 var n_args
: AExprs is writable, noinit
2468 # A call to the `init` constructor.
2469 # Note: because `init` is a keyword and not a `TId`, the explicit call to init cannot be a `ACallFormExpr`.
2473 # The `init` keyword
2474 var n_kwinit
: TKwinit is writable, noinit
2476 # The arguments of the init
2477 var n_args
: AExprs is writable, noinit
2480 # Whatever looks-like a call of the brackets `[]` operator.
2481 abstract class ABraFormExpr
2484 # The arguments inside the brackets
2485 var n_args
: AExprs is writable, noinit
2488 # A call of the brackets operator. eg `x[y,z]`
2493 # A setter call of the bracket operator. eg `x[y,z]=t`
2494 class ABraAssignExpr
2496 super AAssignFormExpr
2499 # Whatever is an access to a local variable
2500 abstract class AVarFormExpr
2503 # The name of the attribute
2504 var n_id
: TId is writable, noinit
2507 # A complex setter call of the bracket operator. eg `x[y,z]+=t`
2508 class ABraReassignExpr
2510 super ASendReassignFormExpr
2513 # A local variable read access.
2514 # The parser cannot instantiate them, see `ACallExpr`.
2519 # A local variable simple assignment access
2520 # The parser cannot instantiate them, see `ACallAssignExpr`.
2521 class AVarAssignExpr
2523 super AAssignFormExpr
2526 # A local variable complex assignment access
2527 # The parser cannot instantiate them, see `ACallReassignExpr`.
2528 class AVarReassignExpr
2530 super AReassignFormExpr
2533 # A literal range, open or closed
2534 abstract class ARangeExpr
2537 # The left (lower) element of the range
2538 var n_expr
: AExpr is writable, noinit
2541 var n_dotdot
: TDotdot is writable, noinit
2543 # The right (upper) element of the range
2544 var n_expr2
: AExpr is writable, noinit
2547 # A closed literal range. eg `[x..y]`
2551 # The opening bracket `[`
2552 var n_obra
: TObra is writable, noinit
2554 # The closing bracket `]`
2555 var n_cbra
: TCbra is writable, noinit
2558 # An open literal range. eg `[x..y[`
2562 # The opening bracket `[`
2563 var n_obra
: TObra is writable, noinit
2565 # The closing bracket `[` (because open range)
2566 var n_cbra
: TObra is writable, noinit
2569 # A literal array. eg. `[x,y,z]`
2573 # The opening bracket `[`
2574 var n_obra
: TObra is writable, noinit
2576 # The elements of the array
2577 var n_exprs
= new ANodes[AExpr](self)
2579 # The type of the element of the array (if any)
2580 var n_type
: nullable AType = null is writable
2582 # The closing bracket `]`
2583 var n_cbra
: TCbra is writable, noinit
2590 # The `self` keyword
2591 var n_kwself
: nullable TKwself = null is writable
2594 # When there is no explicit receiver, `self` is implicit
2595 class AImplicitSelfExpr
2599 # A `true` boolean literal constant
2603 # The `true` keyword
2604 var n_kwtrue
: TKwtrue is writable, noinit
2607 # A `false` boolean literal constant
2611 # The `false` keyword
2612 var n_kwfalse
: TKwfalse is writable, noinit
2615 # A `null` literal constant
2619 # The `null` keyword
2620 var n_kwnull
: TKwnull is writable, noinit
2623 # An integer literal
2628 var n_integer
: TInteger is writable, noinit
2636 var n_float
: TFloat is writable, noinit
2639 # A character literal
2643 # The character token
2644 var n_char
: TChar is writable, noinit
2648 abstract class AStringFormExpr
2652 var n_string
: Token is writable, noinit
2655 # A simple string. eg. `"abc"`
2657 super AStringFormExpr
2660 # The start of a superstring. eg `"abc{`
2661 class AStartStringExpr
2662 super AStringFormExpr
2665 # The middle of a superstring. eg `}abc{`
2666 class AMidStringExpr
2667 super AStringFormExpr
2670 # The end of a superstrng. eg `}abc"`
2671 class AEndStringExpr
2672 super AStringFormExpr
2675 # A superstring literal. eg `"a{x}b{y}c"`
2676 # Each part is modeled a sequence of expression. eg. `["a{, x, }b{, y, }c"]`
2677 class ASuperstringExpr
2680 # The list of the expressions of the superstring
2681 var n_exprs
= new ANodes[AExpr](self)
2684 # A simple parenthesis. eg `(x)`
2688 # The opening parenthesis
2689 var n_opar
: TOpar is writable, noinit
2691 # The inner expression
2692 var n_expr
: AExpr is writable, noinit
2694 # The closing parenthesis
2695 var n_cpar
: TCpar is writable, noinit
2698 # A cast, against a type or `not null`
2702 # The expression to cast
2703 var n_expr
: AExpr is writable, noinit
2706 var n_kwas
: TKwas is writable, noinit
2708 # The opening parenthesis
2709 var n_opar
: nullable TOpar = null is writable
2711 # The closing parenthesis
2712 var n_cpar
: nullable TCpar = null is writable
2715 # A type cast. eg `x.as(T)`
2719 # The target type to cast to
2720 var n_type
: AType is writable, noinit
2723 # A as-not-null cast. eg `x.as(not null)`
2724 class AAsNotnullExpr
2728 var n_kwnot
: TKwnot is writable, noinit
2730 # The `null` keyword
2731 var n_kwnull
: TKwnull is writable, noinit
2734 # A is-set check of old-style attributes. eg `isset x._a`
2735 class AIssetAttrExpr
2738 # The `isset` keyword
2739 var n_kwisset
: TKwisset is writable, noinit
2742 # An ellipsis notation used to pass an expression as it, in a vararg parameter
2746 # The passed expression
2747 var n_expr
: AExpr is writable, noinit
2750 var n_dotdotdot
: TDotdotdot is writable, noinit
2753 # An named notation used to pass an expression by name in a parameter
2757 # The name of the argument
2758 var n_id
: TId is writable, noinit
2761 var n_assign
: TAssign is writable, noinit
2763 # The passed expression
2764 var n_expr
: AExpr is writable, noinit
2767 # A list of expression separated with commas (arguments for instance)
2771 # The list of expressions
2772 var n_exprs
= new ANodes[AExpr](self)
2775 # A special expression that encapsulates a static type
2776 # Can only be found in special construction like arguments of annotations.
2780 # The encapsulated type
2781 var n_type
: AType is writable, noinit
2784 # A special expression that encapsulates a method identifier
2785 # Can only be found in special construction like arguments of annotations.
2790 var n_expr
: AExpr is writable, noinit
2792 # The encapsulated method identifier
2793 var n_id
: AMethid is writable, noinit
2796 # A special expression that encapsulate an annotation
2797 # Can only be found in special construction like arguments of annotations.
2799 # The encapsulated annotations are in `n_annotations`
2804 # A special expression to debug types
2805 class ADebugTypeExpr
2808 # The `debug` keyword
2809 var n_kwdebug
: TKwdebug is writable, noinit
2811 # The `type` keyword
2812 var n_kwtype
: TKwtype is writable, noinit
2814 # The expression to check
2815 var n_expr
: AExpr is writable, noinit
2818 var n_type
: AType is writable, noinit
2821 # A list of expression separated with commas (arguments for instance)
2822 abstract class AExprs
2825 # The list of expressions
2826 var n_exprs
= new ANodes[AExpr](self)
2829 # A simple list of expressions
2834 # A list of expressions enclosed in parentheses
2838 # The opening parenthesis
2839 var n_opar
: TOpar is writable, noinit
2841 # The closing parenthesis
2842 var n_cpar
: TCpar is writable, noinit
2845 # A list of expressions enclosed in brackets
2849 # The opening bracket
2850 var n_obra
: TObra is writable, noinit
2852 # The closing bracket
2853 var n_cbra
: TCbra is writable, noinit
2856 # A complex assignment operator. (`+=` and `-=`)
2857 abstract class AAssignOp
2860 # The combined assignment operator
2861 var n_op
: Token is writable, noinit
2863 # The name of the operator without the `=` (eg '+')
2864 fun operator
: String is abstract
2867 # A `+=` assignment operation
2871 redef fun operator
do return "+"
2874 # A `-=` assignment operation
2875 class AMinusAssignOp
2878 redef fun operator
do return "-"
2881 # A `*=` assignment operation
2885 redef fun operator
do return "*"
2888 # A `/=` assignment operation
2889 class ASlashAssignOp
2892 redef fun operator
do return "/"
2895 # A `%=` assignment operation
2896 class APercentAssignOp
2899 redef fun operator
do return "%"
2902 # A `**=` assignment operation
2903 class AStarstarAssignOp
2906 redef fun operator
do return "**"
2909 # A `|=` assignment operation
2913 redef fun operator
do return "|"
2916 # A `^=` assignment operation
2917 class ACaretAssignOp
2920 redef fun operator
do return "^"
2923 # A `&=` assignment operation
2927 redef fun operator
do return "&"
2930 # A `<<=` assignment operation
2934 redef fun operator
do return "<<"
2937 # A `>>=` assignment operation
2941 redef fun operator
do return ">>"
2944 # A possibly fully-qualified module identifier
2948 # The starting quad (`::`)
2949 var n_quad
: nullable TQuad = null is writable
2951 # The list of quad-separated package/group identifiers
2952 var n_path
= new ANodes[TId](self)
2954 # The final module identifier
2955 var n_id
: TId is writable, noinit
2958 # A language declaration for an extern block
2963 var n_kwin
: TKwin is writable, noinit
2966 var n_string
: TString is writable, noinit
2969 # An full extern block
2970 class AExternCodeBlock
2973 # The language declration
2974 var n_in_language
: nullable AInLanguage = null is writable
2976 # The block of extern code
2977 var n_extern_code_segment
: TExternCodeSegment is writable, noinit
2980 # A possible full method qualifier.
2984 # The starting quad (`::`)
2985 var n_quad
: nullable TQuad = null is writable
2987 # The list of quad-separated package/group/module identifiers
2988 var n_id
= new ANodes[TId](self)
2990 # A class identifier
2991 var n_classid
: nullable TClassid = null is writable
2994 # A documentation of a definition
2995 # It contains the block of comments just above the declaration
2999 # A list of lines of comment
3000 var n_comment
= new ANodes[TComment](self)
3003 # A group of annotation on a node
3005 # This same class is used for the 3 kind of annotations:
3007 # * *is* annotations. eg `module foo is bar`.
3008 # * *at* annotations. eg `foo@bar` or `foo@(bar,baz)`.
3009 # * *class* annotations, defined in classes.
3013 # The `is` keyword, for *is* annotations
3014 var n_kwis
: nullable TKwis = null is writable
3016 # The `@` symbol, for *at* annotations
3017 var n_at
: nullable TAt = null is writable
3019 # The opening parenthesis in *at* annotations
3020 var n_opar
: nullable TOpar = null is writable
3022 # The list of annotations
3023 var n_items
= new ANodes[AAnnotation](self)
3025 # The closing parenthesis in *at* annotations
3026 var n_cpar
: nullable TCpar = null is writable
3028 # The `end` keyword, for *is* annotations
3029 var n_kwend
: nullable TKwend = null is writable
3032 # A single annotation
3036 # The name of the annotation
3037 var n_atid
: AAtid is writable, noinit
3039 # The opening parenthesis of the arguments
3040 var n_opar
: nullable TOpar = null is writable
3042 # The list of arguments
3043 var n_args
= new ANodes[AExpr](self)
3045 # The closing parenthesis
3046 var n_cpar
: nullable TCpar = null is writable
3048 # The name of the annotation
3051 return n_atid
.n_id
.text
3055 # An annotation name
3056 abstract class AAtid
3059 # The identifier of the annotation.
3061 # Can be a TId or a keyword.
3062 var n_id
: Token is writable, noinit
3065 # An annotation name based on an identifier
3070 # An annotation name based on the keyword `extern`
3075 # An annotation name based on the keyword `import`
3080 # An annotation name based on the keyword `abstract`
3081 class AKwabstractAtid
3085 # The root of the AST
3090 var n_base
: nullable AModule is writable
3092 # The end of file (or error) token
3093 var n_eof
: EOF is writable