* @param tokenizer the tokenizer file generator
* @param analyzer the analyzer file generator
*/
private void initializeCode(VisualBasicTokenizerFile tokenizer,
VisualBasicAnalyzerFile analyzer) {
VisualBasicConstructor constr;
VisualBasicMethod method;
VisualBasicNamespace n;
String str;
// Add using
file.addImports(new VisualBasicImports("System.IO"));
file.addImports(new VisualBasicImports("PerCederberg.Grammatica.Runtime"));
// Add namespace
if (gen.getNamespace() == null) {
file.addClass(cls);
} else {
n = new VisualBasicNamespace(gen.getNamespace());
n.addClass(cls);
file.addNamespace(n);
}
// Add file comment
str = file.toString() + "\n\n" + gen.getFileComment();
file.addComment(new VisualBasicComment(VisualBasicComment.SINGLELINE,
str));
// Add type comment
cls.addComment(new VisualBasicComment(TYPE_COMMENT));
// Add enumeration
cls.addEnumeration(enm);
enm.addComment(new VisualBasicComment(ENUM_COMMENT));
// Add constructor
constr = new VisualBasicConstructor("ByVal input As TextReader");
cls.addConstructor(constr);
constr.addComment(new VisualBasicComment(CONSTRUCTOR1_COMMENT));
constr.addCode("MyBase.New(input)");
constr.addCode("CreatePatterns()");
// Add constructor
constr = new VisualBasicConstructor("ByVal input As TextReader, " +
"ByVal analyzer As " +
analyzer.getClassName());
cls.addConstructor(constr);
constr.addComment(new VisualBasicComment(CONSTRUCTOR2_COMMENT));
constr.addCode("MyBase.New(input, analyzer)");
constr.addCode("CreatePatterns()");
// Add tokenizer factory method
method = new VisualBasicMethod(VisualBasicMethod.PROTECTED + VisualBasicMethod.OVERRIDES,
"NewTokenizer",
"ByVal input As TextReader",