};
std::string source;
+ std::string source_name;
+ unsigned current_line;
std::string::const_iterator iter;
+ std::string::const_iterator source_end;
+ bool allow_preprocess;
+ bool allow_stage_change;
+ std::string last_token;
std::deque<std::string> next_tokens;
ProgramSyntax::Module *module;
ProgramSyntax::Stage *cur_stage;
ProgramParser();
~ProgramParser();
- ProgramSyntax::Module &parse(const std::string &);
- ProgramSyntax::Module &parse(IO::Base &);
+ ProgramSyntax::Module &parse(const std::string &, const std::string &);
+ ProgramSyntax::Module &parse(IO::Base &, const std::string &);
private:
void parse_source();
+ std::string format_error(const std::string &);
+ std::string format_syntax_error(const std::string &);
+
const std::string &peek_token(unsigned = 0);
- std::string parse_token();
+ const std::string &parse_token();
std::string parse_token_();
std::string parse_identifier();
std::string parse_number();
std::string parse_other();
- bool skip_comment_and_whitespace();
+ void skip_comment_and_whitespace();
void expect(const std::string &);
std::string expect_type();
std::string expect_identifier();
static bool is_interface_qualifier(const std::string &);
static bool is_sampling_qualifier(const std::string &);
+ static bool is_interpolation_qualifier(const std::string &);
+ static bool is_precision_qualifier(const std::string &);
static bool is_qualifier(const std::string &);
static bool is_builtin_type(const std::string &);
bool is_type(const std::string &);
bool is_identifier(const std::string &);
+ void preprocess();
+ void preprocess_pragma();
+ void preprocess_pragma_msp();
+ void preprocess_stage();
+
RefPtr<ProgramSyntax::Node> parse_global_declaration();
RefPtr<ProgramSyntax::Node> parse_statement();
RefPtr<ProgramSyntax::Import> parse_import();
+ RefPtr<ProgramSyntax::Precision> parse_precision();
RefPtr<ProgramSyntax::Layout> parse_layout();
void parse_block(ProgramSyntax::Block &, bool);
RefPtr<ProgramSyntax::Expression> parse_expression(unsigned = 0);