Beispiel #1
0
def matchSymbol(s):
    from py.clojure.lang.symbol import Symbol
    from py.clojure.lang.cljkeyword import Keyword
    m = symbolPat.match(s)
    if m is not None:
        ns = m.group(1)
        name = m.group(2)
        if ns is not None and ns.endswith(":/") or name.endswith(":")\
            or s.find("::") != -1:
                return None
        if s.startswith("::"):
            return "FIX"
        ns = ns if ns is None else ns[:-1]
        iskeyword = s.find(':') == 0
        sym = symbol(ns, name[(1 if iskeyword else 0):])
        if iskeyword:
            return keyword(s)
        else:
            return sym
    return None
Beispiel #2
0
from py.clojure.lang.ipersistentmap import IPersistentMap
from py.clojure.lang.ipersistentlist import IPersistentList
from py.clojure.lang.var import Var
from py.clojure.util.byteplay import *
import py.clojure.util.byteplay as byteplay
from py.clojure.lang.cljkeyword import Keyword, keyword
import new
import py.clojure.lang.rt as RT
from py.clojure.lang.lispreader import _AMP_
from py.clojure.lang.namespace import findItem
from py.clojure.lang.lispreader import LINE_KEY, garg
import re
import new
import sys

_MACRO_ = keyword(symbol(":macro"))
version = (sys.version_info[0] * 10) + sys.version_info[1]

def emitJump(label):
    if version == 26:
        return [(JUMP_IF_FALSE, label),
                (POP_TOP, None)]
    else:
        return [(POP_JUMP_IF_FALSE, label)]

def emitLanding(label):
    if version == 26:
        return [(label, None),
                (POP_TOP, None)]
    else:
        return [(label, None)]
Beispiel #3
0
from py.clojure.lang.iref import IRef
from py.clojure.lang.ifn import IFn
from py.clojure.lang.settable import Settable
from py.clojure.lang.aref import ARef
from py.clojure.lang.cljexceptions import (ArityException,
                                           InvalidArgumentException,
                                           IllegalStateException)
from py.clojure.lang.persistenthashmap import EMPTY
from py.clojure.lang.threadutil import ThreadLocal, currentThread
from py.clojure.lang.symbol import symbol
from py.clojure.lang.cljkeyword import keyword
import persistentarraymap

privateKey = keyword(symbol("private"))
macrokey = keyword(symbol(":macro"))
dvals = ThreadLocal()
privateMeta = persistentarraymap.create([privateKey, True])
UKNOWN = symbol("UNKNOWN")


def pushThreadBindings(bindings):
    f = dvals.get(lambda: Frame())
    bmap = f.bindings
    bs = bindings.seq()
    while bs is not None:
        e = bs.first()
        v = e.getKey()
        if not v.dynamic:
            raise IllegalStateException("Can't dynamically bind non-dynamic "
                                        "var: " + str(v.ns) + "/"
                                        + str(v.sym))