Paul Hinze
5612ebd968
Handle multiple interpolations in string.
...
A user testing an RC release of Terraform 0.6.7 found the following
string unexpectedly caused a syntax error:
"echo ${var.region}${element(split(",",var.zones),0)}"
This fixes the error and covers it with a test.
2015-11-19 13:56:32 -06:00
Paul Hinze
feb701804f
Restore old behavior for \" within interpolations
...
Before the parser rewrite, HCL would silently convert `\"` within
interpolation braces to `"`.
After the conversion, this became a syntax error.
We've found several instances of Terraform configs in the wild using
this syntax. It results in a hard "syntax error" message during config
parsing. While avoiding the extra escape on double quotes within
interpolations is definitely preferred, the UX of the syntax error feels
harsh enough to be worth inserting this backwards compatibility for now,
leaving us the option of deprecating it with a warning down the line.
2015-11-19 12:04:02 -06:00
Mitchell Hashimoto
201420aad0
hcl/parser: store position on every parse err [GH-54]
2015-11-15 15:03:31 -08:00
Fatih Arslan
d45f5d133c
ast: change signature of Walk() to allow rewriting AST
...
With the previous Walk function it's not easy to rewrite the node as we
don't have any kind of reference to the parent. If we want to rewrite a
given AST, we have to manually traverse it as Walk is not usable. To
allow us rewriting the AST we change the signature of the function
passed to Walk. It'll allow us to rewrite the AST and return back.
Internally Walk() overrides the returned AST.
This idea was also talked here:
https://groups.google.com/forum/#!topic/golang-nuts/cRZQV36IckM
extensively.
2015-11-14 21:58:31 +02:00
Fatih Arslan
99ce7c7e2c
parser: fix syntax error on missing comma
...
Fixes hashicorp/terraform#3877
2015-11-12 15:26:23 +02:00
Mitchell Hashimoto
616214bb2e
hcl/printer: cleanup how we handle heredocs
2015-11-10 15:06:32 -08:00
Mitchell Hashimoto
7b107c7b54
hcl/printer: clear trailing newline from heredoc
2015-11-10 15:02:21 -08:00
Mitchell Hashimoto
16dcdb88fa
hcl/printer: unindent for heredocs
2015-11-10 14:54:46 -08:00
Mitchell Hashimoto
db97e1a99c
hcl/token: Value for heredoc
2015-11-10 14:09:01 -08:00
Mitchell Hashimoto
0f965478b6
hcl/parser: parse heredocs
2015-11-10 14:03:29 -08:00
Mitchell Hashimoto
6c34ace97d
hcl/token: heredoc token
2015-11-10 14:02:37 -08:00
Mitchell Hashimoto
82ad2beb52
hcl/scanner: scan heredocs
2015-11-10 14:01:56 -08:00
Mitchell Hashimoto
d726517f58
hcl/ast: tests for Filter
2015-11-09 09:08:05 -08:00
Mitchell Hashimoto
eabb04dcd5
hcl/ast: filter should compare value string
2015-11-08 16:25:40 -08:00
Mitchell Hashimoto
278bb105f2
hcl/ast: style
2015-11-08 16:20:22 -08:00
Mitchell Hashimoto
340f0af3c0
json/token: fix issues with unquoting sttrings from JSON
2015-11-08 16:08:36 -08:00
Mitchell Hashimoto
15fce08259
hcl/ast: walk the objectlist within an objecttype
2015-11-07 16:47:50 -08:00
Mitchell Hashimoto
0704c168e1
hcl/printer: make boolean logic one line
2015-11-07 15:15:40 -08:00
Mitchell Hashimoto
b24dfd1bb1
hcl/printer: output an equal sign only if we had one originally
2015-11-07 15:13:05 -08:00
Mitchell Hashimoto
9ca9a4e1c3
hcl/ast: simplify API
2015-11-07 10:25:22 -08:00
Mitchell Hashimoto
32411ba6af
hcl/ast: Get should return a list
2015-11-07 09:52:50 -08:00
Mitchell Hashimoto
e370e34aeb
down to one failing test
2015-11-07 00:12:04 -08:00
Mitchell Hashimoto
5aaa3e75b9
hcl/parser: scan errors should come through as well
2015-11-06 23:42:45 -08:00
Mitchell Hashimoto
6cc18eb70b
hcl/scanner: actually scan all things with exponents as floats
2015-11-06 23:33:25 -08:00
Mitchell Hashimoto
0c18c66fff
hcl/ast: ObjectList.Prefix
2015-11-06 23:12:08 -08:00
Mitchell Hashimoto
7996653560
hcl/strconv: more error cases
2015-11-06 23:02:59 -08:00
Mitchell Hashimoto
c8f28b7b42
hcl/strconv: custom unquote logic
2015-11-06 23:00:37 -08:00
Mitchell Hashimoto
68e40f3944
hcl/token: Value should unquote string
2015-11-06 22:35:07 -08:00
Mitchell Hashimoto
16ce140272
hcl/token: add Value for IDENT
2015-11-06 18:29:48 -08:00
Mitchell Hashimoto
798e1c6c05
hcl/scanner: allow hyphens in idents
2015-11-06 17:56:57 -08:00
Mitchell Hashimoto
22bdcc2db1
hcl/scanner: scan interpolations properly
2015-11-06 17:55:07 -08:00
Mitchell Hashimoto
96291d2dbe
hcl/token: add Value to get the rich type value
2015-11-06 17:28:38 -08:00
Mitchell Hashimoto
c1090aad4a
hcl: delete old parser
2015-11-06 16:18:44 -08:00
Mitchell Hashimoto
d7c35808a8
move hclnew to hcl
2015-11-06 16:04:20 -08:00
Mitchell Hashimoto
4de51957ef
hcl: fix trailing comma + comment parse error
...
https://github.com/hashicorp/terraform/issues/3249
2015-09-16 09:54:29 -07:00
Mitchell Hashimoto
5486421143
hcl: multi-line comments aren't allowed to terminate with EOF
2015-06-23 21:38:11 -07:00
Mitchell Hashimoto
681623f4e1
hcl: don't allow nested comments
...
This copies C's behavior and disallows nested block comments. It ignores
a new /* within an existing block comment and ends at the first */
2015-06-23 21:34:40 -07:00
Mitchell Hashimoto
513e04c400
hcl: use stringer to generate string values for ValueType
2015-01-15 15:12:25 -08:00
Mitchell Hashimoto
3c3a30a1e5
Use go generate to generate parsers
2015-01-15 15:11:14 -08:00
Atin Malaviya
5f50053914
Modified to import github.com/hashicorp/go-multierror rather than terraform's multierror.
2014-12-24 17:49:50 -05:00
Mitchell Hashimoto
256bb51ed8
hcl: support "." in identifier
2014-12-17 11:39:45 -08:00
Mitchell Hashimoto
e51eabcdf8
parse floats 1.02 properly [GH-19]
2014-11-12 21:29:07 -08:00
Mitchell Hashimoto
88ef419bd9
Properly decode \\n
2014-11-12 21:12:45 -08:00
Mitchell Hashimoto
ab2c4c3120
hcl: complex keys can be set using strings
2014-11-12 21:08:08 -08:00
Matt Hartzler
f41fb6a9c4
fixup comment typo
2014-10-16 09:53:03 -05:00
Mitchell Hashimoto
764b0ad3c0
Allow escaping quotes in HCL string [GH-14]
2014-10-10 16:07:25 -07:00
Mitchell Hashimoto
6606366746
hcl: trailing comma support in HCL
2014-09-30 14:58:50 -07:00
Mitchell Hashimoto
3fc289c4d2
hcl: test parsing an empty file
2014-09-15 09:38:43 -07:00
Mitchell Hashimoto
86d22484a4
hcl: can parse empty file with just a comment
2014-09-14 19:59:36 -07:00
Mitchell Hashimoto
9b5d9eb9b0
hcl: fix scenario where infinite loop happens
2014-09-07 16:18:56 -07:00
Mitchell Hashimoto
a0a5d2873e
hcl: identifiers can have '-'
2014-08-28 17:03:42 -07:00
Mitchell Hashimoto
71e25b33f0
Fix broken parsing case
2014-08-28 16:56:08 -07:00
Mitchell Hashimoto
982cf1ff35
hcl: stop number if whitespace
...
/cc @sbinet - The issue was in the lexer. It was seeing:
1.2e-10
e =
As:
1.2e-10e
2014-08-22 12:29:30 -07:00
Sebastien Binet
8438e17f49
all: first stab to full scientific notation support
2014-08-22 10:34:03 +02:00
Mitchell Hashimoto
26239b8eab
hcl: support heredocs [GH-6]
2014-08-21 14:54:13 -07:00
Mitchell Hashimoto
f65d314d58
hcl: support variable interpolations for compat with libucl
2014-08-21 14:38:45 -07:00
Mitchell Hashimoto
b9f494b747
hcl: support scientific notation
2014-08-21 11:29:33 -07:00
Mitchell Hashimoto
b699557f16
Decode into proper arrays of things, add many test cases
...
/cc @armon - This changes how Consul has to define its structure. Ping
me tomorrow to learn more, but going to leave it here for reference too:
The Consul case (there is a test case) never worked even with go-libucl,
because there is an ambiguity of whether you want the inner children or
the array of outer elements (the slice in the Policy struct).
I've added a new modifier you can specify with a tag called "expand"
which will tell hcl to expand the value to its children for decoding.
You can see me use it in the test case which verifies that the Consul
ACLs parse.
2014-08-17 23:50:44 -07:00
Mitchell Hashimoto
1a9d040ea4
Support Elem on lists
2014-08-11 21:33:44 -07:00
Mitchell Hashimoto
bf89042e7b
hcl: Elem on nil should return nil
2014-08-11 21:11:00 -07:00
Mitchell Hashimoto
99d585c297
Tests pass.
2014-08-11 20:58:20 -07:00
Mitchell Hashimoto
719a177dba
decoding structs a bit
2014-08-11 16:51:52 -07:00
Mitchell Hashimoto
a3b46cc5d6
hcl: use new Object structure
2014-08-11 16:13:24 -07:00
Mitchell Hashimoto
61bd5db85c
Fix consul test case
2014-08-08 15:16:42 -07:00
Mitchell Hashimoto
a9d6287a6e
hcl: support empty lists
2014-08-04 22:45:47 -07:00
Mitchell Hashimoto
0d84234df1
hcl: support booleans
2014-08-04 22:23:11 -07:00
Mitchell Hashimoto
398c583f25
hcl,json: fix list and object ordering
2014-08-04 21:53:39 -07:00
Mitchell Hashimoto
33c2953c5b
hcl: set the key
2014-08-04 09:27:50 -07:00
Mitchell Hashimoto
481bfbf3c0
hcl: continue to simplify hcl ast
2014-08-03 22:02:57 -07:00
Mitchell Hashimoto
783acc2aa1
ObjectNodes can only have assignments
2014-08-03 21:56:50 -07:00
Mitchell Hashimoto
8c0a6c555f
hcl: negative numbers and floats
2014-08-03 17:33:29 -07:00
Mitchell Hashimoto
42dabeb54f
hcl: remove the tests for AST structure
2014-08-03 13:43:34 -07:00
Mitchell Hashimoto
b2ba9e7b3e
Decode structures
2014-08-02 16:07:54 -07:00
Mitchell Hashimoto
59e0ca9d5a
Start the decoder
2014-08-02 15:44:45 -07:00
Mitchell Hashimoto
d5f339015f
hcl package for hcl parsing
2014-08-02 11:41:10 -07:00