125 Commits

Author SHA1 Message Date
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