def KBytes(value: bytes):
    # Change from python bytes repr to bytes repr in K.
    byte_repr = '{}'.format(value)
    if byte_repr.startswith("b'") and byte_repr.endswith("'"):
        byte_repr = byte_repr.replace('"', '\\"')
        byte_repr = 'b"' + byte_repr[2:-1] + '"'
    return KToken(byte_repr, 'Bytes')
예제 #2
0
def wasm_string(s: str):
    return KToken('\"%s\"' % s, 'WasmStringToken')
예제 #3
0
def KBytes(bs: bytes):
    # Change from python bytes repr to bytes repr in K.
    byte_repr = '{}'.format(bs)
    if byte_repr.startswith("b'") and byte_repr.endswith("'"):
        byte_repr = 'b"' + byte_repr[2:-1] + '"'
    return KToken(byte_repr, 'Bytes')
예제 #4
0
def KString(value: str):
    return KToken('"%s"' % value, 'String')
예제 #5
0
def KFloat(value: float):
    return KToken(str(value), 'Float')
예제 #6
0
def KInt(value: int):
    return KToken(str(value), 'Int')
import tempfile
import argparse

from functools import reduce

import pyk

from pyk.kast import combineDicts, appliedLabelStr, constLabel, underbarUnparsing, KApply, KConstant, KSequence, KVariable, KToken
from pyk.kastManip import substitute, prettyPrintKast


def printerr(msg):
    sys.stderr.write(msg + '\n')


intToken = lambda x: KToken(str(x), 'Int')
boolToken = lambda x: KToken(str(x).lower(), 'Bool')
intToBoolToken = lambda x: KToken("true" if x == '1' else "false", 'Bool')
boolToBoolStringToken = lambda x: KToken("true" if x else "false", 'Bool')
stringToken = lambda x: KToken('"' + str(x) + '"', 'String')
hashToken = lambda x: KToken(
    '"' + "".join("\\x" + str(x)[i:i + 2]
                  for i in range(2, len(str(x)), 2)) + '"', 'String')

hexIntToken = lambda x: intToken(int(x, 16))

unimplemented = lambda input: KToken('UNIMPLEMENTED << ' + str(input) + ' >>',
                                     'K')

foldr = lambda func, init: lambda xs: reduce(lambda x, y: func(y, x), xs[::-1],
                                             init)
예제 #8
0
def KBytes(bs: bytes):
    return KToken(str(bs), 'Bytes')
def KWasmString(value):
    return KToken('"%s"' % value, 'WasmStringToken')