--- /dev/null
+#ifndef MSP_GL_PROGRAMPARSER_H_
+#define MSP_GL_PROGRAMPARSER_H_
+
+#include <deque>
+#include <map>
+#include <string>
+#include <msp/io/base.h>
+#include "programsyntax.h"
+
+namespace Msp {
+namespace GL {
+
+class ProgramParser
+{
+private:
+ std::string source;
+ std::string::const_iterator iter;
+ std::deque<std::string> next_tokens;
+ ProgramSyntax::Module main_module;
+ ProgramSyntax::Module *cur_module;
+
+public:
+ ProgramSyntax::Module &parse(const std::string &);
+ ProgramSyntax::Module &parse(IO::Base &);
+
+private:
+ void parse_source(ProgramSyntax::Module &);
+
+ const std::string &peek_token(unsigned = 0);
+ std::string parse_token();
+ std::string parse_token_();
+ std::string parse_identifier();
+ std::string parse_number();
+ std::string parse_other();
+ bool skip_comment_and_whitespace();
+ void expect(const std::string &);
+ std::string expect_type();
+ std::string expect_identifier();
+ bool check(const std::string &);
+
+ static bool is_interface_qualifier(const std::string &);
+ static bool is_sampling_qualifier(const std::string &);
+ static bool is_qualifier(const std::string &);
+ static bool is_builtin_type(const std::string &);
+ bool is_type(const std::string &);
+
+ ProgramSyntax::Node *parse_global_declaration();
+ ProgramSyntax::Node *parse_statement();
+ ProgramSyntax::Layout *parse_layout();
+ void parse_block(ProgramSyntax::Block &, bool);
+ void parse_expression(ProgramSyntax::Expression &);
+ ProgramSyntax::StructDeclaration *parse_struct_declaration();
+ ProgramSyntax::VariableDeclaration *parse_variable_declaration();
+ ProgramSyntax::FunctionDeclaration *parse_function_declaration();
+ void parse_function_parameter_list(ProgramSyntax::FunctionDeclaration &);
+ ProgramSyntax::InterfaceBlock *parse_interface_block();
+ ProgramSyntax::Conditional *parse_conditional();
+ ProgramSyntax::Iteration *parse_iteration();
+ ProgramSyntax::Return *parse_return();
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif