1 #ifndef MSP_GL_SL_PARSER_H_
2 #define MSP_GL_SL_PARSER_H_
8 #include <msp/io/base.h>
41 std::string source_name;
42 unsigned source_index;
43 unsigned current_line;
44 std::string::const_iterator iter;
45 std::string::const_iterator source_end;
46 bool allow_preprocess;
47 bool allow_stage_change;
48 std::string last_token;
49 std::deque<std::string> next_tokens;
52 std::set<std::string> declared_types;
54 static Operator operators[];
60 Module &parse(const std::string &, const std::string &, unsigned = 0);
61 Module &parse(IO::Base &, const std::string &, unsigned = 0);
66 std::string format_error(const std::string &);
67 std::string format_syntax_error(const std::string &);
69 const std::string &peek_token(unsigned = 0);
70 const std::string &parse_token();
71 std::string parse_token_();
72 std::string parse_identifier();
73 std::string parse_number();
74 std::string parse_other();
75 void skip_comment_and_whitespace();
76 void expect(const std::string &);
77 std::string expect_type();
78 std::string expect_identifier();
79 bool check(const std::string &);
81 static bool is_interface_qualifier(const std::string &);
82 static bool is_sampling_qualifier(const std::string &);
83 static bool is_interpolation_qualifier(const std::string &);
84 static bool is_precision_qualifier(const std::string &);
85 static bool is_qualifier(const std::string &);
86 static bool is_builtin_type(const std::string &);
87 bool is_type(const std::string &);
88 bool is_identifier(const std::string &);
91 void preprocess_version();
92 void preprocess_pragma();
93 void preprocess_pragma_msp();
94 void preprocess_stage();
96 RefPtr<Statement> parse_global_declaration();
97 RefPtr<Statement> parse_statement();
98 RefPtr<Import> parse_import();
99 RefPtr<Precision> parse_precision();
100 RefPtr<Layout> parse_layout();
101 void parse_block(Block &, bool);
102 RefPtr<Expression> parse_expression(unsigned = 0);
103 RefPtr<BinaryExpression> parse_binary(const RefPtr<Expression> &, const Operator *);
104 RefPtr<FunctionCall> parse_function_call(const VariableReference &);
105 RefPtr<StructDeclaration> parse_struct_declaration();
106 RefPtr<VariableDeclaration> parse_variable_declaration();
107 RefPtr<FunctionDeclaration> parse_function_declaration();
108 RefPtr<InterfaceBlock> parse_interface_block();
109 RefPtr<Conditional> parse_conditional();
110 RefPtr<Iteration> parse_for();
111 RefPtr<Iteration> parse_while();
112 RefPtr<Passthrough> parse_passthrough();
113 RefPtr<Return> parse_return();