@Override public String visitSource(MainParser.SourceContext ctx) {
StringBuilder program = new StringBuilder("v2.0 raw\n");
for (ParseTree child : ctx.children) {
String currentByte = visit(child);
if (! currentByte.isEmpty()) { // empty string doesn't effect program output
if (currentByte.matches("^[01]{8}$")) {
int value = Integer.parseInt(currentByte, 2);
program.append(toBase(value, 16, 2) + " ");
bytes++; // running count of bytes is important for visitAssignLabel
} else {
throw new ParseCancellationException(new com.github.charmoniumq.assembler.backend.InternalError(String.format("Invalid byte produced: %s", currentByte)));
}
}
}
return program.toString();
}
Compiler.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:LALU-Assembler
作者:
评论列表
文章目录