Commit Graph

4 Commits

Author SHA1 Message Date
Martin Atkins
61ebd9b65b zclsyntax: template "for" construct 2017-06-18 08:14:55 -07:00
Martin Atkins
fdd68833f3 zclsyntax: template single-interpolation case as separate AST node
Rather than setting an "Unwrap" field on the existing TemplateExpr, we'll
instead use a separate, simpler AST node.

There is very little in common between these two cases, so overloading the
TemplateExpr node doesn't buy much. A separate node is needed here,
rather than just returning the wrapped node directly, to give us somewhere
to capture the full source range extent of the wrapping template, whereas
the inner expression only captures the range of itself. This is important
both for good diagnostics and for transforming zclsyntax AST into
zclwrite AST.
2017-06-18 07:44:57 -07:00
Martin Atkins
15e3d80e6c zclsyntax: parsing of template if construct
Since this ultimately just returns a ConditionalExpr, the evaluation is
already implemented too.
2017-06-17 10:07:59 -07:00
Martin Atkins
2f1bfd284c zclsyntax: reorganize template parsing
Previously we tried to do the whole template parse in one pass. This was
adequate for dealing with literals and interpolations because they
create a flat structure, but to parse the template control sequences we
need to be able to deal with nested template sequences.

As a building block towards this, we first do a pass of extracting the
template-level "tokens": literals, interpolations, control sequences.
We then pass over that sequence of tokens and parse it, which is then
simplified because the larger template atoms have already been produced.
2017-06-17 09:05:15 -07:00