29 Commits

Author SHA1 Message Date
Mitchell Hashimoto
d02cd46b72
hcl: error if we scan a null char before end of input text
This was allowing very strange input to be allowed through to Terraform
since some encryped output will contain null characters (such as from
git crypt).
2016-11-21 18:09:54 -08:00
Mark Pim
fb052f74db Remove duplicate unit test 2016-11-12 19:14:56 +00:00
Mitchell Hashimoto
57bf849243
hcl/parser: cleaner error handling for objects with empty keys #158
The way that the contents of an object (objectList()) was parsed before
was weirdly implicit in expecting RBRACE as the ending token. This makes
that expectation explicit, which fixes a parse error that could occur
with an object that ends in an empty assign to an RBRACE.

Before this, the parser would accept this as expected behavior because
the object "ended" since the unexpected token was an RBRACE.
2016-10-18 17:36:39 -07:00
Mitchell Hashimoto
8d4635e72c
hcl/parser: literal elements in a list can have a lead comment 2016-10-08 14:40:39 +08:00
Mitchell Hashimoto
7d7bae6bc1
hcl/parser: line comment tests for list items 2016-10-08 14:33:53 +08:00
Mitchell Hashimoto
16dda36a23
hcl/printer: file with only comments formats properly 2016-10-08 11:42:34 +08:00
Mitchell Hashimoto
9250907631
hcl/scanner: single line '//' commments verify second '/'
The way the scanner works '/ foo' was actually valid comment syntax.
This obviously is not what we want. This modifies the scanner to verify
that '//' comments in fact have the second '/'.
2016-09-01 19:50:55 -07:00
Mitchell Hashimoto
baeb59c710
hcl/parser: test case for error in "10kb"
https://github.com/hashicorp/terraform/issues/3287#issuecomment-195779840
2016-08-22 14:41:45 -07:00
Paul Hinze
92237bfa68
hcl/parser: Support lists of objects
a.k.a lists of maps

Implementation was pretty straightforward - I had to tweak the `needsComma`
handling since it was stuck inside literal parsing. It happens out front
now. I also promoted the `assign_deep.hcl` parser test to a decoder
test that passes, since it was testing for an error to occur but now it
works! :)

Additionally we make ObjectLists support being comma-delimited, which
enables maps to defined inline like `{one = 1, two = 2}`.

Refs https://github.com/hashicorp/terraform/issues/7142
2016-07-06 13:01:52 -05:00
Mitchell Hashimoto
c9b6178f09
hcl/parser: remove spew 2016-06-21 13:26:05 -07:00
Mitchell Hashimoto
50042432b0
hcl/parser: fix broken parsing of: "v=/\n[," 2016-06-21 13:21:48 -07:00
Mitchell Hashimoto
6816a5c3fb
fix panic on decode of "t=0t d{}" 2016-06-21 13:18:51 -07:00
Mitchell Hashimoto
352bb4b5e3
hcl/parser: don't allow objects with no keys 2016-06-21 13:07:06 -07:00
Mitchell Hashimoto
99c4d58691 hcl/parser: better comments 2016-03-14 20:56:27 +01:00
Mitchell Hashimoto
faa2fba9b8 hcl/parser: error on bare object keys in object 2016-03-14 20:54:33 +01:00
Mitchell Hashimoto
7df3f8587e hcl/parser: test for bare key at top level 2016-03-14 20:44:57 +01:00
Mitchell Hashimoto
71c7409f1a hcl/parser: add test case from TF issue 2016-03-01 10:33:45 -08:00
Mitchell Hashimoto
1c284ec98f Parser enforces closing RBRACE [GH-88] 2016-02-10 10:31:11 -08:00
Mitchell Hashimoto
8cc8107682 hcl/parser: more negative number tests 2016-02-07 12:08:28 -08:00
Paul Hinze
3a2d43b647 Fix crash on missing braces
Fixes crash reported here https://github.com/hashicorp/terraform/issues/4350
2015-12-16 18:21:22 -06:00
James Nugent
8a65681ce2 Merge pull request #66 from hashicorp/b-heredoc-lists
Support HEREDOCs in lists
2015-11-29 11:28:44 +00:00
Eljas Alakulppi
2ec27b6be2 Fixed hang when comment was on the last line of the file 2015-11-29 00:20:41 +02:00
James Nugent
eb77c8f861 Support HEREDOCs in lists
This fixes a regression in Terraform where HEREDOCS were previously
supported in lists, reported in hashicorp/terraform#4065.
2015-11-26 14:52:16 +02: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
99ce7c7e2c parser: fix syntax error on missing comma
Fixes hashicorp/terraform#3877
2015-11-12 15:26:23 +02:00
Mitchell Hashimoto
0f965478b6 hcl/parser: parse heredocs 2015-11-10 14:03:29 -08:00
Mitchell Hashimoto
5aaa3e75b9 hcl/parser: scan errors should come through as well 2015-11-06 23:42:45 -08:00
Mitchell Hashimoto
d7c35808a8 move hclnew to hcl 2015-11-06 16:04:20 -08:00