From 256bb51ed8e806e2edbf485525bf4180f0ecfa07 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 17 Dec 2014 11:39:45 -0800 Subject: [PATCH] hcl: support "." in identifier --- hcl/lex.go | 3 ++- hcl/lex_test.go | 4 ++++ hcl/test-fixtures/complex_key.hcl | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 hcl/test-fixtures/complex_key.hcl diff --git a/hcl/lex.go b/hcl/lex.go index c3ccd4b..e0c96b1 100644 --- a/hcl/lex.go +++ b/hcl/lex.go @@ -193,7 +193,8 @@ func (x *hclLex) lexId(yylval *hclSymType) int { break } - if !unicode.IsDigit(c) && !unicode.IsLetter(c) && c != '_' && c != '-' { + if !unicode.IsDigit(c) && !unicode.IsLetter(c) && + c != '_' && c != '-' && c != '.' { x.backup() if first { diff --git a/hcl/lex_test.go b/hcl/lex_test.go index f9ab5cc..dcdd9b3 100644 --- a/hcl/lex_test.go +++ b/hcl/lex_test.go @@ -20,6 +20,10 @@ func TestLex(t *testing.T) { "comment_single.hcl", []int{lexEOF}, }, + { + "complex_key.hcl", + []int{IDENTIFIER, EQUAL, STRING, lexEOF}, + }, { "multiple.hcl", []int{ diff --git a/hcl/test-fixtures/complex_key.hcl b/hcl/test-fixtures/complex_key.hcl new file mode 100644 index 0000000..0007aaf --- /dev/null +++ b/hcl/test-fixtures/complex_key.hcl @@ -0,0 +1 @@ +foo.bar = "baz"