use of org.antlr.v4.codegen.model.chunk.QRetValueRef in project antlr4 by tunnelvisionlabs.
the class ActionTranslator method qualifiedAttr.
@Override
public void qualifiedAttr(String expr, Token x, Token y) {
gen.g.tool.log("action-translator", "qattr " + x + "." + y);
if (node.resolver.resolveToAttribute(x.getText(), node) != null) {
// must be a member access to a predefined attribute like $ctx.foo
attr(expr, x);
chunks.add(new ActionText(nodeContext, "." + y.getText()));
return;
}
Attribute a = node.resolver.resolveToAttribute(x.getText(), y.getText(), node);
if (a == null) {
// Added in response to https://github.com/antlr/antlr4/issues/1211
gen.g.tool.errMgr.grammarError(ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE, gen.g.fileName, x, x.getText(), "rule");
return;
}
switch(a.dict.type) {
// has to be current rule
case ARG:
chunks.add(new ArgRef(nodeContext, y.getText()));
break;
case RET:
chunks.add(new QRetValueRef(nodeContext, getRuleLabel(x.getText()), y.getText()));
break;
case PREDEFINED_RULE:
chunks.add(getRulePropertyRef(x, y));
break;
case TOKEN:
chunks.add(getTokenPropertyRef(x, y));
break;
}
}
use of org.antlr.v4.codegen.model.chunk.QRetValueRef in project antlr4 by antlr.
the class ActionTranslator method qualifiedAttr.
@Override
public void qualifiedAttr(String expr, Token x, Token y) {
gen.g.tool.log("action-translator", "qattr " + x + "." + y);
if (node.resolver.resolveToAttribute(x.getText(), node) != null) {
// must be a member access to a predefined attribute like $ctx.foo
attr(expr, x);
chunks.add(new ActionText(nodeContext, "." + y.getText()));
return;
}
Attribute a = node.resolver.resolveToAttribute(x.getText(), y.getText(), node);
if (a == null) {
// Added in response to https://github.com/antlr/antlr4/issues/1211
gen.g.tool.errMgr.grammarError(ErrorType.UNKNOWN_SIMPLE_ATTRIBUTE, gen.g.fileName, x, x.getText(), "rule");
return;
}
switch(a.dict.type) {
// has to be current rule
case ARG:
chunks.add(new ArgRef(nodeContext, y.getText()));
break;
case RET:
chunks.add(new QRetValueRef(nodeContext, getRuleLabel(x.getText()), y.getText()));
break;
case PREDEFINED_RULE:
chunks.add(getRulePropertyRef(x, y));
break;
case TOKEN:
chunks.add(getTokenPropertyRef(x, y));
break;
}
}
Aggregations