예제 #1
0
def externVar(parser):
    target = parser.nextToken()

    if target.type != "identifier":
        Error.parseError(parser, "expecting target")

    target = target.token

    if not target in ["client", "full", "node"]:
        Error.parseError(parser, target + " is not a valid compilation target")

    VarParser.createAndAssignParser(parser)
    parser.currentNode.nodes[-1].extern = True
    parser.currentNode.nodes[-1].global_target = target
    parser.currentNode.nodes[-1].nodes[1].extern = True
예제 #2
0
def externVar(parser):
    VarParser.createAndAssignParser(parser, imutable=True)
    parser.currentNode.nodes[-1].extern = True
    parser.currentNode.nodes[-1].nodes[1].extern = True
예제 #3
0
def func(parser):
    place = Tree.Lambda(parser)
    parser.currentNode.addNode(place)

    brace = Tree.FuncBraceOpen(parser)
    place.addNode(brace)

    parser.currentNode = brace

    b = parser.nextToken()

    count = -1

    while parser.thisToken().token != "|":
        if b.type == "identifier" and parser.lookInfront().token != ":":
            count += 1

            def callback(typ):
                print(u.varName, "changed to", typ)

            u = Types.Unknown(parser, callback)
            u.varName = parser.thisToken().token
            VarParser.createParser(parser, b, typ=u, check=False)
            b = parser.nextToken()
            continue
        elif parser.thisToken().token == ":":
            count += 1
        elif b.token == ",":
            b = parser.nextToken()
            continue

        Parser.declareOnly(parser)
        b = parser.nextToken()

    vars = [i.varType for i in brace]

    typ = False
    do = False

    parser.nextToken()

    place.returnTyp = False
    if parser.thisToken().token == "->":
        parser.nextToken()
        typ = Types.parseType(parser)
        place.returnTyp = True
        parser.nextToken()

    body = Tree.FuncBody(parser)

    place.addNode(body)
    parser.currentNode = body

    if parser.thisToken().token == "do":
        do = True
        parser.nextToken()

    brace.do = do
    brace.body = body
    body.do = do

    first = True

    parser.iter -= 1

    while not Parser.isEnd(parser):
        parser.nextToken()
        Parser.callToken(parser, lam=first)
        first = False

    ExprParser.endExpr(parser)
    place.args = vars
    place.returnTyp = typ

    place.do = do

    parser.currentNode = place.owner
예제 #4
0
def func(parser):
    place = Tree.Lambda(parser)
    parser.currentNode.addNode(place)

    brace = Tree.FuncBraceOpen(parser)
    place.addNode(brace)

    parser.currentNode = brace

    b = parser.nextToken()

    count = -1

    while parser.thisToken().token != "|":
        count += 1

        if b.type == "identifier":
            VarParser.createParser(parser,
                                   b,
                                   typ=Types.Unknown(count, place),
                                   check=False)
            b = parser.nextToken()
            continue
        elif b.token == ",":
            b = parser.nextToken()
            continue

        Parser.declareOnly(parser)
        b = parser.Parser.nextToken(parser)

    vars = [i.varType for i in brace]

    typ = False
    do = False

    if parser.nextToken().token == "->":
        typ = Types.parseType(parser)

    body = Tree.FuncBody(parser)

    place.addNode(body)
    parser.currentNode = body

    if parser.thisToken().token == "do":
        do = True
        parser.nextToken()

    brace.do = do
    brace.body = body
    body.do = do

    first = True

    while not Parser.isEnd(parser):
        Parser.callToken(parser, lam=first)
        parser.nextToken()
        first = False

    ExprParser.endExpr(parser)

    if typ:
        place.type = Types.Lambda(place, vars, typ=typ, do=do)
    else:
        place.type = Types.Lambda(place, vars, do=do)

    parser.currentNode = place.owner
예제 #5
0
def index(parser, name):
    parser.currentNode.nodes.pop()

    parser.nextToken()

    VarParser.read(parser, parser.thisToken().token, package= name)
예제 #6
0
def index(parser, name):
    parser.currentNode.nodes.pop()

    parser.nextToken()

    VarParser.read(parser, parser.thisToken().token, package=name)