Пример #1
0
def parse_clause(l, loc):
    if l.keyword("run"):

        expr = l.require(l.simple_expression)
        return testast.Action(loc, expr)

    elif l.keyword("pause"):

        expr = l.require(l.simple_expression)
        return testast.Pause(loc, expr)

    elif l.keyword("label"):

        name = l.require(l.name)
        return testast.Label(loc, name)

    elif l.keyword("click"):
        return parse_click(l, loc, None)

    else:
        target = l.string()
        if target:
            return parse_click(l, loc, target)

    l.error("Expected a test language statement or clause.")
    return testast.Click(loc, target)
def parse_clause(l, loc):
    if l.keyword("run"):

        expr = l.require(l.simple_expression)
        return testast.Action(loc, expr)

    elif l.keyword("pause"):

        expr = l.require(l.simple_expression)
        return testast.Pause(loc, expr)

    elif l.keyword("label"):

        name = l.require(l.name)
        return testast.Label(loc, name)

    elif l.keyword("type"):

        name = l.name()
        if name is not None:
            return parse_type(l, loc, [ name ])

        string = l.require(l.string)

        return parse_type(l, loc, list(string))

    elif l.keyword("drag"):

        return parse_drag(l, loc)

    elif l.keyword("move"):
        return parse_move(l, loc)

    elif l.keyword("click"):
        return parse_click(l, loc, None)

    elif l.keyword("scroll"):
        pattern = l.require(l.string)
        return testast.Scroll(loc, pattern)

    else:
        target = l.string()
        if target:
            return parse_click(l, loc, target)

    l.error("Expected a test language statement or clause.")
    return testast.Click(loc, target)