Rule* processRuleFile(Arguments *args) { int rules_number; Rule *rules; rules_number = countRules(args->input_file); rules = malloc(sizeof(Rule)*rules_number); initPass(args->input_file, rules, rules_number); finalPass(args->input_file, rules, rules_number); fclose(args->input_file); return rules; }
void ParseTreeTraverser::finalPass(Node* tree) { switch(tree->node_type) { case NT_PROGRAM: if(!passesForCompilation()) return; finalPass(tree->node_data.nodes[0]); if(tree->subnodes > 1) finalPass(tree->node_data.nodes[1]); if(tree->subnodes > 2) finalPass(tree->node_data.nodes[2]); break; case NT_CLASSSET: { int i = 0; while(i < tree->subnodes) { finalPass(tree->node_data.nodes[i]); i++; } } break; case NT_ANNOTATED_CLASS: finalPass(tree->node_data.nodes[0]); break; case NT_CLASS: case NT_CLASS_EXTERN: { PureType<wake::UNQUALIFIED>* classtype = tree->node_data.nodes[0]->node_data.pure_type; string classname = classtype->typedata._class.classname; errors.pushContext("In declaration of '" + string(tree->node_type == NT_CLASS ? "every" : "extern") + " " + classname + "'"); ClassParseTreeTraverser classtraverser(&errors, objectsymtable, &scopesymtable, objectsymtable->findByImportedNameModifiable(classname)->getAsPureType()->getFQClassname(), &typechecker, &methodanalyzer, objectsymtable->findByImportedNameModifiable(classname), tree->node_type == NT_CLASS_EXTERN); finalPass(tree->node_data.nodes[1]); if(tree->subnodes > 2) classtraverser.secondPass(tree->node_data.nodes[2]); errors.popContext(); } break; } }