示例#1
0
 def generate(cls, tree, features):
     """
     Parses an AST and checks it.
     """
     tree = Lowering(parser=tree.parser, features=features).process(tree)
     module = Semantics(features=features).process(tree)
     return tree, module
示例#2
0
def parse(source, lower=False):
    """
    Don't regenerate the parser on every call
    """
    tree = _parser().parse(source, allow_single_quotes=False)
    if not lower:
        return tree
    return Lowering(parser=tree.parser, features={}).process(tree)
示例#3
0
def parse(source, lower=False):
    """
    Don't regenerate the parser on every call
    """
    tree = _parser().parse(source)
    if not lower:
        return tree
    return Lowering(parser=tree.parser).process(tree)
示例#4
0
 def generate(cls, tree, storycontext, scope):
     """
     Parses an AST and checks it.
     """
     tree = Lowering(
         parser=tree.parser, features=storycontext.features
     ).process(tree)
     module = Semantics(
         storycontext=storycontext, root_scope=scope
     ).process(tree)
     return tree, module
示例#5
0
def test_story_parse_lower(patch, story, parser):
    patch.object(Lowering, 'process')
    story.parse(parser=parser, lower=True)
    parser.parse.assert_called_with(story.story)
    Lowering.process.assert_called_with(Parser.parse())
    assert story.tree == Lowering.process(Lowering.process())
示例#6
0
 def generate(cls, tree, debug=False):
     """
     Parses an AST and checks it.
     """
     tree = Lowering(parser=tree.parser).process(tree)
     return Semantics().process(tree)