本文整理汇总了Python中ListOps.src.parser.Parser类的典型用法代码示例。如果您正苦于以下问题:Python Parser类的具体用法?Python Parser怎么用?Python Parser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_read_id
def test_read_id(self):
value = "abcd"
scanner = Scanner(value)
parser = Parser(scanner)
parser._advance()
id = parser._read_identifier()
self.assertEqual(id, Identifier(value))
示例2: test_read_float
def test_read_float(self):
scanner = Scanner("12.12")
parser = Parser(scanner)
parser._advance()
number = parser._read_float()
self.assertEqual(number, Float("12.12"))
self.assertEqual(number.value, 12.12)
示例3: test_read_sys_func_args
def test_read_sys_func_args(self):
input = "(a->a>2)"
scanner = Scanner(input)
parser = Parser(scanner)
parser._advance()
expr = parser._read_sys_func_args()
self.assertEqual(isinstance(expr, FunctionExpr), True)
示例4: test_read_for_loop
def test_read_for_loop(self):
value = "for (a in b : a>4){a=a+1}"
scanner = Scanner(value)
parser = Parser(scanner)
parser._advance()
loop = parser._read_for_loop()
self.assertEqual(isinstance(loop, ForLoop), True)
示例5: test_read_if_header
def test_read_if_header(self):
value = "(a>4)"
scanner = Scanner(value)
parser = Parser(scanner)
parser._advance()
header = parser._read_if_header()
self.assertEqual(isinstance(header, LogicTest), True)
示例6: test_read_slice_call
def test_read_slice_call(self):
input = "a[1:2]"
scanner = Scanner(input)
parser = Parser(scanner)
parser._advance()
slice = parser._read_slice_call()
self.assertEqual(isinstance(slice, FuncCall), True)
示例7: test_read_return_statement
def test_read_return_statement(self):
input = "return e"
scanner = Scanner(input)
parser = Parser(scanner)
parser._advance()
ret = parser._read_return_statement()
self.assertEqual(isinstance(ret, Identifier), True)
示例8: test_read_calc_with_proper_parenthesis
def test_read_calc_with_proper_parenthesis(self):
input = "((4+8)*2)/12"
scanner = Scanner(input)
parser = Parser(scanner)
parser._advance()
value = parser._read_calc().get_value()
self.assertEqual(value, Number(2))
示例9: test_read_test_arg
def test_read_test_arg(self):
input = "4>8"
scanner = Scanner(input)
parser = Parser(scanner)
parser._advance()
value = parser._read_test_argument().get_value()
self.assertEqual(value, False)
示例10: test_read_single_arg_calc
def test_read_single_arg_calc(self):
input = "4"
scanner = Scanner(input)
parser = Parser(scanner)
parser._advance()
value = parser._read_calc().get_value()
self.assertEqual(value, Number(4))
示例11: test_read_calc_with_proper_reversed_operator_priority
def test_read_calc_with_proper_reversed_operator_priority(self):
input = "4*8+2"
scanner = Scanner(input)
parser = Parser(scanner)
parser._advance()
value = parser._read_calc().get_value()
self.assertEqual(value, Number(34))
示例12: test_read_bot_calc
def test_read_bot_calc(self):
input = "4+8"
scanner = Scanner(input)
parser = Parser(scanner)
parser._advance()
value = parser._read_calc().get_value()
self.assertEqual(value, Number(12))
示例13: test_read_two_top_calcs
def test_read_two_top_calcs(self):
input = "4*8/2"
scanner = Scanner(input)
parser = Parser(scanner)
parser._advance()
value = parser._read_top_calc().get_value()
self.assertEqual(value, Number(16))
示例14: test_read_args
def test_read_args(self):
value = "(12,-3,a,b)"
scanner = Scanner(value)
parser = Parser(scanner)
parser._advance()
list = [Number(12), Number(-3), Identifier("a"), Identifier("b")]
self.assertEqual(list, parser._read_arguments_list())
示例15: test_read_sys_func
def test_read_sys_func(self):
input = "filter(a->a>2)"
scanner = Scanner(input)
parser = Parser(scanner)
parser._advance()
func = parser._read_sys_func()
self.assertEqual(isinstance(func, FilterFunction), True)