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::const_iterator source_end;
44 bool allow_preprocess;
45 bool allow_stage_change;
46 std::string last_token;
47 std::deque<std::string> next_tokens;
48 ProgramSyntax::Module *module;
49 ProgramSyntax::Stage *cur_stage;
50 std::set<std::string> declared_types;
52 static Operator operators[];
58 ProgramSyntax::Module &parse(const std::string &, const std::string &);
59 ProgramSyntax::Module &parse(IO::Base &, const std::string &);
64 std::string format_error(const std::string &);
65 std::string format_syntax_error(const std::string &);
67 const std::string &peek_token(unsigned = 0);
68 const std::string &parse_token();
69 std::string parse_token_();
70 std::string parse_identifier();
71 std::string parse_number();
72 std::string parse_other();
73 void skip_comment_and_whitespace();
74 void expect(const std::string &);
75 std::string expect_type();
76 std::string expect_identifier();
77 bool check(const std::string &);
79 static bool is_interface_qualifier(const std::string &);
80 static bool is_sampling_qualifier(const std::string &);
81 static bool is_interpolation_qualifier(const std::string &);
82 static bool is_precision_qualifier(const std::string &);
83 static bool is_qualifier(const std::string &);
84 static bool is_builtin_type(const std::string &);
85 bool is_type(const std::string &);
86 bool is_identifier(const std::string &);
89 void preprocess_pragma();
90 void preprocess_pragma_msp();
91 void preprocess_stage();
93 RefPtr<ProgramSyntax::Node> parse_global_declaration();
94 RefPtr<ProgramSyntax::Node> parse_statement();
95 RefPtr<ProgramSyntax::Import> parse_import();
96 RefPtr<ProgramSyntax::Precision> parse_precision();
97 RefPtr<ProgramSyntax::Layout> parse_layout();
98 void parse_block(ProgramSyntax::Block &, bool);
99 RefPtr<ProgramSyntax::Expression> parse_expression(unsigned = 0);
100 RefPtr<ProgramSyntax::BinaryExpression> parse_binary(const RefPtr<ProgramSyntax::Expression> &, const Operator *);
101 RefPtr<ProgramSyntax::FunctionCall> parse_function_call(const ProgramSyntax::VariableReference &);
102 RefPtr<ProgramSyntax::StructDeclaration> parse_struct_declaration();
103 RefPtr<ProgramSyntax::VariableDeclaration> parse_variable_declaration();
104 RefPtr<ProgramSyntax::FunctionDeclaration> parse_function_declaration();
105 RefPtr<ProgramSyntax::InterfaceBlock> parse_interface_block();
106 RefPtr<ProgramSyntax::Conditional> parse_conditional();
107 RefPtr<ProgramSyntax::Iteration> parse_iteration();
108 RefPtr<ProgramSyntax::Passthrough> parse_passthrough();
109 RefPtr<ProgramSyntax::Return> parse_return();