Simulator.java 文件源码

java
阅读 29 收藏 0 点赞 0 评论 0

项目:TSS 作者:
private static CommandResult executeCommand(String command, Transputer[] transputers, PrintWriter output, PrintWriter errOutput) {
    DebuggerCommandLexer commandLexer = new DebuggerCommandLexer(new ANTLRInputStream(command));
    commandLexer.removeErrorListener(ConsoleErrorListener.INSTANCE);

    CommonTokenStream tokenStream = new CommonTokenStream(commandLexer);
    ErrorListener errorListener = new ErrorListener();
    DebuggerCommandParser commandParser = new DebuggerCommandParser(tokenStream);
    commandParser.addErrorListener(errorListener);
    commandParser.removeErrorListener(ConsoleErrorListener.INSTANCE);

    ParseTree commandTree = commandParser.command();

    if (errorListener.errors != 0) {
        output.println("Command not recognised.");
        output.flush();
        return CommandResult.NOT_RECOGNISED;
    }

    CommandExecutor executor = new CommandExecutor(transputers, output, errOutput);
    return executor.visit(commandTree);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号