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;
29 std::set<std::string> declared_types;
30 std::vector<std::string> errors;
33 Parser(ModuleCache *);
35 void parse(Module &, const std::string &, const std::string &, int);
36 void parse(Module &, IO::Base &, const std::string &, int);
39 void parse_source(const std::string &, int);
40 void set_required_version(const Version &);
41 void source_reference(unsigned, const std::string &);
42 void stage_change(Stage::Type);
43 void line_change(int, unsigned);
45 std::string expect_type();
46 std::string expect_identifier();
48 bool check(const std::string &);
50 static bool is_interface_qualifier(const std::string &);
51 static bool is_sampling_qualifier(const std::string &);
52 static bool is_interpolation_qualifier(const std::string &);
53 static bool is_precision_qualifier(const std::string &);
54 static bool is_qualifier(const std::string &);
55 bool is_type(const std::string &);
56 bool is_identifier(const std::string &);
59 void preprocess_version();
60 void preprocess_pragma();
61 void preprocess_pragma_msp();
62 void preprocess_stage();
65 RefPtr<T> create_node();
67 RefPtr<T> parse_with_recovery(RefPtr<T> (Parser::*)());
68 RefPtr<Statement> parse_global_declaration();
69 RefPtr<Statement> parse_statement();
70 RefPtr<Import> parse_import();
71 RefPtr<Precision> parse_precision();
72 RefPtr<Layout> parse_layout();
74 void parse_block(Block &, bool, RefPtr<T> (Parser::*)());
75 RefPtr<Expression> parse_expression(const Operator * = 0);
76 RefPtr<Literal> parse_literal();
77 RefPtr<BinaryExpression> parse_binary(const RefPtr<Expression> &, const Operator &);
78 RefPtr<TernaryExpression> parse_ternary(const RefPtr<Expression> &, const Operator &);
79 RefPtr<FunctionCall> parse_function_call(const VariableReference &);
80 RefPtr<TypeDeclaration> parse_type_declaration();
81 RefPtr<BasicTypeDeclaration> parse_basic_type_declaration();
82 RefPtr<ImageTypeDeclaration> parse_image_type_declaration();
83 RefPtr<StructDeclaration> parse_struct_declaration();
84 RefPtr<VariableDeclaration> parse_variable_declaration();
85 RefPtr<VariableDeclaration> parse_variable_declaration_with_layout();
86 RefPtr<FunctionDeclaration> parse_function_declaration();
87 RefPtr<InterfaceBlock> parse_interface_block();
88 RefPtr<Conditional> parse_conditional();
89 RefPtr<Iteration> parse_for();
90 RefPtr<Iteration> parse_while();
91 RefPtr<Passthrough> parse_passthrough();
92 RefPtr<Return> parse_return();