예제 #1
0
파일: parser.py 프로젝트: W-M-T/gsc
def StmtRet():
    yield ps.token(TOKEN.RETURN)
    found_expr = yield ps.times(Exp, 0, 1)
    found_expr = found_expr[0] if len(found_expr) > 0 else None
    yield ps.token(TOKEN.SEMICOLON)
    return AST.RETURN(expr=found_expr)
예제 #2
0
                 Token(None, TOKEN.IDENTIFIER, "y")
             ],
             type=None,
             vardecls=[],
             stmts=[]),
 AST.FUNDECL(kind=FunKind.INFIXR,
             fixity=Token(None, TOKEN.INT, 4),
             id=Token(None, TOKEN.OP_IDENTIFIER, "^^"),
             params=[
                 Token(None, TOKEN.IDENTIFIER, "x"),
                 Token(None, TOKEN.IDENTIFIER, "y")
             ],
             type=None,
             vardecls=[],
             stmts=[
                 AST.STMT(val=AST.RETURN(expr=None)),
                 AST.STMT(val=AST.RETURN(expr=None))
             ]),
 AST.FUNDECL(
     kind=FunKind.FUNC,
     fixity=None,
     id=Token(None, TOKEN.OP_IDENTIFIER, "fib2"),
     params=[
         Token(None, TOKEN.IDENTIFIER, "xtup"),
         Token(None, TOKEN.IDENTIFIER, "y"),
         Token(None, TOKEN.IDENTIFIER, "z")
     ],
     type=AST.FUNTYPE(from_types=[
         AST.TUPLETYPE(
             a=AST.TYPE(val=AST.BASICTYPE(type_id=Token(
                 None, TOKEN.TYPE_IDENTIFIER, "Char"))),