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


Python test_utils.parse_simple函数代码示例

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


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

示例1: test_dict_one

def test_dict_one():
    "{a: b}"
    parse_simple([
           ('LEFT_BRACKET', '{', [], []),
           ('NAME', 'a'),
           ('COLON', ':', [], [('SPACE', ' ')]),
           ('NAME', 'b'),
           ('RIGHT_BRACKET', '}', [], []),
          ],
          [{
            "type": "dict",
            "first_formatting": [],
            "second_formatting": [],
            "third_formatting": [],
            "fourth_formatting": [],
            "value": [{
                "type": "dictitem",
                "first_formatting": [],
                "second_formatting": [{"type": "space", "value": " "}],
                "key": {
                    "type": "name",
                    "value": "a",
                },
                "value": {
                    "type": "name",
                    "value": "b",
                }
            }],
          }])
开发者ID:oksome,项目名称:baron,代码行数:29,代码来源:test_grammator_data_structures.py

示例2: test_return_a

def test_return_a():
    "return a"
    parse_simple([
           ('RETURN', 'return', [], [('SPACE', ' ')]),
           ('NAME', 'a'),
          ],
         [{ "type": "return", "value": { "type": "name", "value": 'a', }, "formatting": [{"type": "space", "value": " "}], }])
开发者ID:oksome,项目名称:baron,代码行数:7,代码来源:test_grammator_primitives.py

示例3: test_repr_quote_double

def test_repr_quote_double():
    "` a, b `"
    parse_simple([
           ('BACKQUOTE', '`', [], [('SPACE', ' ')]),
           ('NAME', 'a'),
           ('COMMA', ',', [], [('SPACE', ' ')]),
           ('NAME', 'b'),
           ('BACKQUOTE', '`', [('SPACE', ' ')]),
          ],
          [{
            "type": "repr",
            "first_formatting": [{"type": "space", "value": " "}],
            "second_formatting": [{"type": "space", "value": " "}],
            "value": [{
                "type": "name",
                "value": "a",
            },{
                "first_formatting": [],
                "second_formatting": [{"type": "space", "value": " "}],
                "type": "comma",
            },{
                "type": "name",
                "value": "b",
            }],
          }])
开发者ID:oksome,项目名称:baron,代码行数:25,代码来源:test_grammator_data_structures.py

示例4: test_lambda_arguments

def test_lambda_arguments():
    "lambda argument : a"
    parse_simple([
           ('LAMBDA', 'lambda', [], [('SPACE', ' ')]),
           ('NAME', 'argument'),
           ('COLON', ':', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'a'),
          ],
          [{
            "type": "lambda",
            "first_formatting": [{"type": "space", "value": " "}],
            "second_formatting": [{"type": "space", "value": " "}],
            "third_formatting": [{"type": "space", "value": " "}],
            "value": {
                "type": "name",
                "value": "a",
            },
            "arguments": [{
                "value": {},
                "first_formatting": [],
                "second_formatting": [],
                "type": "argument",
                "name": "argument",
            }]
          }])
开发者ID:oksome,项目名称:baron,代码行数:25,代码来源:test_grammator_primitives.py

示例5: test_assert_message

def test_assert_message():
    "assert a , b"
    parse_simple([
           ('ASSERT', 'assert', [], [('SPACE', ' ')]),
           ('NAME', 'a'),
           ('COMMA', ',', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'b'),
          ],
          [{
            "type": "assert",
            "value": { "type": "name", "value": 'a', },
            "message": {"type": "name", "value": 'b'},
            "first_formatting": [{"type": "space", "value": " "}],
            "second_formatting": [{"type": "space", "value": " "}],
            "third_formatting": [{"type": "space", "value": " "}]
          }])
    parse_simple([
           ('ASSERT', 'assert', [], [('SPACE', ' ')]),
           ('NAME', 'a'),
           ('COMMA', ',', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'b'),
          ],
          [{
            "type": "assert",
            "value": {"type": "name", "value": 'a'},
            "message": { "type": "name", "value": 'b', },
            "first_formatting": [{"type": "space", "value": " "}],
            "second_formatting": [{"type": "space", "value": " "}],
            "third_formatting": [{"type": "space", "value": " "}]
          }])
开发者ID:oksome,项目名称:baron,代码行数:30,代码来源:test_grammator_primitives.py

示例6: test_global_two

def test_global_two():
    "global a, b ,  c"
    parse_simple([
           ('GLOBAL', 'global', [], [('SPACE', ' ')]),
           ('NAME', 'a'),
           ('COMMA', ',', [], [('SPACE', ' ')]),
           ('NAME', 'b'),
           ('COMMA', ',', [('SPACE', ' ')], [('SPACE', '  ')]),
           ('NAME', 'c'),
          ],
          [{
            "type": "global",
            "formatting": [{"type": "space", "value": " "}],
            "value": [
                      {"type": "name", "value": "a"},
                      {
                       "type": "comma",
                       "first_formatting": [],
                       "second_formatting": [{ "type": "space", "value": " ", },],
                      },
                      {"type": "name", "value": "b"},
                      {
                       "type": "comma",
                       "first_formatting": [{"type": "space", "value": " "},],
                       "second_formatting": [{"type": "space", "value": "  "},],
                      },
                      {"type": "name", "value": "c"},
                     ]
          }])
