From 12d49acb7f2e48b1d18c08c22992e6aa09863732 Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Fri, 26 Feb 2016 13:41:23 -0500 Subject: [PATCH] Fix bug: syntax error with list with no ending semicolon This bug was caused when a list with no ending semicolon was followed directly by another setting. We were eating the next token after a list, which if it was a newline, means when we go to check that the next value is a newline or semicolon, we get a syntax error. Resolves #29 --- forge_test.go | 7 +++++++ parser.go | 1 + test.cfg | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/forge_test.go b/forge_test.go index 1d8a3a7..143f9cc 100644 --- a/forge_test.go +++ b/forge_test.go @@ -42,6 +42,13 @@ primary { key = "primary sub key value"; include "./test_include.cfg"; } + + sub_section { + # Testing of a special case that had previous caused failures + # Was caused by an array with no ending semicolon, followed directly by another setting + nested_array_no_semi_colon = ["a", "b"] + another = true + } } secondary { diff --git a/parser.go b/parser.go index fbf800f..08609e7 100644 --- a/parser.go +++ b/parser.go @@ -193,6 +193,7 @@ func (parser *Parser) parseSettingValue() (Value, error) { } value = NewList() value.UpdateValue(listVal) + readNext = false default: return value, parser.syntaxError( fmt.Sprintf("expected STRING, INTEGER, FLOAT, BOOLEAN or IDENTIFIER, instead found %s", parser.curTok.ID), diff --git a/test.cfg b/test.cfg index 1c6b94e..94a2e3a 100644 --- a/test.cfg +++ b/test.cfg @@ -31,6 +31,13 @@ primary { key = "primary sub key value"; include "./test_include.cfg"; } + + sub_section { + # Testing of a special case that had previous caused failures + # Was caused by an array with no ending semicolon, followed directly by another setting + nested_array_no_semi_colon = ["a", "b"] + another = true + } } secondary {