當前位置: 首頁>>代碼示例>>Java>>正文


Java TerminalNode.getText方法代碼示例

本文整理匯總了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;
			}
		}
	}
}
 
開發者ID:paypal,項目名稱:digraph-parser,代碼行數:26,代碼來源:GraphParser.java

示例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 + " ";
}
 
開發者ID:marcelganczak,項目名稱:ts-swift-transpiler,代碼行數:17,代碼來源:Visitor.java

示例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);
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:17,代碼來源:TypeCheck.java

示例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;
}
 
開發者ID:youseries,項目名稱:ureport,代碼行數:20,代碼來源:ExpressionVisitor.java

示例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;
}
 
開發者ID:youseries,項目名稱:ureport,代碼行數:24,代碼來源:ExpressionVisitor.java

示例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;
}
 
開發者ID:youseries,項目名稱:ureport,代碼行數:21,代碼來源:ExpressionVisitor.java

示例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;
  }
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:13,代碼來源:AbstractWhereClauseListener.java

示例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;
}
 
開發者ID:kasirgalabs,項目名稱:ETUmulator,代碼行數:15,代碼來源:Linker.java

示例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;
}
 
開發者ID:rockscript,項目名稱:rockscript,代碼行數:15,代碼來源:Parse.java

示例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;
}
 
開發者ID:rockscript,項目名稱:rockscript,代碼行數:37,代碼來源:Parse.java

示例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;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:13,代碼來源:LingualQueryCreator.java

示例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;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:13,代碼來源:LingualQueryCreator.java

示例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;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:14,代碼來源:ModelBuilder.java

示例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);
}
 
開發者ID:mware-solutions,項目名稱:memory-graph,代碼行數:6,代碼來源:CypherCstToAstVisitor.java

示例15: visitUnescapedSymbolicName

import org.antlr.v4.runtime.tree.TerminalNode; //導入方法依賴的package包/類
private CypherString visitUnescapedSymbolicName(TerminalNode unescapedSymbolicName) {
    return new CypherString(unescapedSymbolicName.getText());
}
 
開發者ID:mware-solutions,項目名稱:memory-graph,代碼行數:4,代碼來源:CypherCstToAstVisitor.java


注:本文中的org.antlr.v4.runtime.tree.TerminalNode.getText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。