How to use the js2py.legecy_translators.nparser.jsdict function in Js2Py

To help you get started, we’ve selected a few Js2Py examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PiotrDabkowski / Js2Py / js2py / legecy_translators / nparser.py View on Github external
def __repr__(self):
        return str(self.__dict__)


class RegExp(object):
    def __init__(self, pattern, flags=''):
        self.flags = flags
        pyflags = 0 | re.M if 'm' in flags else 0 | re.I if 'i' in flags else 0
        self.source = pattern
        self.pattern = re.compile(pattern, pyflags)

    def test(self, s):
        return self.pattern.search(s) is not None


console = jsdict({"log": print})


def __temp__42(object=None, body=None):
    return jsdict({
        "type": Syntax.WithStatement,
        "object": object,
        "body": body,
    })


def __temp__41(test=None, body=None):
    return jsdict({
        "type": Syntax.WhileStatement,
        "test": test,
        "body": body,
    })
github PiotrDabkowski / Js2Py / js2py / legecy_translators / nparser.py View on Github external
def apply(self=None, node=None):
        if extra.range:
            node.range = [self.marker[0], self.marker[3]]
        if extra.loc:
            node.loc = jsdict({
                "start":
                jsdict({
                    "line": self.marker[1],
                    "column": self.marker[2],
                }),
                "end":
                jsdict({
                    "line": self.marker[4],
                    "column": self.marker[5],
                }),
            })
        node = delegate.postProcess(node)
github PiotrDabkowski / Js2Py / js2py / legecy_translators / nparser.py View on Github external
def skipSingleLineComment():
    global index, lineNumber, lineStart
    start = None
    loc = None
    ch = None
    comment = None
    start = index - 2
    loc = jsdict({
        "start":
        jsdict({
            "line": lineNumber,
            "column": (index - lineStart) - 2,
        }),
    })
    while index < length:
        ch = (ord(source[index]) if index < len(source) else None)
        index += 1
        index
        if isLineTerminator(ch):
            if extra.comments:
                comment = source[(start + 2):(index - 1)]
                loc.end = jsdict({
                    "line": lineNumber,
                    "column": (index - lineStart) - 1,
github PiotrDabkowski / Js2Py / js2py / legecy_translators / nparser.py View on Github external
def __temp__20(id=None, params=None, defaults=None, body=None):
    return jsdict({
        "type": Syntax.FunctionExpression,
        "id": id,
        "params": params,
        "defaults": defaults,
        "body": body,
        "rest": None,
        "generator": False,
        "expression": False,
    })
github PiotrDabkowski / Js2Py / js2py / legecy_translators / nparser.py View on Github external
def parseParams(firstRestricted=None):
    param = None
    params = []
    token = None
    stricted = None
    paramSet = None
    key = None
    message = None
    expect("(")
    if not match(")"):
        paramSet = jsdict({})
        while index < length:
            token = lookahead
            param = parseVariableIdentifier()
            key = "$" + token.value
            if strict:
                if isRestrictedWord(token.value):
                    stricted = token
                    message = Messages.StrictParamName
                if key in paramSet:
                    stricted = token
                    message = Messages.StrictParamDupe
            elif not firstRestricted:
                if isRestrictedWord(token.value):
                    firstRestricted = token
                    message = Messages.StrictParamName
                elif isStrictModeReservedWord(token.value):
github PiotrDabkowski / Js2Py / js2py / legecy_translators / nparser.py View on Github external
def __temp__18(left=None, right=None, body=None):
    return jsdict({
        "type": Syntax.ForInStatement,
        "left": left,
        "right": right,
        "body": body,
        "each": False,
    })
github PiotrDabkowski / Js2Py / js2py / legecy_translators / nparser.py View on Github external
def __temp__10(param=None, body=None):
    return jsdict({
        "type": Syntax.CatchClause,
        "param": param,
        "body": body,
    })
github PiotrDabkowski / Js2Py / js2py / legecy_translators / nparser.py View on Github external
def __temp__38(operator=None, argument=None):
    if (operator == "++") or (operator == "--"):
        return jsdict({
            "type": Syntax.UpdateExpression,
            "operator": operator,
            "argument": argument,
            "prefix": True,
        })
    return jsdict({
        "type": Syntax.UnaryExpression,
        "operator": operator,
        "argument": argument,
        "prefix": True,
    })
github PiotrDabkowski / Js2Py / js2py / legecy_translators / nparser.py View on Github external
def collectToken():
    start = None
    loc = None
    token = None
    range = None
    value = None
    skipComment()
    start = index
    loc = jsdict({
        "start":
        jsdict({
            "line": lineNumber,
            "column": index - lineStart,
        }),
    })
    token = extra.advance()
    loc.end = jsdict({
        "line": lineNumber,
        "column": index - lineStart,
    })
    if token.type != Token.EOF:
        range = [token.range[0], token.range[1]]
        value = source[token.range[0]:token.range[1]]
        extra.tokens.append(
            jsdict({
                "type": TokenName[token.type],
                "value": value,
github PiotrDabkowski / Js2Py / js2py / legecy_translators / nparser.py View on Github external
def __temp__9(callee=None, args=None):
    return jsdict({
        "type": Syntax.CallExpression,
        "callee": callee,
        "arguments": args,
    })