本文整理汇总了Java中org.antlr.runtime.TokenRewriteStream.toString方法的典型用法代码示例。如果您正苦于以下问题:Java TokenRewriteStream.toString方法的具体用法?Java TokenRewriteStream.toString怎么用?Java TokenRewriteStream.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.runtime.TokenRewriteStream
的用法示例。
在下文中一共展示了TokenRewriteStream.toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test2InsertBeforeAfterMiddleIndex
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void test2InsertBeforeAfterMiddleIndex() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abc");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.insertBefore(1, "x");
tokens.insertAfter(1, "x");
String result = tokens.toString();
String expecting = "axbxc";
assertEquals(result, expecting);
}
示例2: testReplaceThenDeleteMiddleIndex
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void testReplaceThenDeleteMiddleIndex() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abc");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.replace(1, "x");
tokens.delete(1);
String result = tokens.toString();
String expecting = "ac";
assertEquals(result, expecting);
}
示例3: testReplaceThenInsertSameIndex
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void testReplaceThenInsertSameIndex() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abc");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.replace(0, "x");
tokens.insertBefore(0, "0");
String result = tokens.toString();
String expecting = "0xbc";
assertEquals(result, expecting);
}
示例4: testReplaceThen2InsertSameIndex
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void testReplaceThen2InsertSameIndex() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abc");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.replace(0, "x");
tokens.insertBefore(0, "y");
tokens.insertBefore(0, "z");
String result = tokens.toString();
String expecting = "zyxbc";
assertEquals(result, expecting);
}
示例5: testInsertThenReplaceSameIndex
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void testInsertThenReplaceSameIndex() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abc");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.insertBefore(0, "0");
tokens.replace(0, "x");
String result = tokens.toString();
String expecting = "0xbc";
assertEquals(result, expecting);
}
示例6: testReplaceThenReplaceSuperset
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void testReplaceThenReplaceSuperset() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abcccba");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.replace(2, 4, "xyz");
tokens.replace(2, 5, "foo"); // kills previous replace
String result = tokens.toString();
String expecting = "abfooa";
assertEquals(result, expecting);
}
示例7: test2InsertThenReplaceIndex0
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void test2InsertThenReplaceIndex0() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abc");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.insertBefore(0, "x");
tokens.insertBefore(0, "y");
tokens.replace(0, "z");
String result = tokens.toString();
String expecting = "yxzbc";
assertEquals(result, expecting);
}
示例8: testReplaceThenInsertBeforeLastIndex
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void testReplaceThenInsertBeforeLastIndex() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abc");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.replace(2, "x");
tokens.insertBefore(2, "y");
String result = tokens.toString();
String expecting = "abyx";
assertEquals(result, expecting);
}
示例9: testInsertThenReplaceLastIndex
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void testInsertThenReplaceLastIndex() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abc");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.insertBefore(2, "y");
tokens.replace(2, "x");
String result = tokens.toString();
String expecting = "abyx";
assertEquals(result, expecting);
}
示例10: testReplaceThenReplaceLowerIndexedSuperset
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void testReplaceThenReplaceLowerIndexedSuperset() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abcccba");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.replace(2, 4, "xyz");
tokens.replace(1, 3, "foo"); // executes first since 1<2; then ignores [email protected] as it skips over 1..3
String result = tokens.toString();
String expecting = "afoocba";
assertEquals(result, expecting);
}
示例11: testReplaceRangeThenInsertAtLeftEdge
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void testReplaceRangeThenInsertAtLeftEdge() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abcccba");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.replace(2, 4, "x");
tokens.insertBefore(2, "y");
String result = tokens.toString();
String expecting = "abyxba";
assertEquals(result, expecting);
}
示例12: testReplaceRangeThenInsertAtRightEdge
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void testReplaceRangeThenInsertAtRightEdge() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abcccba");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.replace(2, 4, "x");
tokens.insertBefore(4, "y"); // no effect; within range of a replace
String result = tokens.toString();
String expecting = "abxba";
assertEquals(result, expecting);
}
示例13: testReplaceRangeThenInsertAfterRightEdge
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void testReplaceRangeThenInsertAfterRightEdge() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abcccba");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.replace(2, 4, "x");
tokens.insertAfter(4, "y");
String result = tokens.toString();
String expecting = "abxyba";
assertEquals(result, expecting);
}
示例14: testOverlappingReplace3
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void testOverlappingReplace3() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abcc");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.replace(1, 2, "foo");
tokens.replace(0, 2, "bar"); // wipes prior nested replace
String result = tokens.toString();
String expecting = "barc";
assertEquals(expecting, result);
}
示例15: testDropPrevCoveredInsert
import org.antlr.runtime.TokenRewriteStream; //导入方法依赖的package包/类
public void testDropPrevCoveredInsert() throws Exception {
Grammar g = new Grammar(
"lexer grammar t;\n"+
"A : 'a';\n" +
"B : 'b';\n" +
"C : 'c';\n");
CharStream input = new ANTLRStringStream("abcc");
Interpreter lexEngine = new Interpreter(g, input);
TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
tokens.LT(1); // fill buffer
tokens.insertBefore(1, "foo");
tokens.replace(1, 2, "foo"); // kill prev insert
String result = tokens.toString();
String expecting = "afooc";
assertEquals(expecting, result);
}