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


Python CommonTokenStream.CommonTokenStream类代码示例

本文整理汇总了Python中antlr4.CommonTokenStream.CommonTokenStream的典型用法代码示例。如果您正苦于以下问题:Python CommonTokenStream类的具体用法?Python CommonTokenStream怎么用?Python CommonTokenStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testInsertBeforeIndexZero

    def testInsertBeforeIndexZero(self):
        input = InputStream('abc')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)
        rewriter.insertBeforeIndex(0, '0')

        self.assertEqual(rewriter.getDefaultText(), '0abc')
开发者ID:antlr,项目名称:antlr4,代码行数:9,代码来源:TestTokenStreamRewriter.py

示例2: testInsertAfterLastIndex

    def testInsertAfterLastIndex(self):
        input = InputStream('abc')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)
        rewriter.insertAfter(10, 'x')

        self.assertEqual(rewriter.getDefaultText(), 'abcx')
开发者ID:antlr,项目名称:antlr4,代码行数:9,代码来源:TestTokenStreamRewriter.py

示例3: testReplaceMiddleIndex

    def testReplaceMiddleIndex(self):
        input = InputStream('abc')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)

        rewriter.replaceIndex(1, 'x')

        self.assertEqual(rewriter.getDefaultText(), 'axc')
开发者ID:antlr,项目名称:antlr4,代码行数:10,代码来源:TestTokenStreamRewriter.py

示例4: testReplaceSubsetThenFetch

    def testReplaceSubsetThenFetch(self):
        input = InputStream('abcccba')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)

        rewriter.replaceRange(2, 4, 'xyz')

        self.assertEqual('abxyzba', rewriter.getDefaultText())
开发者ID:antlr,项目名称:antlr4,代码行数:10,代码来源:TestTokenStreamRewriter.py

示例5: testReplaceAll

    def testReplaceAll(self):
        input = InputStream('abcccba')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)

        rewriter.replaceRange(0, 6, 'x')

        self.assertEqual('x', rewriter.getDefaultText())
开发者ID:antlr,项目名称:antlr4,代码行数:10,代码来源:TestTokenStreamRewriter.py

示例6: testOverlappingReplace4

    def testOverlappingReplace4(self):
        input = InputStream('abcc')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)

        rewriter.replaceRange(1, 2, 'foo')
        rewriter.replaceRange(1, 3, 'bar')

        self.assertEqual('abar', rewriter.getDefaultText())
开发者ID:antlr,项目名称:antlr4,代码行数:11,代码来源:TestTokenStreamRewriter.py

示例7: testInsertBeforeTokenThenDeleteThatToken

    def testInsertBeforeTokenThenDeleteThatToken(self):
        input = InputStream('abc')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)

        rewriter.insertBeforeIndex(1, 'foo')
        rewriter.replaceRange(1, 2, 'foo')

        self.assertEqual('afoofoo', rewriter.getDefaultText())
开发者ID:antlr,项目名称:antlr4,代码行数:11,代码来源:TestTokenStreamRewriter.py

示例8: testReplaceThenInsertAfterLastIndex

    def testReplaceThenInsertAfterLastIndex(self):
        input = InputStream('abc')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)

        rewriter.replaceIndex(2, 'x')
        rewriter.insertAfter(2, 'y')

        self.assertEqual('abxy', rewriter.getDefaultText())
开发者ID:antlr,项目名称:antlr4,代码行数:11,代码来源:TestTokenStreamRewriter.py

示例9: testInsertThenReplaceSameIndex

    def testInsertThenReplaceSameIndex(self):
        input = InputStream('abc')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)

        rewriter.insertBeforeIndex(0, '0')
        rewriter.replaceIndex(0, 'x')

        self.assertEqual('0xbc', rewriter.getDefaultText())
开发者ID:antlr,项目名称:antlr4,代码行数:11,代码来源:TestTokenStreamRewriter.py

示例10: testReplaceRangeThenInsertAfterRightEdge

    def testReplaceRangeThenInsertAfterRightEdge(self):
        input = InputStream('abcccba')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)

        rewriter.replaceRange(2, 4, 'x')
        rewriter.insertAfter(4, 'y')

        self.assertEqual('abxyba', rewriter.getDefaultText())
开发者ID:antlr,项目名称:antlr4,代码行数:11,代码来源:TestTokenStreamRewriter.py

示例11: testDropIdenticalReplace

    def testDropIdenticalReplace(self):
        input = InputStream('abcc')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)

        rewriter.replaceRange(1, 2, 'foo')
        rewriter.replaceRange(1, 2, 'foo')

        self.assertEqual('afooc', rewriter.getDefaultText())
开发者ID:antlr,项目名称:antlr4,代码行数:11,代码来源:TestTokenStreamRewriter.py

示例12: testReplaceSingleMiddleThenOverlappingSuperset

    def testReplaceSingleMiddleThenOverlappingSuperset(self):
        input = InputStream('abcba')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)

        rewriter.replaceIndex(2, 'xyz')
        rewriter.replaceRange(0, 3, 'foo')

        self.assertEqual('fooa', rewriter.getDefaultText())
开发者ID:antlr,项目名称:antlr4,代码行数:11,代码来源:TestTokenStreamRewriter.py

示例13: testCombineInsertOnLeftWithReplace

    def testCombineInsertOnLeftWithReplace(self):
        input = InputStream('abc')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)

        rewriter.replaceRange(0, 2, 'foo')
        rewriter.insertBeforeIndex(0, 'z')

        self.assertEqual('zfoo', rewriter.getDefaultText())
开发者ID:antlr,项目名称:antlr4,代码行数:11,代码来源:TestTokenStreamRewriter.py

示例14: testCombineInsertOnLeftWithDelete

    def testCombineInsertOnLeftWithDelete(self):
        input = InputStream('abc')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)

        rewriter.delete('default', 0, 2)
        rewriter.insertBeforeIndex(0, 'z')

        self.assertEqual('z', rewriter.getDefaultText())
开发者ID:antlr,项目名称:antlr4,代码行数:11,代码来源:TestTokenStreamRewriter.py

示例15: test2InsertBeforeAfterMiddleIndex

    def test2InsertBeforeAfterMiddleIndex(self):
        input = InputStream('abc')
        lexer = TestLexer(input)
        stream = CommonTokenStream(lexer=lexer)
        stream.fill()
        rewriter = TokenStreamRewriter(tokens=stream)

        rewriter.insertBeforeIndex(1, 'x')
        rewriter.insertAfter(1, 'x')

        self.assertEqual(rewriter.getDefaultText(), 'axbxc')
开发者ID:antlr,项目名称:antlr4,代码行数:11,代码来源:TestTokenStreamRewriter.py


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