我正在使用PicoContainer来连接我的应用程序的类。正如您在下面看到的,一切都很完美,但在一个地方:
CharArrayReader reader = new CharArrayReader(acCode.toCharArray());
CharStream charStream = new CharStream(reader);
Scanner scanner = new Scanner(charStream);
TokenStream tokenStream = new TokenStream(scanner);
ParserGeneratingAST parserGeneratingAST = new ParserGeneratingAST(tokenStream);
--> AbstractSyntaxTree ast = parserGeneratingAST.generateAST(); <-- here is the problem
SymbolsTable symbolsTable = new SymbolsTable();
ErrorsTable errorsTable = new ErrorsTable();
SymbolsTableFillerVisitor symbolsTableFillerVisitor = new SymbolsTableFillerVisitor(symbolsTable, errorsTable);
TypeCheckingVisitor typeCheckingVisitor = new TypeCheckingVisitor(symbolsTable, errorsTable);
InstructionsList instructionsList = new InstructionsList();
CodeGenerationVisitor codeGenerationVisitor = new CodeGenerationVisitor(instructionsList);
symbolsTableFillerVisitor.visit(ast);
typeCheckingVisitor.visit(ast);
codeGenerationVisitor.visit(ast);
问题线是
AbstractSyntaxTree ast = parserGeneratingAST.generateAST();
有没有办法使用 PicoContainer 解决这个问题?如果可能的话,我想保持我的课程没有注释。
谢谢