Esempio n. 1
0
def parse_statement(l, loc):

    if l.keyword('python'):

        l.require(':')

        l.expect_block("python block")

        source = l.python_block()

        code = renpy.ast.PyCode(source, loc)
        return testast.Python(loc, code)

    # Single-line statements only below here.

    l.expect_noblock('statement')

    if l.match(r'\$'):

        source = l.require(l.rest)

        code = renpy.ast.PyCode(source, loc)
        return testast.Python(loc, code)

    elif l.keyword('assert'):
        source = l.require(l.rest)
        return testast.Assert(loc, source)

    rv = parse_clause(l, loc)

    if l.keyword("until"):
        right = parse_clause(l, loc)
        rv = testast.Until(rv, right)

    return rv
def parse_statement(l, loc):

    if l.keyword('python'):

        l.require(':')

        l.expect_block("python block")

        source = l.python_block()

        code = renpy.ast.PyCode(source, loc)
        return testast.Python(loc, code)

    if l.keyword("if"):
        l.expect_block("if block")

        condition = parse_clause(l, loc)
        l.require(':')
        block = parse_block(l.subblock_lexer(False), loc)

        return testast.If(loc, condition, block)

    # Single-line statements only below here.

    l.expect_noblock('statement')

    if l.match(r'\$'):

        source = l.require(l.rest)

        code = renpy.ast.PyCode(source, loc)
        return testast.Python(loc, code)

    elif l.keyword('assert'):
        source = l.require(l.rest)
        return testast.Assert(loc, source)

    elif l.keyword('jump'):
        target = l.require(l.name)
        return testast.Jump(loc, target)

    elif l.keyword('call'):
        target = l.require(l.name)
        return testast.Call(loc, target)

    rv = parse_clause(l, loc)

    if l.keyword("until"):
        right = parse_clause(l, loc)
        rv = testast.Until(loc, rv, right)

    return rv