use of org.antlr.v4.parse.ActionSplitterListener in project antlr4 by tunnelvisionlabs.
the class UseDefAnalyzer method actionIsContextDependent.
public static boolean actionIsContextDependent(ActionAST actionAST) {
ANTLRStringStream in = new ANTLRStringStream(actionAST.token.getText());
in.setLine(actionAST.token.getLine());
in.setCharPositionInLine(actionAST.token.getCharPositionInLine());
// can't be simple bool with anon class
final boolean[] dependent = new boolean[] { false };
ActionSplitterListener listener = new BlankActionSplitterListener() {
@Override
public void nonLocalAttr(String expr, Token x, Token y) {
dependent[0] = true;
}
@Override
public void qualifiedAttr(String expr, Token x, Token y) {
dependent[0] = true;
}
@Override
public void setAttr(String expr, Token x, Token rhs) {
dependent[0] = true;
}
@Override
public void setExprAttribute(String expr) {
dependent[0] = true;
}
@Override
public void setNonLocalAttr(String expr, Token x, Token y, Token rhs) {
dependent[0] = true;
}
@Override
public void attr(String expr, Token x) {
dependent[0] = true;
}
};
ActionSplitter splitter = new ActionSplitter(in, listener);
// forces eval, triggers listener methods
splitter.getActionTokens();
return dependent[0];
}
use of org.antlr.v4.parse.ActionSplitterListener in project antlr4 by antlr.
the class UseDefAnalyzer method actionIsContextDependent.
public static boolean actionIsContextDependent(ActionAST actionAST) {
ANTLRStringStream in = new ANTLRStringStream(actionAST.token.getText());
in.setLine(actionAST.token.getLine());
in.setCharPositionInLine(actionAST.token.getCharPositionInLine());
// can't be simple bool with anon class
final boolean[] dependent = new boolean[] { false };
ActionSplitterListener listener = new BlankActionSplitterListener() {
@Override
public void nonLocalAttr(String expr, Token x, Token y) {
dependent[0] = true;
}
@Override
public void qualifiedAttr(String expr, Token x, Token y) {
dependent[0] = true;
}
@Override
public void setAttr(String expr, Token x, Token rhs) {
dependent[0] = true;
}
@Override
public void setExprAttribute(String expr) {
dependent[0] = true;
}
@Override
public void setNonLocalAttr(String expr, Token x, Token y, Token rhs) {
dependent[0] = true;
}
@Override
public void attr(String expr, Token x) {
dependent[0] = true;
}
};
ActionSplitter splitter = new ActionSplitter(in, listener);
// forces eval, triggers listener methods
splitter.getActionTokens();
return dependent[0];
}
Aggregations