1 #ifndef MSP_GL_SL_PARSER_H_
2 #define MSP_GL_SL_PARSER_H_
6 #include <msp/io/base.h>
7 #include "preprocessor.h"
20 unsigned source_index;
22 Preprocessor preprocessor;
23 bool allow_stage_change;
26 std::set<std::string> declared_types;
27 std::vector<std::string> errors;
33 Module &parse(const std::string &, const std::string &, unsigned = 0);
34 Module &parse(IO::Base &, const std::string &, unsigned = 0);
37 void parse_source(const std::string &, unsigned);
38 void set_required_version(const Version &);
39 void source_reference(unsigned, const std::string &);
40 void stage_change(Stage::Type);
41 void line_change(int, unsigned);
43 std::string expect_type();
44 std::string expect_identifier();
46 bool check(const std::string &);
48 static bool is_interface_qualifier(const std::string &);
49 static bool is_sampling_qualifier(const std::string &);
50 static bool is_interpolation_qualifier(const std::string &);
51 static bool is_precision_qualifier(const std::string &);
52 static bool is_qualifier(const std::string &);
53 static bool is_builtin_type(const std::string &);
54 bool is_type(const std::string &);
55 bool is_identifier(const std::string &);
58 void preprocess_version();
59 void preprocess_pragma();
60 void preprocess_pragma_msp();
61 void preprocess_stage();
63 RefPtr<Statement> parse_global_declaration();
65 RefPtr<T> parse_with_recovery(RefPtr<T> (Parser::*)());
66 RefPtr<Statement> parse_statement();
67 RefPtr<Import> parse_import();
68 RefPtr<Precision> parse_precision();
69 RefPtr<Layout> parse_layout();
71 void parse_block(Block &, bool, RefPtr<T> (Parser::*)());
72 RefPtr<Expression> parse_expression(unsigned = 0);
73 RefPtr<BinaryExpression> parse_binary(const RefPtr<Expression> &, const Operator *);
74 RefPtr<FunctionCall> parse_function_call(const VariableReference &);
75 RefPtr<StructDeclaration> parse_struct_declaration();
76 RefPtr<VariableDeclaration> parse_variable_declaration();
77 RefPtr<VariableDeclaration> parse_variable_declaration_with_layout();
78 RefPtr<FunctionDeclaration> parse_function_declaration();
79 RefPtr<InterfaceBlock> parse_interface_block();
80 RefPtr<Conditional> parse_conditional();
81 RefPtr<Iteration> parse_for();
82 RefPtr<Iteration> parse_while();
83 RefPtr<Passthrough> parse_passthrough();
84 RefPtr<Return> parse_return();