开发者ID:oksome,项目名称:baron,代码行数:29,代码来源:test_grammator_primitives.py

示例7: test_yield_a

def test_yield_a():
    "yield a"
    parse_simple([
           ('YIELD', 'yield', [], [('SPACE', ' ')]),
           ('NAME', 'a'),
          ],
         [{ "type": "yield", "value": { "type": "name", "value": 'a', }, "formatting": [{"type": "space", "value": " "}], }])
开发者ID:oksome,项目名称:baron,代码行数:7,代码来源:test_grammator_primitives.py

示例8: test_break

def test_break():
    "break"
    parse_simple([
           ('BREAK', 'break'),
          ],
          [{
            "type": "break",
          }])
开发者ID:oksome,项目名称:baron,代码行数:8,代码来源:test_grammator_primitives.py

示例9: test_continue

def test_continue():
    "continue"
    parse_simple([
           ('CONTINUE', 'continue'),
          ],
          [{
            "type": "continue",
          }])
开发者ID:oksome,项目名称:baron,代码行数:8,代码来源:test_grammator_primitives.py

示例10: test_pass

def test_pass():
    "pass"
    parse_simple([
           ('PASS', 'pass'),
          ],
          [{
            "type": "pass",
          }])
开发者ID:oksome,项目名称:baron,代码行数:8,代码来源:test_grammator_primitives.py

示例11: test_list_comprehension_if_if

def test_list_comprehension_if_if():
    "[ a for b in c if d if d ]"
    parse_simple([
           ('LEFT_SQUARE_BRACKET', '[', [], [('SPACE', ' ')]),
           ('NAME', 'a'),
           ('FOR', 'for', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'b'),
           ('IN', 'in', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'c'),
           ('IF', 'if', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'd'),
           ('IF', 'if', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'd'),
           ('RIGHT_SQUARE_BRACKET', ']', [('SPACE', ' ')]),
          ],
          [{
            "type": "list_comprehension",
            "first_formatting": [],
            "second_formatting": [{"type": "space", "value": " "}],
            "third_formatting": [{"type": "space", "value": " "}],
            "fourth_formatting": [],
            "result": {
               "type": "name",
               "value": "a",
            },
            "generators": [{
                "type": "comprehension_loop",
                "first_formatting": [{"type": "space", "value": " "}],
                "second_formatting": [{"type": "space", "value": " "}],
                "third_formatting": [{"type": "space", "value": " "}],
                "fourth_formatting": [{"type": "space", "value": " "}],
                "iterator": {
                   "type": "name",
                   "value": "b",
                },
                "target": {
                   "type": "name",
                   "value": "c",
                },
                "ifs": [{
                    "type": "comprehension_if",
                    "first_formatting": [{"type": "space", "value": " "}],
                    "second_formatting": [{"type": "space", "value": " "}],
                    "value": {
                        "type": "name",
                        "value": "d"
                    },
                }, {
                    "type": "comprehension_if",
                    "first_formatting": [{"type": "space", "value": " "}],
                    "second_formatting": [{"type": "space", "value": " "}],
                    "value": {
                        "type": "name",
                        "value": "d"
                    },
                }],
            }]
          }])
开发者ID:oksome,项目名称:baron,代码行数:58,代码来源:test_grammator_data_structures.py

示例12: test_generator_comprehension_if_if

def test_generator_comprehension_if_if():
    "( a for b in c if d if e )"
    parse_simple([
           ('LEFT_PARENTHESIS', '(', [], [('SPACE', ' ')]),
           ('NAME', 'a'),
           ('FOR', 'for', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'b'),
           ('IN', 'in', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'c'),
           ('IF', 'if', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'd'),
           ('IF', 'if', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'e'),
           ('RIGHT_PARENTHESIS', ')', [('SPACE', ' ')]),
          ],
          [{
            "type": "generator_comprehension",
            "first_formatting": [],
            "second_formatting": [{"type": "space", "value": " "}],
            "third_formatting": [{"type": "space", "value": " "}],
            "fourth_formatting": [],
            "result": {
               "type": "name",
               "value": "a",
            },
            "generators": [{
                "type": "comprehension_loop",
                "first_formatting": [{"type": "space", "value": " "}],
                "second_formatting": [{"type": "space", "value": " "}],
                "third_formatting": [{"type": "space", "value": " "}],
                "fourth_formatting": [{"type": "space", "value": " "}],
                "iterator": {
                   "type": "name",
                   "value": "b",
                },
                "target": {
                   "type": "name",
                   "value": "c",
                },
                "ifs": [{
                    "type": "comprehension_if",
                    "first_formatting": [{"type": "space", "value": " "}],
                    "second_formatting": [{"type": "space", "value": " "}],
                    "value": {
                        "type": "name",
                        "value": "d"
                    },
                },{
                    "type": "comprehension_if",
                    "first_formatting": [{"type": "space", "value": " "}],
                    "second_formatting": [{"type": "space", "value": " "}],
                    "value": {
                        "type": "name",
                        "value": "e"
                    },
                }],
            }]
          }])
