这是我的JCA文件的语法:
methodBody : stackMethod localMethod descriptorMethod* instructionMethod* ;
stackMethod : '.stack' NUMBER ';' ;
localMethod : '.locals' NUMBER ';' ;
descriptorMethod : '.descriptor' typeJCA ';' qualifiedNumber ';';
instructionMethod :
('L' NUMBER ':')? op=instruction+
;
instruction :
qualifiedID ('L'? NUMBER)* ';'
|'.'qualifiedID '{' (('L' NUMBER) | NUMBER)* ';' '}'
;
我希望分别获得所有方法(指令方法*)的说明。与听众或访客
例:
@Override
public void enterInstructionMethod(InstructionMethodContext ctx) {
//Print all instruction+ (one by one in a loop or any way)
}
没
关系,我找到了一个解决方案(简单的解决方案)
首先你必须听
@Override
public void enterInstruction(InstructionContext ctx) {
}
其次,你必须倾听
@Override
public void exitMethodBody(MethodBodyContext ctx) {
// Here you will have the trigger that say : hi, the instructionS that you have just read before are mine
//And the same think for all exitMethodBody
}