target = &*i;
}
+ if(stage.required_version>target->required_version)
+ target->required_version = stage.required_version;
for(NodeList<Statement>::iterator i=stage.content.body.begin(); i!=stage.content.body.end(); ++i)
target->content.body.push_back(*i);
apply<DeclarationCombiner>(*target);
void ProgramCompiler::generate(Stage &stage)
{
+ if(module->shared.required_version>stage.required_version)
+ stage.required_version = module->shared.required_version;
inject_block(stage.content, module->shared.content);
apply<DeclarationReorderer>(stage);
string token = peek_token();
if(token=="pragma")
preprocess_pragma();
+ else if(token=="version")
+ preprocess_version();
else if(token=="define" || token=="undef" || token=="if" || token=="ifdef" || token=="ifndef" || token=="else" ||
- token=="elif" || token=="endif" || token=="error" || token=="extension" || token=="version" || token=="line")
+ token=="elif" || token=="endif" || token=="error" || token=="extension" || token=="line")
throw runtime_error(format_error(format("Unsupported preprocessor directive '%s'", token)));
else if(!token.empty())
throw runtime_error(format_syntax_error("a preprocessor directive"));
iter = line_end;
}
+void ProgramParser::preprocess_version()
+{
+ expect("version");
+ string token = parse_token();
+ unsigned version = lexical_cast<unsigned>(token);
+ cur_stage->required_version = Version(version/100, version%100);
+
+ token = parse_token();
+ if(!token.empty())
+ throw runtime_error(format_syntax_error("end of line"));
+}
+
void ProgramParser::preprocess_pragma()
{
expect("pragma");
bool is_identifier(const std::string &);
void preprocess();
+ void preprocess_version();
void preprocess_pragma();
void preprocess_pragma_msp();
void preprocess_stage();