本文整理匯總了Java中org.antlr.v4.runtime.tree.TerminalNode.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java TerminalNode.getText方法的具體用法?Java TerminalNode.getText怎麽用?Java TerminalNode.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.antlr.v4.runtime.tree.TerminalNode
的用法示例。
在下文中一共展示了TerminalNode.getText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: populateAttributes
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
private void populateAttributes(DOTParser.Attr_listContext ctx, Map<String,Object> attrs) {
attrs.clear();
if (ctx == null) return;
for (A_listContext listCtx : ctx.a_list()) {
String[] kv = {null,null};
int i = 0;
for (IdContext idCtx : listCtx.id()) {
TerminalNode idObj = idCtx.ID();
if (idObj == null) idObj = idCtx.NUMBER();
if (idObj == null) idObj = idCtx.STRING();
if (idObj == null) idObj = idCtx.HTML_STRING();
String text = idObj.getText();
if (idObj.getSymbol().getType() == DOTParser.STRING) {
text = trimDoubleQuotes(text);
text = text.replace("\\\"", "\"");
}
kv[i++] = text;
if (i > 1) {
attrs.put(kv[0], kv[1]);
i = 0;
}
}
}
}
示例2: printTerminalNode
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
protected String printTerminalNode(TerminalNode c) {
String text = c.getText();
if(text.equals("<EOF>")) {
return "";
}
else if(text.equals("const")) {
return "let ";
}
else if(text.equals("let")) {
return "var ";
}
else if(text.equals(".")) {
return ".";
}
return text + " ";
}
示例3: visitQuantifier
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
@Override
public Object visitQuantifier(final QuantifierContext ctx) {
for (final TerminalNode identifier : ctx.IDENTIFIER()) {
if (this.universe.contains(new Atom(identifier.getText()))) {
final int offset = identifier.getSymbol().getCharPositionInLine();
final int line = identifier.getSymbol().getLine();
final String errorString = "Type check error:\nVariable " + identifier.getText()
+ " must be different from any atom in the model ! " + "[Line:{" + line
+ "}, Position:{" + offset + "}]";
this.errors.add(new ValidationError(line, offset, errorString));
// System.err.println(errorString);
this.setErrState(true);
}
}
return super.visitQuantifier(ctx);
}
示例4: parseExpr
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
private Expression parseExpr(ExprContext exprContext) {
List<BaseExpression> expressions=new ArrayList<BaseExpression>();
List<Operator> operators=new ArrayList<Operator>();
List<ItemContext> itemContexts = exprContext.item();
List<TerminalNode> operatorNodes=exprContext.Operator();
for(int i=0;i<itemContexts.size();i++){
ItemContext itemContext=itemContexts.get(i);
BaseExpression expr=parseItemContext(itemContext);
expressions.add(expr);
if(i>0){
TerminalNode operatorNode=operatorNodes.get(i-1);
String op=operatorNode.getText();
operators.add(Operator.parse(op));
}
}
ParenExpression expression=new ParenExpression(operators, expressions);
expression.setExpr(exprContext.getText());
return expression;
}
示例5: visitSimpleJoin
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
@Override
public BaseExpression visitSimpleJoin(SimpleJoinContext ctx) {
List<BaseExpression> expressions=new ArrayList<BaseExpression>();
List<Operator> operators=new ArrayList<Operator>();
List<UnitContext> unitContexts=ctx.unit();
List<TerminalNode> operatorNodes=ctx.Operator();
for(int i=0;i<unitContexts.size();i++){
UnitContext unitContext=unitContexts.get(i);
BaseExpression expr=buildExpression(unitContext);
expressions.add(expr);
if(i>0){
TerminalNode operatorNode=operatorNodes.get(i-1);
String op=operatorNode.getText();
operators.add(Operator.parse(op));
}
}
if(operators.size()==0 && expressions.size()==1){
return expressions.get(0);
}
JoinExpression expression=new JoinExpression(operators,expressions);
expression.setExpr(ctx.getText());
return expression;
}
示例6: visitParenJoin
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
@Override
public BaseExpression visitParenJoin(ParenJoinContext ctx) {
List<BaseExpression> expressions=new ArrayList<BaseExpression>();
List<Operator> operators=new ArrayList<Operator>();
List<ItemContext> itemContexts=ctx.item();
List<TerminalNode> operatorNodes=ctx.Operator();
for(int i=0;i<itemContexts.size();i++){
ItemContext itemContext=itemContexts.get(i);
BaseExpression expr=parseItemContext(itemContext);
expressions.add(expr);
if(i>0){
TerminalNode operatorNode=operatorNodes.get(i-1);
String op=operatorNode.getText();
operators.add(Operator.parse(op));
}
}
ParenExpression expression=new ParenExpression(operators, expressions);
expression.setExpr(ctx.getText());
return expression;
}
示例7: visitTerminal
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
@Override
public void visitTerminal(TerminalNode node) {
super.visitTerminal(node);
if (handleThisTerminal()) {
String value = node.getText();
if (!isSeparator(value)) {
addRhs(value);
}
} else {
skipNextTerminal = false;
}
}
示例8: replaceLabelAddress
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
private void replaceLabelAddress(ParserRuleContext ctx, TerminalNode terminalNode) {
if(!secondPass) {
return;
}
String label = terminalNode.getText();
if(!definedBranches.containsKey(label)) {
throw new LabelError("\"" + label + "\" is not defined.");
}
int lineNumber = ctx.start.getLine() - 1;
String temp = new String(code[lineNumber]);
String address = Integer.toString(definedBranches.get(label));
temp = temp.replace(label, address);
code[lineNumber] = temp;
}
示例9: parsePropertyName
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
private String parsePropertyName(PropertyNameContext propertyNameContext) {
IdentifierNameContext identifierNameContext = propertyNameContext.identifierName();
if (identifierNameContext!=null) {
return identifierNameContext.getText();
}
TerminalNode stringLiteralNode = propertyNameContext.StringLiteral();
if (stringLiteralNode!=null) {
String propertyNameWithQuotes = stringLiteralNode.getText();
String propertyNameWithoutQuotes = removeQuotesFromString(stringLiteralNode, propertyNameWithQuotes);
return propertyNameWithoutQuotes;
}
addErrorUnsupportedElement(propertyNameContext, "propertyName");
return null;
}
示例10: parseLiteral
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
private SingleExpression parseLiteral(LiteralContext literalContext) {
if (literalContext.StringLiteral()!=null) {
return parseStringLiteral(literalContext);
}
TerminalNode nullLiteral = literalContext.NullLiteral();
if (nullLiteral!=null) {
return new Literal(createNextScriptElementId(), createLocation(literalContext));
}
NumericLiteralContext numericLiteralContext = literalContext.numericLiteral();
if (numericLiteralContext!=null) {
if (numericLiteralContext.DecimalLiteral()!=null) {
return parseDecimalNumberLiteral(numericLiteralContext);
}
addErrorUnsupportedElement(numericLiteralContext, "number");
return null;
}
TerminalNode regularExpressionLiteral = literalContext.RegularExpressionLiteral();
if (regularExpressionLiteral!=null) {
String regexText = regularExpressionLiteral.getText();
addErrorUnsupportedElement(regularExpressionLiteral, "regex");
return null;
}
TerminalNode booleanLiteral = literalContext.BooleanLiteral();
if (booleanLiteral != null) {
if ("true".equals(booleanLiteral.getText())) {
return parseBooleanLiteral(literalContext, true);
} else if ("false".equals(booleanLiteral.getText())) {
return parseBooleanLiteral(literalContext, false);
}
}
return null;
}
示例11: generateIdentifierText
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
private String generateIdentifierText(JavaidenContext javaiden) {
String iden = "";
int i = 0;
for (TerminalNode identifier : javaiden.Identifier()) {
if (i == 0)
iden = iden + identifier.getText();
else
iden = iden + " " + identifier.getText();
i++;
}
return iden;
}
示例12: generateJavaIdentifierText
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
public String generateJavaIdentifierText(QueryParserParser.JavaidenContext ctx) {
String iden = "";
int i = 0;
for (TerminalNode identifier : ctx.Identifier()) {
if (i == 0)
iden = iden + identifier.getText();
else
iden = iden + " " + identifier.getText();
i++;
}
return iden;
}
示例13: visitTerminal
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
@Override
public void visitTerminal(final TerminalNode node) {
this.atom = new Atom(node.getText());
if (this.tuple != null) {
if (node.getSymbol().getType() == FOLParser.IDENTIFIER) {
this.tuple.addAtom(this.atom);
if (!this.universe.contains(this.atom)) {
this.universe.addAtom(this.atom);
}
}
}
this.atom = null;
}
示例14: visitEscapedSymbolicName
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
private CypherString visitEscapedSymbolicName(TerminalNode escapedSymbolicName) {
String text = escapedSymbolicName.getText();
text = text.substring(1, text.length() - 1);
return new CypherString(text);
}
示例15: visitUnescapedSymbolicName
import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
private CypherString visitUnescapedSymbolicName(TerminalNode unescapedSymbolicName) {
return new CypherString(unescapedSymbolicName.getText());
}