示例#1
0
文件: parser.py 项目: AllenWeb/gypsum
 def process(parsed, loc):
     parsed = ct.untangle(parsed)
     if len(parsed) == 2:
         return parsed[0]
     else:
         sty = parsed[0]
         tps = parsed[3]
         return ast.ExistentialType(sty, tps, loc)
示例#2
0
文件: parser.py 项目: AllenWeb/gypsum
 def process(parsed, loc):
     prefixComponents, nullFlag = ct.untangle(parsed)
     prefix = prefixComponents[:-1]
     last = prefixComponents[-1]
     name = last.name
     typeArgs = last.typeArguments if last.typeArguments is not None else []
     flags = set([nullFlag]) if nullFlag is not None else set()
     return ast.ClassType(prefix, name, typeArgs, flags, loc)
示例#3
0
文件: parser.py 项目: AllenWeb/gypsum
def processCall(receiver, parsed, loc):
    [methodName, typeArguments, arguments, isGetMethod] = ct.untangle(parsed)
    if isGetMethod:
        if methodName is None or \
           typeArguments is not None or \
           arguments is not None:
            return ct.FailValue()
        return ast.FunctionValueExpression(ast.PropertyExpression(receiver, methodName, loc), loc)
    elif methodName is not None or \
         typeArguments is not None or \
         arguments is not None:
        hasArguments = typeArguments is not None or arguments is not None
        if methodName is not None:
            method = ast.PropertyExpression(receiver, methodName, loc)
        else:
            method = receiver
        if hasArguments:
            return ast.CallExpression(method, typeArguments, arguments, loc)
        else:
            return method
    else:
        return ct.FailValue("not a call")
示例#4
0
文件: parser.py 项目: AllenWeb/gypsum
 def process(parsed, loc):
     [attrs, _, elementType, _, getName, _, setName, _, lengthName, _] = ct.untangle(parsed)
     return ast.ArrayElementsStatement(attrs, elementType,
                                          getName, setName, lengthName, loc)
示例#5
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     if parsed is None:
         return None, None
     else:
         [_, supertype, args] = ct.untangle(parsed)
         return supertype, args
示例#6
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     [ats, _, params, _] = ct.untangle(parsed)
     return ast.AstPrimaryConstructorDefinition(ats, params, loc)
示例#7
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     [ats, _, name, tps, ps, rty, body, _] = ct.untangle(parsed)
     return ast.AstFunctionDefinition(ats, name, tps, ps, rty, body, loc)
示例#8
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     [ats, kw, pat, expr, _] = ct.untangle(parsed)
     return ast.AstVariableDefinition(ats, kw, pat, expr, loc)
示例#9
0
文件: parser.py 项目: zpzgone/gypsum
 def processSimple(parsed, loc):
     [_, p, _, e] = ct.untangle(parsed)
     return ast.AstPartialFunctionExpression([ast.AstPartialFunctionCase(p, None, e, loc)], loc)
示例#10
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     [_, _, e, _, m] = ct.untangle(parsed)
     return ast.AstMatchExpression(e, m, loc)
示例#11
0
文件: parser.py 项目: AllenWeb/gypsum
 def process(parsed, loc):
     _, _, tps, _, ty = ct.untangle(parsed)
     return ast.ExistentialType(tps, ty, loc)
示例#12
0
文件: parser.py 项目: AllenWeb/gypsum
 def process(parsed, loc):
     _, first, _, rest, _, nullFlag = ct.untangle(parsed)
     flags = set([nullFlag]) if nullFlag else set()
     return ast.TupleType([first] + rest, flags, loc)
示例#13
0
文件: parser.py 项目: AllenWeb/gypsum
 def process(parsed, loc):
     _, p, _ = ct.untangle(parsed)
     return p
示例#14
0
文件: parser.py 项目: AllenWeb/gypsum
 def processSuffix(parsed, loc):
     return ct.untangle(parsed)[1]
示例#15
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     [_, _, c, _, b] = ct.untangle(parsed)
     return ast.AstWhileExpression(c, b, loc)
示例#16
0
文件: parser.py 项目: AllenWeb/gypsum
 def process(parsed, loc):
     [_, _, length, _, ty, args] = ct.untangle(parsed)
     return ast.NewArrayExpression(length, ty, args, loc)
示例#17
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     [_, p, c, _, e, _] = ct.untangle(parsed)
     return ast.AstPartialFunctionCase(p, c, e, loc)
示例#18
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     [ats, var, name, upper, lower] = ct.untangle(parsed)
     return ast.AstTypeParameter(ats, var, name, upper, lower, loc)
示例#19
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     [_, e, c, f] = ct.untangle(parsed)
     if c is None and f is None:
         return ct.FailValue("expected 'catch' or 'finally' in 'try'-expression")
     else:
         return ast.AstTryCatchExpression(e, c, f, loc)
示例#20
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     [ats, var, pat] = ct.untangle(parsed)
     return ast.AstParameter(ats, var, pat, loc)
示例#21
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     [_, n, tps, _, ps, _, b] = ct.untangle(parsed)
     return ast.AstLambdaExpression(n, tps, ps, b, loc)
示例#22
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     name, typeArgs, nullFlag = ct.untangle(parsed)
     typeArgs = [] if typeArgs is None else typeArgs
     flags = set([nullFlag]) if nullFlag else set()
     return ast.AstClassType(name, typeArgs, flags, loc)
示例#23
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     [_, ast, _] = ct.untangle(parsed)
     return ast
示例#24
0
文件: parser.py 项目: zpzgone/gypsum
def callSuffix():
    methodNameOpt = ct.Opt(keyword(".") + symbol ^ (lambda p, _: p[1]))
    argumentsOpt = ct.Opt(keyword("(") + ct.RepSep(ct.Lazy(expression), keyword(",")) + keyword(")")) ^ \
        (lambda p, _: ct.untangle(p)[1] if p else None)
    getMethodOpt = ct.Opt(keyword("_")) ^ (lambda p, _: bool(p))
    return methodNameOpt + typeArguments() + argumentsOpt + getMethodOpt
示例#25
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     [ats, _, name, tps, ctor, sty, sargs, ms, _] = ct.untangle(parsed)
     return ast.AstClassDefinition(ats, name, tps, ctor, sty, sargs, ms, loc)
示例#26
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, _):
     [_, e, _] = ct.untangle(parsed)
     return e
示例#27
0
文件: parser.py 项目: zpzgone/gypsum
 def processArgs(parsed, loc):
     return ct.untangle(parsed)[1] if parsed is not None else []
示例#28
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, loc):
     [_, _, c, _, t, f] = ct.untangle(parsed)
     return ast.AstIfExpression(c, t, f, loc)
示例#29
0
文件: parser.py 项目: zpzgone/gypsum
 def process(parsed, _):
     return ct.untangle(parsed)[1] if parsed else []
示例#30
0
文件: parser.py 项目: AllenWeb/gypsum
 def process(parsed, loc):
     _, prefix, suffixFn, _ = ct.untangle(parsed)
     bindings = suffixFn(prefix)
     return ast.ImportStatement(prefix, bindings, loc)