From 1470fed809be7b11f147f8a6ca924a252b473c97 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 22 Aug 2009 10:24:18 +0200 Subject: Implement the CLI language parser --- cli/parser.hxx | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 cli/parser.hxx (limited to 'cli/parser.hxx') diff --git a/cli/parser.hxx b/cli/parser.hxx new file mode 100644 index 0000000..d1f4b4b --- /dev/null +++ b/cli/parser.hxx @@ -0,0 +1,60 @@ +// file : cli/parser.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#ifndef CLI_PARSER_HXX +#define CLI_PARSER_HXX + +#include +#include + +class Token; +class Lexer; + +class Parser +{ +public: + struct InvalidInput {}; + + void + parse (std::istream& is, std::string const& id); + +private: + struct Error {}; + + void + def_unit (); + + void + include_decl (); + + bool + decl (Token&); + + void + namespace_def (); + + void + class_def (); + + bool + option_def (Token&); + + bool + qualified_name (Token&); + + bool + fundamental_type (Token&); + +private: + void + recover (Token& t); + +private: + bool valid_; + Lexer* lexer_; + std::string const* id_; +}; + +#endif // CLI_PARSER_HXX -- cgit v1.1