23 Commits

Author SHA1 Message Date
Florian Forster
c2326d41d7 Fix handling of line comments in multi-line statements. 2018-04-03 19:39:12 +02:00
Mikael Olenfalk
8f6b1344a9 Return PosError instead of error in more cases 2017-08-25 10:13:36 -07:00
James Bardin
a4b07c25de Merge pull request #173 from hashicorp/jbardin/crlf
Remove CRLF line endings
2017-05-04 15:02:34 -04:00
Mitchell Hashimoto
08c7efd78d
hcl/parser: parse list of lists 2017-01-30 13:05:20 -08:00
Mitchell Hashimoto
e59762bcc7
hcl/parser: support bools in lists 2017-01-19 17:06:02 -08:00
James Bardin
a97a4ff95f No longer preserve CRLF line endings
Matching the behavior of Go tooling, we are going to accept "\r\n" line
endings, but standaradize on "\n" being the official format.

Normalize line endings to "\n in the Parse function, so that we
never get stray "\r" characters in the source.
2016-12-01 12:09:33 -05:00
Mitchell Hashimoto
6000b27b60
hcl/parser: don't print "illegal"
We shouldn't output any text during parsing, that's just strange!

token.ILLEGAL happens when the scanner has an error. This error is
recorded in `scerr` during parsing which is eventually returned out.
Therefore, we handle the error properly. We can simply return a backup
error here in case we don't (scanner errors are checked first).
2016-11-30 12:55:04 -08: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
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
50042432b0
hcl/parser: fix broken parsing of: "v=/\n[," 2016-06-21 13:21:48 -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
1c284ec98f Parser enforces closing RBRACE [GH-88] 2016-02-10 10:31:11 -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
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
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