Commit Graph

15 Commits

Author SHA1 Message Date
Paul Tyng
e8e85f5edd
Add additional comment test cases
Some of these fail in HCL1 fmt
2018-10-31 12:25:12 -04:00
Martin Atkins
d754d5a269 hclwrite: Adjust token spacing automatically when writing
Although our underlying parse tree retains all of the token content, it
doesn't necessarily retain all of the spacing information under editing,
and so formatting on save ensures that we'll produce a canonical result
even if some edits have been applied that have changed the expected
alignment of objects, etc.
2018-08-25 12:15:40 -07:00
Martin Atkins
59bb5c2670 hclwrite: Fix NewExpressionAbsTraversal signature
It is still not implemented, but at least now it is declared with the
correct return type.
2018-08-09 08:47:37 -07:00
Martin Atkins
c8c208e083 hclwrite: Body.SetAttributeValue
For now, this is the only way to set an attribute, and so attributes can
only be set to literal values.

Later this will be generalized so that this is just a helper wrapper
around a "SetAttribute" method that just uses a given expression, which
then helps by constructing the expression from the value first.
2018-08-09 08:44:48 -07:00
Martin Atkins
77c0b55a59 hclwrite: Simplify internal data structures
The original prototype of hclwrite tried to track both the tokens and
the AST as two parallel data structures. This quickly exploded in
complexity, leading to lots of messy code to manage keeping those two
structures in sync.

This new approach melds the two structures together, creating first a
physical token tree (made of "node" objects, and hidden from the caller)
and then attaching the AST nodes to that token tree as additional sidecar
data.

The result is much easier to work with, leading to less code in the parser
and considerably less complex data structures in the parser's tests.

This commit is enough to reach feature parity with the previous prototype,
but it remains a prototype. With a more usable foundation, we'll evolve
this into a more complete implementation in subsequent commits.
2018-08-01 08:46:31 -07:00
Martin Atkins
966851f309 hclwrite: TokensForValue
This function produces a token stream of a reasonable source
representation of the given constant value.
2018-07-14 15:05:37 -07:00
Martin Atkins
3c0fafde46 hclwrite: Formatter should put a space after a comma 2018-07-14 15:05:37 -07:00
Martin Atkins
314ea6f332 hclwrite: Allow format to be called on fragment of tokens 2018-07-14 15:05:37 -07:00
Martin Atkins
d6367b5f96 hclwrite: Parsing of absolute traversals in expressions
This will allow for use-cases such as renaming a variable (changing the
content of the first token) and replacing variable references with
constant values that they evaluate to for debug purposes.
2018-07-14 13:07:39 -07:00
Martin Atkins
81d2277300 hclwrite: Format shouldn't introduce spaces before index brackets
This is another heuristic because the "[" syntax is also the tuple
constructor start marker, but this takes care of the common cases of
indexing keywords and bracketed expressions.

This fixes #29.
2018-05-23 16:56:29 -07:00
Martin Atkins
f70b6b00c8 hclwrite: update remaining stale references to "zcl" 2018-01-27 11:03:05 -08:00
Fatih Arslan
f87600a7d9 update zclsyntax to hclsyntax in various comments and strings
These are remnants of the project HCL was forked from.
2018-01-23 21:54:38 -08:00
Martin Atkins
46b20d40af Update doc comments and readmes for zcl -> HCL. 2017-09-11 16:56:31 -07:00
Martin Atkins
708abb8c97 Move the zcl package and its two parsing subpackages to "hcl" names
This is a super-invasive update since the "zcl" package in particular
is referenced all over.

There are probably still a few zcl references hanging around in comments,
etc but this takes care of most of it.
2017-09-11 16:40:37 -07:00
Martin Atkins
0dc3a6015c Rename the ancillary packages from "zcl" to "hcl".
The main "zcl" package requires a bit more care because of how many
callers it has and because of its two subpackages, so we'll take care
of that one separately.
2017-09-11 16:00:31 -07:00