use of org.antlr.v4.codegen.model.chunk.LabelRef in project antlr4 by antlr.
the class ActionTranslator method attr.
@Override
public void attr(String expr, Token x) {
gen.g.tool.log("action-translator", "attr " + x);
Attribute a = node.resolver.resolveToAttribute(x.getText(), node);
if (a != null) {
switch(a.dict.type) {
case ARG:
chunks.add(new ArgRef(nodeContext, x.getText()));
break;
case RET:
chunks.add(new RetValueRef(rf.ruleCtx, x.getText()));
break;
case LOCAL:
chunks.add(new LocalRef(nodeContext, x.getText()));
break;
case PREDEFINED_RULE:
chunks.add(getRulePropertyRef(x));
break;
}
}
if (node.resolver.resolvesToToken(x.getText(), node)) {
// $label
chunks.add(new TokenRef(nodeContext, getTokenLabel(x.getText())));
return;
}
if (node.resolver.resolvesToLabel(x.getText(), node)) {
// $x for x=ID etc...
chunks.add(new LabelRef(nodeContext, getTokenLabel(x.getText())));
return;
}
if (node.resolver.resolvesToListLabel(x.getText(), node)) {
// $ids for ids+=ID etc...
chunks.add(new ListLabelRef(nodeContext, x.getText()));
return;
}
Rule r = factory.getGrammar().getRule(x.getText());
if (r != null) {
// $r for r rule ref
chunks.add(new LabelRef(nodeContext, getRuleLabel(x.getText())));
}
}
Aggregations