开发者ID:oksome,项目名称:baron,代码行数:58,代码来源:test_grammator_data_structures.py

示例13: test_print_redirect_ab_comma

def test_print_redirect_ab_comma():
    "print >> a , b ,"
    parse_simple([
           ('PRINT', 'print', [], [('SPACE', ' ')]),
           ('RIGHT_SHIFT', '>>', [], [('SPACE', ' ')]),
           ('NAME', 'a'),
           ('COMMA', ',', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'b'),
           ('COMMA', ',', [('SPACE', ' ')]),
          ],
          [{
            "type": "print",
            "formatting": [{"type": "space",
                            "value": " "}],
            "value": [
                      {"type": "comma",
                       "first_formatting": [{"type": "space", "value": " "}],
                       "second_formatting": [{"type": "space", "value": " "}]},
                      {
                       "type": "name",
                       "value": 'b',
                      },
                      {"type": "comma",
                       "first_formatting": [{"type": "space", "value": " "}],
                       "second_formatting": []},
                     ],
            "destination": {"type": "name", "value": 'a'},
            "destination_formatting": [{"type": "space", "value": " "}],
          }])
    parse_simple([
           ('PRINT', 'print', [], [('SPACE', ' ')]),
           ('RIGHT_SHIFT', '>>', [], [('SPACE', ' ')]),
           ('NAME', 'a'),
           ('COMMA', ',', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'b'),
           ('COMMA', ',', [('SPACE', ' ')]),
          ],
          [{
            "type": "print",
            "formatting": [{"type": "space",
                            "value": " "}],
            "value": [
                      {"type": "comma",
                       "first_formatting": [{"type": "space", "value": " "}],
                       "second_formatting": [{"type": "space", "value": " "}]},
                      {"type": "name",
                       "value": 'b'},
                      {"type": "comma",
                       "first_formatting": [{"type": "space", "value": " "}],
                       "second_formatting": []},
                     ],
            "destination": {
                            "type": "name",
                            "value": 'a',
                           },
            "destination_formatting": [{"type": "space",
                                        "value": " "}],
          }])
开发者ID:oksome,项目名称:baron,代码行数:58,代码来源:test_grammator_primitives.py

示例14: test_int

def test_int():
    "1"
    parse_simple([
           ('INT', '1')],
          [{
            "type": "int",
            "section": "number",
            "value": "1",
           }])
开发者ID:titouanc,项目名称:baron,代码行数:9,代码来源:test_grammator.py

示例15: test_list_comprehension_tuple

def test_list_comprehension_tuple():
    "[ a for b in c, d ]"
    parse_simple([
           ('LEFT_SQUARE_BRACKET', '[', [], [('SPACE', ' ')]),
           ('NAME', 'a'),
           ('FOR', 'for', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'b'),
           ('IN', 'in', [('SPACE', ' ')], [('SPACE', ' ')]),
           ('NAME', 'c'),
           ('COMMA', ',', [], [('SPACE', ' ')]),
           ('NAME', 'd'),
           ('RIGHT_SQUARE_BRACKET', ']', [('SPACE', ' ')]),
          ],
          [{
            "type": "list_comprehension",
            "first_formatting": [],
            "second_formatting": [{"type": "space", "value": " "}],
            "third_formatting": [{"type": "space", "value": " "}],
            "forth_formatting": [],
            "result": {
               "type": "name",
               "value": "a",
            },
            "generators": [{
                "type": "comprehension_loop",
                "first_formatting": [{"type": "space", "value": " "}],
                "second_formatting": [{"type": "space", "value": " "}],
                "third_formatting": [{"type": "space", "value": " "}],
                "forth_formatting": [{"type": "space", "value": " "}],
                "iterator": {
                   "type": "name",
                   "value": "b",
                },
                "target": {
                   "type": "tuple",
                   "with_parenthesis": False,
                   "first_formatting": [],
                   "second_formatting": [],
                   "third_formatting": [],
                   "forth_formatting": [],
                   "value": [{
                        "type": "name",
                        "value": "c",
                   },{
                        "type": "comma",
                        "first_formatting": [],
                        "second_formatting": [{"type": "space", "value": " "}],
                   },{
                        "type": "name",
                        "value": "d",
                   }],
                },
                "ifs": [],
            }]
          }])
开发者ID:titouanc,项目名称:baron,代码行数:55,代码来源:test_grammator_data_structures.py


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