本文整理匯總了Python中ListOps.src.parser.Parser._advance方法的典型用法代碼示例。如果您正苦於以下問題:Python Parser._advance方法的具體用法?Python Parser._advance怎麽用?Python Parser._advance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ListOps.src.parser.Parser
的用法示例。
在下文中一共展示了Parser._advance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_read_sys_func_args
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
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)
示例2: test_read_empty_sys_func_args
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
def test_read_empty_sys_func_args(self):
input = "()"
scanner = Scanner(input)
parser = Parser(scanner)
parser._advance()
expr = parser._read_sys_func_args()
self.assertEqual(expr, None)
示例3: test_read_if_header
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
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)
示例4: test_read_float
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
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)
示例5: test_read_return_statement
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
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)
示例6: test_read_for_loop
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
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)
示例7: test_read_test_arg
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
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)
示例8: test_read_slice_call
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
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)
示例9: test_read_calc_with_proper_reversed_operator_priority
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
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))
示例10: test_read_calc_with_proper_parenthesis
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
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))
示例11: test_read_single_arg_calc
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
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))
示例12: test_read_bot_calc
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
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
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
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
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
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_bot_logic_test
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _advance [as 別名]
def test_read_bot_logic_test(self):
input = "4>8 || 3<4"
scanner = Scanner(input)
parser = Parser(scanner)
parser._advance()
value = parser._read_logic_test().get_value()
self.assertEqual(value, True)