当前位置: 首页>>代码示例>>Java>>正文


Java Utils.escapeWhitespace方法代码示例

本文整理汇总了Java中org.antlr.v4.runtime.misc.Utils.escapeWhitespace方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.escapeWhitespace方法的具体用法?Java Utils.escapeWhitespace怎么用?Java Utils.escapeWhitespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.antlr.v4.runtime.misc.Utils的用法示例。


在下文中一共展示了Utils.escapeWhitespace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toStringTree

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
/** Print out a whole tree in LISP form. Arg nodeTextProvider is used on the
 *  node payloads to get the text for the nodes.
 *
 *  @since 4.5.1
 */
public static String toStringTree(Tree t, TreeTextProvider nodeTextProvider) {
	if ( t==null ) return "null";
	String s = Utils.escapeWhitespace(nodeTextProvider.getText(t), false);
	if ( t.getChildCount()==0 ) return s;
	StringBuilder buf = new StringBuilder();
	buf.append("(");
	s = Utils.escapeWhitespace(nodeTextProvider.getText(t), false);
	buf.append(s);
	buf.append(' ');
	for (int i = 0; i<t.getChildCount(); i++) {
		if ( i>0 ) buf.append(' ');
		buf.append(toStringTree(t.getChild(i), nodeTextProvider));
	}
	buf.append(")");
	return buf.toString();
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:22,代码来源:Trees.java

示例2: toStringTree

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
private String toStringTree(Tree tree, List<String> ruleNames) {
    String s = Utils.escapeWhitespace(getNodeText(tree, ruleNames), false);
    if(tree.getChildCount() == 0) return s;
    
    StringBuilder buf = new StringBuilder();
    buf.append("(");
    s = Utils.escapeWhitespace(getNodeText(tree, ruleNames), false);
    buf.append(s);
    buf.append(' ');
    for(int i = 0; i < tree.getChildCount(); i++)
    {
        if(i > 0)
            buf.append(' ');
        buf.append(toStringTree(tree.getChild(i), ruleNames));
    }

    buf.append(")");
    return buf.toString();
}
 
开发者ID:processquerying,项目名称:PQL,代码行数:20,代码来源:AbstractPQLQuery.java

示例3: toStringTree

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
private String toStringTree(@NotNull final Tree t, @Nullable final List<String> ruleNames) {
  if (t.getChildCount() == 0) {
    return Utils.escapeWhitespace(getNodeText(t, ruleNames), true);
  }
  StringBuilder buf = new StringBuilder();
  buf.append(" ( ");
  String s = Utils.escapeWhitespace(getNodeText(t, ruleNames), true);
  buf.append(s);
  buf.append(' ');
  for (int i = 0; i < t.getChildCount(); i++) {
    if (i > 0) {
      buf.append(' ');
    }
    buf.append(toStringTree(t.getChild(i), ruleNames));
  }
  buf.append(" ) ");
  return buf.toString();
}
 
开发者ID:antlr4ide,项目名称:antlr4ide,代码行数:19,代码来源:ParseTreeCommand.java

示例4: toStringTree

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
/** Print out a whole tree in LISP form. {@link #getNodeText} is used on the
 *  node payloads to get the text for the nodes.  Detect
 *  parse trees and extract data appropriately.
 */
public static String toStringTree(@NotNull Tree t, @Nullable List<String> ruleNames) {
	String s = Utils.escapeWhitespace(getNodeText(t, ruleNames), false);
	if ( t.getChildCount()==0 ) return s;
	StringBuilder buf = new StringBuilder();
	buf.append("(");
	s = Utils.escapeWhitespace(getNodeText(t, ruleNames), false);
	buf.append(s);
	buf.append(' ');
	for (int i = 0; i<t.getChildCount(); i++) {
		if ( i>0 ) buf.append(' ');
		buf.append(toStringTree(t.getChild(i), ruleNames));
	}
	buf.append(")");
	return buf.toString();
}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:20,代码来源:Trees.java

示例5: process

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
private String process(final Tree t, final List<String> ruleNames) {
	if (t.getChildCount() == 0) return Utils.escapeWhitespace(Trees.getNodeText(t, ruleNames), false);
	StringBuilder sb = new StringBuilder();
	sb.append(lead(level));
	level++;
	String s = Utils.escapeWhitespace(Trees.getNodeText(t, ruleNames), false);
	sb.append(s + ' ');
	for (int i = 0; i < t.getChildCount(); i++) {
		sb.append(process(t.getChild(i), ruleNames));
	}
	level--;
	sb.append(lead(level));
	return sb.toString();
}
 
开发者ID:grosenberg,项目名称:SnippetsTest,代码行数:15,代码来源:TestBase.java

示例6: visitTerminal

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
@Override
public void visitTerminal(TerminalNode node) {
	String text = Utils.escapeWhitespace(Trees.getNodeText(node, ruleNames), false);
	if(text.startsWith(" ") || text.endsWith(" ")){
		text = "'" + text + "'";
	}
    stack.get(node.getParent()).add(text);
}
 
开发者ID:rpgleparser,项目名称:rpgleparser,代码行数:9,代码来源:TreePrinterListener.java

示例7: appendToken

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
/**
 * Append the symbol and its position in the input text to the parse tree
 * buffer.
 *
 * @param symbol the symbol which should be appended to the parse tree.
 * @return boolean true if symbol is not null, false otherwise.
 */
protected boolean appendToken(Token symbol) {
  if (symbol != null) {
	  buf.append("[");
		String s = Utils.escapeWhitespace(symbol.getText(), false);
		buf.append(s);
		buf.append("]    (line ");
		buf.append(String.valueOf(symbol.getLine()));
		buf.append(":");
		buf.append(String.valueOf(symbol.getCharPositionInLine()));
		buf.append(")");
		return true;
	}
	return false;
}
 
开发者ID:fandianpf,项目名称:antlr4-regressionTestRig,代码行数:22,代码来源:TreePrinter.java

示例8: appendNodeText

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
/**
 * Determine some string representation for the given node and append it to
 * the parse tree buffer.
 *
 * @param t The sub-tree whose current node needs a string representation.
 */
protected void appendNodeText(@NotNull Tree t) {
	if ( ruleNames!=null ) {
		if ( t instanceof RuleNode ) {
			if (appendRule(((RuleNode)t).getRuleContext())) return;
		}
		if ( t instanceof ErrorNode) {
		  buf.append("ERROR: ");
		  appendToken(((ErrorNode)t).getSymbol());
		  return;
		}
		if ( t instanceof TerminalNode) {
			if (appendToken(((TerminalNode)t).getSymbol())) return;
		}
	}
	// no recog for rule names
	Object payload = t.getPayload();
	if ( payload instanceof Token ) {
	  if (appendToken((Token)payload)) return;
	}
	if ( payload instanceof RuleContext ) {
	  if (appendRule((RuleContext)payload)) return;
	}
	String s = Utils.escapeWhitespace(payload.toString(), false);
	buf.append("unknown payload <<");
   buf.append(s);
   buf.append(">>");
}
 
开发者ID:fandianpf,项目名称:antlr4-regressionTestRig,代码行数:34,代码来源:TreePrinter.java

示例9: outputSymbol

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
/** Output the current symbol with line and character position. */
public void outputSymbol(Token symbol) {
  if ( outputStream != null) {
    outputStream.print(", LT(1)=[");
    String s = Utils.escapeWhitespace(symbol.getText(), false);
    outputStream.print(s);
    outputStream.print("]    (line ");
    outputStream.print(String.valueOf(symbol.getLine()));
    outputStream.print(":");
    outputStream.print(String.valueOf(symbol.getCharPositionInLine()));
    outputStream.println(")");
  }
}
 
开发者ID:fandianpf,项目名称:antlr4-regressionTestRig,代码行数:14,代码来源:PrintStreamTraceListener.java

示例10: toStringTree

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
/**
 * @see org.antlr.v4.runtime.tree.Trees.toStringTree(Tree, List<String>)
 */
public static String toStringTree(final Tree t, @Nullable final List<String> ruleNames, final int depth) {
	String s = Utils.escapeWhitespace(Trees.getNodeText(t, ruleNames), false);

	if (t.getChildCount() == 0) {
		return s;
	}

	final StringBuilder buf = new StringBuilder();

	if (depth > 0) {
		buf.append(NEWLINE);
	}

	buf.append(indent(depth));
	buf.append("(");
	s = Utils.escapeWhitespace(Trees.getNodeText(t, ruleNames), false);
	buf.append(s);
	buf.append(' ');

	for (int i = 0; i < t.getChildCount(); i++) {
		if (i > 0) {
			buf.append(' ');
		}

		buf.append(toStringTree(t.getChild(i), ruleNames, depth + 1));
	}

	buf.append(")");

	return buf.toString();
}
 
开发者ID:uwol,项目名称:vb6parser,代码行数:35,代码来源:TreeUtils.java

示例11: toString

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
@Override
public String toString() {
	String symbol = "";
	if (startIndex >= 0 && startIndex < getInputStream().size()) {
		symbol = getInputStream().getText(Interval.of(startIndex,startIndex));
		symbol = Utils.escapeWhitespace(symbol, false);
	}

	return String.format(Locale.getDefault(), "%s('%s')", LexerNoViableAltException.class.getSimpleName(), symbol);
}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:11,代码来源:LexerNoViableAltException.java

示例12: getText

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
protected String getText(Tree tree) {
	String s = treeTextProvider.getText(tree);
	s = Utils.escapeWhitespace(s, false);
	return s;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:6,代码来源:TreePostScriptGenerator.java

示例13: text

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
public void text(Graphics g, String s, int x, int y) {
//		System.out.println("drawing '"+s+"' @ "+x+","+y);
		s = Utils.escapeWhitespace(s, true);
		g.drawString(s, x, y);
	}
 
开发者ID:antlr,项目名称:codebuff,代码行数:6,代码来源:TreeViewer.java

示例14: getText

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
protected String getText(Tree tree) {
	String s = treeTextProvider.getText(tree);
	s = Utils.escapeWhitespace(s, true);
	return s;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:6,代码来源:TreeViewer.java

示例15: toStringTree

import org.antlr.v4.runtime.misc.Utils; //导入方法依赖的package包/类
private static String toStringTree(Tree t, String[] ruleNames, String[] tokenNames, int indent, boolean prettyPrint) {
	String s = Utils.escapeWhitespace(getNodeText(t, ruleNames, tokenNames), false);
	if (t.getChildCount() == 0)
		return s;
	StringBuilder buf = new StringBuilder();
	buf.append("(");
	s = Utils.escapeWhitespace(getNodeText(t, ruleNames, tokenNames), false);
	buf.append(s);
	buf.append(" ");

	boolean inlined = true;

	if (prettyPrint) {
		for (int i = 0; i < t.getChildCount(); i++) {
			if (t.getChild(i).getChildCount() > 1) {
				inlined = false;
			}
		}
	}
	
	for (int i = 0; i < t.getChildCount(); i++) {
		if (inlined) {
			if (i > 0)
				buf.append(" ");
			buf.append(toStringTree(t.getChild(i), ruleNames, tokenNames, indent + 1, prettyPrint));
			inlined = true;
		} else {
			buf.append("\n");
			for (int k = 0; k < indent + 1; k++)
				buf.append("    ");
			buf.append(toStringTree(t.getChild(i), ruleNames, tokenNames, indent + 1, prettyPrint));
			inlined = false;
		}
	}

	if (!inlined) {
		buf.append("\n");
		for (int k = 0; k < indent; k++)
			buf.append("    ");
	}
	buf.append(")");
	return buf.toString();
}
 
开发者ID:danishdynamite,项目名称:templates4j,代码行数:44,代码来源:AntlrUtils.java


注:本文中的org.antlr.v4.runtime.misc.Utils.escapeWhitespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。