* Writes the source code files.
*
* @throws IOException if the files couldn't be written correctly
*/
public void write() throws IOException {
Grammar grammar = getGrammar();
VisualBasicConstantsFile constants;
VisualBasicTokenizerFile tokenizer;
VisualBasicParserFile parser;
VisualBasicAnalyzerFile analyzer;
TokenPattern token;
ProductionPattern production;
int i;
// Create output files
constants = new VisualBasicConstantsFile(this);
tokenizer = new VisualBasicTokenizerFile(this);
analyzer = new VisualBasicAnalyzerFile(this);
parser = new VisualBasicParserFile(this, tokenizer, analyzer);
// Create token declarations
for (i = 0; i < grammar.getTokenPatternCount(); i++) {
token = grammar.getTokenPattern(i);
constants.addToken(token);
tokenizer.addToken(token, constants);
analyzer.addToken(token, constants);
}
// Create production constants
for (i = 0; i < grammar.getProductionPatternCount(); i++) {
production = grammar.getProductionPattern(i);
constants.addProduction(production);
parser.addProductionConstant(production);
analyzer.addProduction(production, constants);
}
// Create production declarations
for (i = 0; i < grammar.getProductionPatternCount(); i++) {
production = grammar.getProductionPattern(i);
parser.addProduction(production, constants);
}
// Write source code files
constants.writeCode();