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


Java TokenRewriteStream.LT属性代码示例

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


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

示例1: test2InsertBeforeAfterMiddleIndex

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);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:16,代码来源:TestTokenRewriteStream.java

示例2: testReplaceSingleMiddleThenOverlappingSuperset

public void testReplaceSingleMiddleThenOverlappingSuperset() throws Exception {
	Grammar g = new Grammar(
		"lexer grammar t;\n"+
		"A : 'a';\n" +
		"B : 'b';\n" +
		"C : 'c';\n");
	CharStream input = new ANTLRStringStream("abcba");
	Interpreter lexEngine = new Interpreter(g, input);
	TokenRewriteStream tokens = new TokenRewriteStream(lexEngine);
	tokens.LT(1); // fill buffer
	tokens.replace(2, 2, "xyz");
	tokens.replace(0, 3, "foo");
	String result = tokens.toString();
	String expecting = "fooa";
	assertEquals(result, expecting);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:16,代码来源:TestTokenRewriteStream.java

示例3: test2ReplaceMiddleIndex

public void test2ReplaceMiddleIndex() 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.replace(1, "y");
	String result = tokens.toString();
	String expecting = "ayc";
	assertEquals(result, expecting);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:16,代码来源:TestTokenRewriteStream.java

示例4: testReplaceThenInsertSameIndex

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);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:16,代码来源:TestTokenRewriteStream.java

示例5: testReplaceThen2InsertSameIndex

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);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:17,代码来源:TestTokenRewriteStream.java

示例6: testInsertThenReplaceSameIndex

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);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:16,代码来源:TestTokenRewriteStream.java

示例7: test2InsertMiddleIndex

public void test2InsertMiddleIndex() 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.insertBefore(1, "y");
	String result = tokens.toString();
	String expecting = "ayxbc";
	assertEquals(result, expecting);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:16,代码来源:TestTokenRewriteStream.java

示例8: test2InsertThenReplaceIndex0

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);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:17,代码来源:TestTokenRewriteStream.java

示例9: testReplaceThenInsertBeforeLastIndex

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);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:16,代码来源:TestTokenRewriteStream.java

示例10: testInsertThenReplaceLastIndex

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);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:16,代码来源:TestTokenRewriteStream.java

示例11: testReplaceThenInsertAfterLastIndex

public void testReplaceThenInsertAfterLastIndex() 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.insertAfter(2, "y");
	String result = tokens.toString();
	String expecting = "abxy";
	assertEquals(result, expecting);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:16,代码来源:TestTokenRewriteStream.java

示例12: testReplaceRangeThenInsertInMiddle

public void testReplaceRangeThenInsertInMiddle() 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(3, "y"); // no effect; can't insert in middle of replaced region
	String result = tokens.toString();
	String expecting = "abxba";
	assertEquals(result, expecting);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:16,代码来源:TestTokenRewriteStream.java

示例13: testReplaceRangeThenInsertAtLeftEdge

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);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:16,代码来源:TestTokenRewriteStream.java

示例14: testReplaceRangeThenInsertAtRightEdge

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);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:16,代码来源:TestTokenRewriteStream.java

示例15: testReplaceRangeThenInsertAfterRightEdge

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);
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:16,代码来源:TestTokenRewriteStream.java


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