aboutsummaryrefslogtreecommitdiff
path: root/build2/test/script/parser
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-12 14:53:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 08:29:23 +0200
commit18ce15f3aee71debe3f35356c6a739943815da8a (patch)
tree828dea05101c11c5b0b6974b25447226db37debf /build2/test/script/parser
parentf423dbc95239cc88021d5d332ad19eeecc6e11e8 (diff)
Initial work on testscript lexer/parser
Diffstat (limited to 'build2/test/script/parser')
-rw-r--r--build2/test/script/parser67
1 files changed, 67 insertions, 0 deletions
diff --git a/build2/test/script/parser b/build2/test/script/parser
new file mode 100644
index 0000000..720a077
--- /dev/null
+++ b/build2/test/script/parser
@@ -0,0 +1,67 @@
+// file : build2/test/script/parser -*- C++ -*-
+// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#ifndef BUILD2_TEST_SCRIPT_PARSER
+#define BUILD2_TEST_SCRIPT_PARSER
+
+#include <build2/types>
+#include <build2/utility>
+
+#include <build2/parser>
+#include <build2/diagnostics>
+
+#include <build2/test/script/token>
+#include <build2/test/script/script>
+
+namespace build2
+{
+ namespace test
+ {
+ namespace script
+ {
+ class lexer;
+
+ class parser: protected build2::parser
+ {
+ public:
+ using script_type = test::script::script;
+
+ // Issue diagnostics and throw failed in case of an error.
+ //
+ script_type
+ parse (istream&, const path& name, target& test, target& script);
+
+ // Recursive descent parser.
+ //
+ // Each parse function receives the token/type from which it should
+ // start consuming. On return the token/type should contain the first
+ // token that has not been consumed.
+ //
+ protected:
+ void
+ script (token&, token_type&);
+
+ void
+ script_line (token&, token_type&);
+
+ void
+ variable_line (token&, token_type&, string);
+
+ void
+ test_line (token&, token_type&, names_type, location);
+
+ void
+ command_exit (token&, token_type&);
+
+ protected:
+ using base_parser = build2::parser;
+
+ lexer* lexer_;
+ script_type* script_;
+ };
+ }
+ }
+}
+
+#endif // BUILD2_TEST_SCRIPT_PARSER