Expression is used to refer to any EXPR
object, including those without children (terminals).
mutable struct EXPR
head::Symbol
args::Union{Nothing,Vector{EXPR}}
trivia::Union{Nothing,Vector{EXPR}}
fullspan::Int
span::Int
val::Union{Nothing,String}
parent::Union{Nothing,EXPR}
meta
end
The first two arguments match the representation within Expr
.
The type of expression, equivalent to the head of Expr. Possible heads are a superset of those available for an Expr.
As for Expr
, holds child expressions. Terminal expressions do not hold children.
Holds terminals specific to the CST representation. Terminal expressions do not hold trivia.
The byte size of the expression in the source code text, including trailing white space.
As above but excluding trailing white space. (fullspan - span
is the byte size of trailing white space.)
A field to store the textual representation of the token as necessary, otherwise it is set to nothing
. This is needed for identifiers, operators and literals.
An extended group of expression types is used to allow full equivalence of terminal tokens with other expressions. By convention expression heads will match those used in Julia AST (lowercase) and others are capitalised.
Identifier Nonstdidentifier Operator
comma lparen rparen lsquare rsquare lbrace rbrace atsign dot
abstract baremodule begin break catch const continue do else elseif end export finally for function global if import importall let local macro module mutable new outer primitive quote return struct try type using while
:INTEGER, :BININT, :HEXINT, :OCTINT, :FLOAT, :STRING, :TRIPLESTRING, :CHAR, :CMD, :TRIPLECMD, :NOTHING, :true, :false,
(args...) (global ,...)
(args...) (,...)
Special handling: global const expr
is parsed as const global expr
. In this case both the const
and global
keywords are stored wihin the :const
expression's trivia (the :global
expression has no trivia).
(args...) (local ,...)
(body) (return)
(name) (abstract type end)
(name n) (primitive type end)
(mut name block) (struct end)
(mut name block) (mutable struct end)
(bodyargs...) (begin end)
(bodyargs...) ()
(block) (quote end)
(block) (:)
(itrs block) (for end)
(sig block) (function end)
(name) (function end)
(arg) (outer)
(args...) ({ commas.. })
(args...) ({ commas... })
(args...) (commas...)
Only used as the head of an expression within using/import
calls.
(cond block) (if end)
(cond block elseif) (if end)
(cond block block) (if else end)
(cond block) (elseif)
(cond block block) (elseif else)
(args...)
Trivia: module
, end
Trivia: baremodule
, end
:ErrorToken
Iterators of loops are converted to a = b
if needed in line with the scheme parser. the operator is a facade and the actual operator use is stored as trivia.
- For single token keyword expressions (e.g.
break
) do we use the visible token as the head or store it in trivia?