aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-20 15:54:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:34 +0200
commit45a0995457ceaf806970cf2a8e9f7001e3236ed4 (patch)
tree86cb5ed8fa3974160e08aca73969fc5ea8da66ef
parent64f4dafa5e859d339d48526ac5373e5e122c298b (diff)
Fix pre-parsing corner cases
-rw-r--r--build2/test/script/lexer.cxx6
-rw-r--r--unit-tests/test/script/parser/pre-parse.test15
2 files changed, 18 insertions, 3 deletions
diff --git a/build2/test/script/lexer.cxx b/build2/test/script/lexer.cxx
index d2657c6..01c93a4 100644
--- a/build2/test/script/lexer.cxx
+++ b/build2/test/script/lexer.cxx
@@ -15,7 +15,7 @@ namespace build2
using type = token_type;
void lexer::
- mode (base_mode m, char)
+ mode (base_mode m, char ps)
{
const char* s1 (nullptr);
const char* s2 (nullptr);
@@ -69,9 +69,9 @@ namespace build2
}
default:
{
- // Disable pair separator.
+ // Disable pair separator except for attributes.
//
- base_lexer::mode (m, '\0');
+ base_lexer::mode (m, m != lexer_mode::attribute ? '\0' : ps);
return;
}
}
diff --git a/unit-tests/test/script/parser/pre-parse.test b/unit-tests/test/script/parser/pre-parse.test
new file mode 100644
index 0000000..4057f9a
--- /dev/null
+++ b/unit-tests/test/script/parser/pre-parse.test
@@ -0,0 +1,15 @@
+# attribute-pair
+#
+$* <<EOI 2>>EOE != 0
+x = [foo=bar]
+EOI
+testscript:1:5: error: unknown value attribute foo=bar
+EOE
+
+# attribute-pair-empty
+#
+$* <<EOI 2>>EOE != 0
+x = [foo=]
+EOI
+testscript:1:5: error: unknown value attribute foo
+EOE