Commit Graph

5 Commits

Author SHA1 Message Date
Martin Atkins
2cfc08c632 json: Allow strings to be treated as HIL templates
Eventually zcl will have its own native template format that we'll use
by default, but for applications migrating from HCL/HIL we can instead
parse strings as HIL templates, for compatibility with how JSON configs
would've been processed in a HCL/HIL app.

When this mode is not enabled, we still just treat strings as literals,
pending the implementation of the zcl template parser.
2017-05-21 22:34:23 -07:00
Martin Atkins
4bbfa6d6ab json: recovery behavior for the parser
When using the parser to do static analysis and editor integrations, it's
still useful to be able to get the incomplete AST resulting from a parse
error.

Callers that intend to use the returned value to take real actions (as
opposed to just analysis) must check diags.HasError() to determine if
the returned file can be considered valid.
2017-05-20 13:32:12 -07:00
Martin Atkins
d2c9089812 json: ContextString implementation
This JSON-flavored ContextString implementation returns a chain of
property names using JavaScript-style attribute access syntax.
2017-05-19 19:33:58 -07:00
Martin Atkins
41527d1a3c Retain the bytes used to construct a file
Later on this will be useful when printing diagnostics with source code
snippets as context.
2017-05-18 08:07:52 -07:00
Martin Atkins
160f56abb1 json: beginnings of parsing JSON into File objects
The returned file objects are not actually functional yet, but this
establishes the interface.
2017-05-18 07:57:04 -07:00