+RefPtr<Import> ProgramParser::parse_import()
+{
+ if(cur_stage->type!=SHARED)
+ throw runtime_error("Imports are only allowed in the shared section");
+
+ expect("import");
+ RefPtr<Import> import = new Import;
+ import->module = parse_token();
+ expect(";");
+ return import;
+}
+
+RefPtr<Precision> ProgramParser::parse_precision()
+{
+ expect("precision");
+ RefPtr<Precision> precision = new Precision;
+
+ precision->precision = parse_token();
+ if(!is_precision_qualifier(precision->precision))
+ throw runtime_error(format("Parse error at '%s': expected a precision qualifier", precision->precision));
+
+ precision->type = parse_token();
+ // Not entirely accurate; only float, int and sampler types are allowed
+ if(!is_builtin_type(precision->type))
+ throw runtime_error(format("Parse error at '%s': expected a builtin type", precision->type));
+
+ expect(";");
+
+ return precision;
+}
+
+RefPtr<Layout> ProgramParser::parse_layout()