From 835ed5f7080a98e9ee80ac08d5585ccdbb63fe0e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 15 Dec 2014 10:43:16 +0200 Subject: Parse directory scopes --- tests/.gitignore | 1 + tests/build/lexer/driver.cxx | 15 ++++----------- tests/build/parser/driver.cxx | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 tests/.gitignore (limited to 'tests') diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..e54525b --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +driver diff --git a/tests/build/lexer/driver.cxx b/tests/build/lexer/driver.cxx index e329b1c..739fa26 100644 --- a/tests/build/lexer/driver.cxx +++ b/tests/build/lexer/driver.cxx @@ -91,17 +91,10 @@ lex (const char* s) switch (t.type ()) { case token_type::eos: v= ""; break; - case token_type::punctuation: - { - switch (t.punctuation ()) - { - case token_punctuation::newline: v = "\n"; break; - case token_punctuation::colon: v = ":"; break; - case token_punctuation::lcbrace: v = "{"; break; - case token_punctuation::rcbrace: v = "}"; break; - } - break; - } + case token_type::newline: v = "\n"; break; + case token_type::colon: v = ":"; break; + case token_type::lcbrace: v = "{"; break; + case token_type::rcbrace: v = "}"; break; case token_type::name: v = t.name ().c_str (); break; } diff --git a/tests/build/parser/driver.cxx b/tests/build/parser/driver.cxx index 4ba589d..0b83cb0 100644 --- a/tests/build/parser/driver.cxx +++ b/tests/build/parser/driver.cxx @@ -45,6 +45,23 @@ main () assert (!parse ("{foo{:")); assert (!parse ("foo: bar:")); assert (!parse ("exe{foo:")); + + // Directory scope. + // + assert (parse ("test/:\n{\n}")); + assert (parse ("test/:\n{\n}\n")); + assert (parse ("test/:\n{\nfoo:bar\n}")); + assert (parse ("test/:\n{\nfoo:bar\n}")); + assert (parse ("test/:\n{\nmore/:\n{\n}\n}")); + assert (parse ("test/:\n{\nmore/:\n{\nfoo:{bar baz}\n}\n}")); + + assert (!parse ("test/:\n{")); + assert (!parse ("test/:\n{\n")); + assert (!parse ("test/:\n{\n:")); + assert (!parse ("test/:\n{\n} foo: bar\n")); + assert (!parse ("test/ foo:\n{\n}")); + assert (!parse ("test foo/:\n{\n}")); + assert (!parse ("test/ foo/:\n{\n}")); } ostream cnull (nullptr); @@ -56,6 +73,7 @@ parse (const char* s) is.exceptions (istream::failbit | istream::badbit); parser p (cnull); + //parser p (cerr); try { -- cgit v1.1