1 #ifndef MSP_GL_PROGRAMPARSER_H_
2 #define MSP_GL_PROGRAMPARSER_H_
8 #include <msp/io/base.h>
9 #include "programsyntax.h"
40 std::string source_name;
41 unsigned current_line;
42 std::string::const_iterator iter;
43 std::string last_token;
44 std::deque<std::string> next_tokens;
45 ProgramSyntax::Module *module;
46 ProgramSyntax::Stage *cur_stage;
47 std::set<std::string> declared_types;
49 static Operator operators[];
55 ProgramSyntax::Module &parse(const std::string &, const std::string &);
56 ProgramSyntax::Module &parse(IO::Base &, const std::string &);
61 std::string format_error(const std::string &);
62 std::string format_syntax_error(const std::string &);
64 const std::string &peek_token(unsigned = 0);
65 const std::string &parse_token();
66 std::string parse_token_();
67 std::string parse_identifier();
68 std::string parse_number();
69 std::string parse_other();
70 bool skip_comment_and_whitespace();
71 void expect(const std::string &);
72 std::string expect_type();
73 std::string expect_identifier();
74 bool check(const std::string &);
76 static bool is_interface_qualifier(const std::string &);
77 static bool is_sampling_qualifier(const std::string &);
78 static bool is_precision_qualifier(const std::string &);
79 static bool is_qualifier(const std::string &);
80 static bool is_builtin_type(const std::string &);
81 bool is_type(const std::string &);
82 bool is_identifier(const std::string &);
84 RefPtr<ProgramSyntax::Node> parse_global_declaration();
85 RefPtr<ProgramSyntax::Node> parse_statement();
86 RefPtr<ProgramSyntax::Import> parse_import();
87 RefPtr<ProgramSyntax::Precision> parse_precision();
88 RefPtr<ProgramSyntax::Layout> parse_layout();
89 void parse_block(ProgramSyntax::Block &, bool);
90 RefPtr<ProgramSyntax::Expression> parse_expression(unsigned = 0);
91 RefPtr<ProgramSyntax::BinaryExpression> parse_binary(const RefPtr<ProgramSyntax::Expression> &, const Operator *);
92 RefPtr<ProgramSyntax::FunctionCall> parse_function_call(const ProgramSyntax::VariableReference &);
93 RefPtr<ProgramSyntax::StructDeclaration> parse_struct_declaration();
94 RefPtr<ProgramSyntax::VariableDeclaration> parse_variable_declaration();
95 RefPtr<ProgramSyntax::FunctionDeclaration> parse_function_declaration();
96 RefPtr<ProgramSyntax::InterfaceBlock> parse_interface_block();
97 RefPtr<ProgramSyntax::Conditional> parse_conditional();
98 RefPtr<ProgramSyntax::Iteration> parse_iteration();
99 RefPtr<ProgramSyntax::Passthrough> parse_passthrough();
100 RefPtr<ProgramSyntax::Return> parse_return();