本文整理汇总了Python中Lexer.Lexer.allTokens方法的典型用法代码示例。如果您正苦于以下问题:Python Lexer.allTokens方法的具体用法?Python Lexer.allTokens怎么用?Python Lexer.allTokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer.Lexer
的用法示例。
在下文中一共展示了Lexer.allTokens方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testScanBooleanTrue
# 需要导入模块: from Lexer import Lexer [as 别名]
# 或者: from Lexer.Lexer import allTokens [as 别名]
def testScanBooleanTrue(self):
lexer = Lexer()
lexer.input("def boolean = true")
(tokens, errors) = lexer.allTokens()
# assert that no error occured
self.assertEqual(errors, [])
# assert correct token scanning
self.assertEqual(types(tokens), 'DEF ID = BOOL')
示例2: testScanNegativeInteger
# 需要导入模块: from Lexer import Lexer [as 别名]
# 或者: from Lexer.Lexer import allTokens [as 别名]
def testScanNegativeInteger(self):
lexer = Lexer()
lexer.input("def number = -102")
(tokens, errors) = lexer.allTokens()
# assert that no error occured
self.assertEqual(errors, [])
# assert correct token scanning
self.assertEqual(types(tokens), 'DEF ID = INT')
示例3: testScanVariable
# 需要导入模块: from Lexer import Lexer [as 别名]
# 或者: from Lexer.Lexer import allTokens [as 别名]
def testScanVariable(self):
lexer = Lexer()
lexer.input("def x = y")
(tokens, errors) = lexer.allTokens()
# assert that no error occured
self.assertEqual(errors, [])
# assert correct token scanning
self.assertEqual(types(tokens), 'DEF ID = ID')
示例4: testScanLambda
# 需要导入模块: from Lexer import Lexer [as 别名]
# 或者: from Lexer.Lexer import allTokens [as 别名]
def testScanLambda(self):
lexer = Lexer()
lexer.input("def f(x) = lambda(y) x")
(tokens, errors) = lexer.allTokens()
# assert that no error occured
self.assertEqual(errors, [])
# assert correct token scanning
self.assertEqual(types(tokens), 'DEF ID ( ID ) = LAMBDA ( ID ) ID')
示例5: testScanList
# 需要导入模块: from Lexer import Lexer [as 别名]
# 或者: from Lexer.Lexer import allTokens [as 别名]
def testScanList(self):
lexer = Lexer()
lexer.input("def t = [a, b]")
(tokens, errors) = lexer.allTokens()
# assert that no error occured
self.assertEqual(errors, [])
# assert correct token scanning
self.assertEqual(types(tokens), 'DEF ID = [ ID , ID ]')
示例6: testScanTuple
# 需要导入模块: from Lexer import Lexer [as 别名]
# 或者: from Lexer.Lexer import allTokens [as 别名]
def testScanTuple(self):
lexer = Lexer()
lexer.input("def t = (a, b)")
(tokens, errors) = lexer.allTokens()
# assert that no error occured
self.assertEqual(errors, [])
# assert correct token scanning
self.assertEqual(types(tokens), 'DEF ID = ( ID , ID )')
示例7: testScanFunction
# 需要导入模块: from Lexer import Lexer [as 别名]
# 或者: from Lexer.Lexer import allTokens [as 别名]
def testScanFunction(self):
lexer = Lexer()
lexer.input("def f(x) = x")
(tokens, errors) = lexer.allTokens()
# assert that no error occured
self.assertEqual(errors, [])
# assert correct token scanning
self.assertEqual(types(tokens), 'DEF ID ( ID ) = ID')
示例8: testScanString
# 需要导入模块: from Lexer import Lexer [as 别名]
# 或者: from Lexer.Lexer import allTokens [as 别名]
def testScanString(self):
lexer = Lexer()
lexer.input("def string = \"hello, world!\"")
(tokens, errors) = lexer.allTokens()
# assert that no error occured
self.assertEqual(errors, [])
# assert correct token scanning
self.assertEqual(types(tokens), 'DEF ID = STRING')