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 ModuleCache *mod_cache;
25 Preprocessor preprocessor;
26 bool allow_stage_change;
28 std::vector<const Module *> imported_modules;
30 std::set<std::string> global_types;
31 std::set<std::string> stage_types;
32 std::vector<std::string> errors;
33 RefPtr<Statement> next_global_declaration;
36 Parser(ModuleCache *);
38 void parse(Module &, const std::string &, const std::string &, int);
39 void parse(Module &, IO::Base &, const std::string &, int);
42 void parse_source(const std::string &, int);
43 void set_required_version(const Version &);
44 void source_reference(unsigned, const std::string &);
45 void stage_change(Stage::Type);
46 void line_change(int, unsigned);
48 std::string expect_type();
49 std::string expect_identifier();
51 bool check(const std::string &);
53 static bool is_interface_qualifier(const std::string &);
54 static bool is_sampling_qualifier(const std::string &);
55 static bool is_interpolation_qualifier(const std::string &);
56 static bool is_precision_qualifier(const std::string &);
57 static bool is_qualifier(const std::string &);
58 bool is_type(const std::string &);
59 bool is_identifier(const std::string &);
62 void preprocess_version();
63 void preprocess_pragma();
64 void preprocess_pragma_msp();
65 void preprocess_stage();
68 RefPtr<T> create_node();
70 RefPtr<T> parse_with_recovery(RefPtr<T> (Parser::*)());
71 RefPtr<Statement> parse_global_declaration();
72 RefPtr<Statement> parse_statement();
73 RefPtr<Import> parse_import();
74 RefPtr<Precision> parse_precision();
75 RefPtr<Layout> parse_layout();
77 void parse_block(Block &, bool, RefPtr<T> (Parser::*)());
78 RefPtr<Expression> parse_expression(const Operator * = 0);
79 RefPtr<Literal> parse_literal();
80 RefPtr<BinaryExpression> parse_binary(const RefPtr<Expression> &, const Operator &);
81 RefPtr<TernaryExpression> parse_ternary(const RefPtr<Expression> &, const Operator &);
82 RefPtr<FunctionCall> parse_function_call(const VariableReference &);
83 void add_type(TypeDeclaration &);
84 RefPtr<TypeDeclaration> parse_type_declaration();
85 RefPtr<BasicTypeDeclaration> parse_basic_type_declaration();
86 RefPtr<ImageTypeDeclaration> parse_image_type_declaration();
87 RefPtr<StructDeclaration> parse_struct_declaration();
88 RefPtr<VariableDeclaration> parse_variable_declaration();
89 RefPtr<VariableDeclaration> parse_variable_declaration_with_layout();
90 RefPtr<FunctionDeclaration> parse_function_declaration();
91 RefPtr<StructDeclaration> parse_interface_block();
92 RefPtr<Conditional> parse_conditional();
93 RefPtr<Iteration> parse_for();
94 RefPtr<Iteration> parse_while();
95 RefPtr<Passthrough> parse_passthrough();
96 RefPtr<Return> parse_return();