Exemplo n.º 1
0
Arquivo: parser.py Projeto: W-M-T/gsc
def StmtElif():
    yield ps.token(TOKEN.ELIF)
    yield ps.token(TOKEN.PAR_OPEN)
    condition = yield Exp
    yield ps.token(TOKEN.PAR_CLOSE)
    yield ps.token(TOKEN.CURL_OPEN)
    contents = yield ps.many(Stmt)
    yield ps.token(TOKEN.CURL_CLOSE)
    return AST.CONDBRANCH(expr=condition, stmts=contents)
Exemplo n.º 2
0
Arquivo: parser.py Projeto: W-M-T/gsc
def StmtIfElse():
    yield ps.token(TOKEN.IF)
    yield ps.token(TOKEN.PAR_OPEN)
    condition = yield Exp
    yield ps.token(TOKEN.PAR_CLOSE)
    yield ps.token(TOKEN.CURL_OPEN)
    if_contents = yield ps.many(Stmt)
    yield ps.token(TOKEN.CURL_CLOSE)
    first_cond = AST.CONDBRANCH(expr=condition, stmts=if_contents)

    elifs = yield ps.many(StmtElif)
    elses = yield ps.times(StmtElse, 0, 1)
    return AST.IFELSE(condbranches=[first_cond, *elifs, *elses])
Exemplo n.º 3
0
Arquivo: parser.py Projeto: W-M-T/gsc
def StmtElse():
    yield ps.token(TOKEN.ELSE)
    yield ps.token(TOKEN.CURL_OPEN)
    contents = yield ps.many(Stmt)
    yield ps.token(TOKEN.CURL_CLOSE)
    return AST.CONDBRANCH(expr=None, stmts=contents)
Exemplo n.º 4
0
     Token(None, TOKEN.OP_IDENTIFIER, "=="),
     Token(None, TOKEN.IDENTIFIER, "y")
 ]),
 update=AST.FUNCALL(id=Token(None, TOKEN.IDENTIFIER,
                             "f"),
                    kind=FunKind.FUNC,
                    args=[]),
 stmts=[
     AST.STMT(
         val=AST.RETURN(expr=None)),
     AST.STMT(val=AST.IFELSE(condbranches=[
         AST.CONDBRANCH(expr=AST.DEFERREDEXPR(contents=[
             Token(None, TOKEN.IDENTIFIER, "x"),
             Token(None, TOKEN.OP_IDENTIFIER, "=="),
             Token(None, TOKEN.IDENTIFIER, "y")
         ]),
                        stmts=[
                            AST.STMT(val=AST.RETURN(
                                expr=None))
                        ]),
         AST.CONDBRANCH(expr=AST.DEFERREDEXPR(contents=[
             Token(None, TOKEN.IDENTIFIER, "x"),
             Token(None, TOKEN.OP_IDENTIFIER, "=="),
             Token(None, TOKEN.IDENTIFIER, "y")
         ]),
                        stmts=[
                            AST.STMT(val=AST.RETURN(
                                expr=None))
                        ]),
         AST.CONDBRANCH(expr=None,
                        stmts=[