@@ -44,6 +44,53 @@ const AnonFuncOp = 14
44
44
SignatureOfFunctionDefIsNotACall,
45
45
MalformedMacroName)
46
46
47
+ """
48
+ `EXPR` represents Julia expressions overlaying a span of bytes in the source
49
+ text. The full span starts at the first syntactically significant token and
50
+ includes any trailing whitespace/comments.
51
+
52
+ Iterating or directly indexing `EXPR` results in a sequence of child `EXPR` in
53
+ source order, including most syntax trivia but not including whitespace,
54
+ comments and semicolons.
55
+
56
+ The fields of `EXPR` are:
57
+
58
+ * `head` represents the type of the expression
59
+ - For internal tree nodes it usually matches the associated `Expr`'s head
60
+ field. But not always because there's some additional heads, for example
61
+ `:brackets` for grouping parentheses, `:globalrefdoc`, `:quotenode`, etc
62
+ - For leaf nodes (ie, individual tokens), it's capitalized. Eg,
63
+ `:INTEGER` for integer tokens, `:END` for `end`, `:LPAREN` for `[`,
64
+ etc.
65
+ - For syntactic operators such as `=` and `<:` (which have the operator
66
+ itself as the expression head in normal `Expr`), the head is an `EXPR`.
67
+
68
+ * `args` are the significant subexpressions, in the order used by `Base.Expr`.
69
+ For leaf nodes, this is `nothing`.
70
+
71
+ * `trivia` are any nontrivial tokens which are trivial after parsing.
72
+ - This includes things like the parentheses in `(1 + 2)`, and the
73
+ keywords in `begin x end`
74
+ - Whitespace and comments are not included in `trivia`
75
+
76
+ * `fullspan` is the total number of bytes of text covered by this expression,
77
+ including any trailing whitespace or comment trivia.
78
+
79
+ * `span` is the number of bytes of text covered by the syntactically
80
+ relevant part of this expression (ie, not including trailing whitespace
81
+ or comment trivia).
82
+
83
+ * `val` is the source text covered by `span`
84
+
85
+ * `parent` is the parent node in the expression tree, or `Nothing` for the root.
86
+
87
+ * `meta` contains metadata. This includes some ad-hoc information supplied by
88
+ the parser. (But can also be used downstream in linting or static analysis.)
89
+
90
+ Whitespace, comments and semicolons are not represented explicitly. Rather,
91
+ they're tacked onto the end of leaf tokens in `args` or `trivia`, in the last
92
+ `fullspan-span` bytes of the token.
93
+ """
47
94
mutable struct EXPR
48
95
head:: Union{Symbol,EXPR}
49
96
args:: Union{Nothing,Vector{EXPR}}
0 commit comments