Fmt.
This commit is contained in:
parent
bd880213de
commit
d5d63fd7e8
16 changed files with 38 additions and 37 deletions
|
@ -17,10 +17,9 @@ from . import (
|
|||
from .v0 import PackageV0, ProfileV0
|
||||
from .v1 import PackageV1, ProfileV1
|
||||
|
||||
from vfs import Vfs
|
||||
|
||||
import click
|
||||
from toposort import toposort_flatten
|
||||
from vfs import Vfs
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
|
@ -11,9 +11,8 @@ from typing import List, Optional, Union
|
|||
|
||||
from .common import Package, sh, stow
|
||||
|
||||
from vfs import Vfs
|
||||
|
||||
import toml
|
||||
from vfs import Vfs
|
||||
|
||||
|
||||
def tempf(name):
|
||||
|
|
|
@ -10,4 +10,3 @@ from ichor.bootstrap import * # noqa
|
|||
from ichor.impl import * # noqa
|
||||
from ichor.isa import * # noqa
|
||||
from ichor.typing import * # noqa
|
||||
from ichor.assembler import *
|
||||
|
|
|
@ -4,7 +4,13 @@
|
|||
ichor entrypoint
|
||||
"""
|
||||
|
||||
from . import Opcode, Interpreter, BOOTSTRAP, XOR3, NOT1, TRUE, FALSE
|
||||
from . import (
|
||||
BOOTSTRAP,
|
||||
Interpreter,
|
||||
NOT1,
|
||||
Opcode,
|
||||
TRUE,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from dataclasses import dataclass
|
||||
from random import choices
|
||||
from string import ascii_lowercase, digits
|
||||
from typing import Generator, List, Union, Optional, Sequence
|
||||
from typing import List, Optional, Sequence, Union
|
||||
|
||||
from ichor import isa
|
||||
|
||||
|
||||
def gensym(prefix = None) -> isa.Label:
|
||||
frag = ''.join(choices(ascii_lowercase + digits, k=8))
|
||||
frag = "".join(choices(ascii_lowercase + digits, k=8))
|
||||
return isa.Label(f"{prefix or 'gensym'}_{frag}")
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ Hopefully no "real" interpreter ever uses this code, since it's obviously replac
|
|||
|
||||
from ichor import isa
|
||||
from ichor.state import Module, Variant
|
||||
from ichor.assembler import FuncBuilder
|
||||
|
||||
|
||||
BOOTSTRAP = Module()
|
||||
|
@ -15,8 +14,8 @@ BOOL = BOOTSTRAP.define_type(
|
|||
";bool;true(),false()",
|
||||
)
|
||||
|
||||
TRUE = Variant(BOOL, 'true', ())
|
||||
FALSE = Variant(BOOL, 'false', ())
|
||||
TRUE = Variant(BOOL, "true", ())
|
||||
FALSE = Variant(BOOL, "false", ())
|
||||
|
||||
NOT1 = BOOTSTRAP.define_function(
|
||||
f";not;{BOOL};{BOOL}",
|
||||
|
|
|
@ -10,11 +10,19 @@ context (a virtual machine) which DOES have an easily introspected and serialize
|
|||
|
||||
|
||||
from copy import deepcopy
|
||||
import typing as t
|
||||
from textwrap import indent
|
||||
|
||||
from ichor import isa
|
||||
from ichor.state import Closure, FunctionRef, Identifier, Module, Function, Type, TypeRef, VariantRef, Variant, Stackframe
|
||||
from ichor.state import (
|
||||
Closure,
|
||||
FunctionRef,
|
||||
Identifier,
|
||||
Module,
|
||||
Stackframe,
|
||||
TypeRef,
|
||||
Variant,
|
||||
VariantRef,
|
||||
)
|
||||
|
||||
|
||||
class InterpreterError(Exception):
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
from abc import ABC
|
||||
from dataclasses import dataclass
|
||||
import typing as t
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -239,4 +238,3 @@ class VLOAD(Opcode):
|
|||
@dataclass
|
||||
class BREAK(Opcode):
|
||||
"""Abort the interpreter."""
|
||||
pass
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
import typing as t
|
||||
|
||||
from ichor import isa
|
||||
|
||||
from pyrsistent import pdeque, PDeque
|
||||
from lark import Lark, Transformer, v_args, Token
|
||||
from lark import Lark, Token, Transformer, v_args
|
||||
|
||||
|
||||
class Identifier(t.NamedTuple):
|
||||
|
@ -62,7 +60,7 @@ class FuncT(Transformer):
|
|||
return name
|
||||
|
||||
|
||||
FUNC = Lark(GRAMMAR, start="fun", parser='lalr', transformer=FuncT())
|
||||
FUNC = Lark(GRAMMAR, start="fun", parser="lalr", transformer=FuncT())
|
||||
|
||||
|
||||
class FunctionRef(t.NamedTuple):
|
||||
|
@ -120,7 +118,7 @@ class TypeT(FuncT):
|
|||
|
||||
|
||||
|
||||
TYPE = Lark(GRAMMAR, start="var", parser='lalr', transformer=TypeT())
|
||||
TYPE = Lark(GRAMMAR, start="var", parser="lalr", transformer=TypeT())
|
||||
|
||||
|
||||
class TypeRef(t.NamedTuple):
|
||||
|
|
|
@ -6,12 +6,7 @@ from abc import ABC
|
|||
from dataclasses import dataclass
|
||||
import typing as t
|
||||
|
||||
from shoggoth.types import (
|
||||
Keyword,
|
||||
List,
|
||||
Symbol,
|
||||
Vec,
|
||||
)
|
||||
from shoggoth.types import Keyword, List, Symbol
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from ichor import Interpreter, BOOTSTRAP
|
||||
|
||||
from ichor import BOOTSTRAP, Interpreter
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from ichor import FuncBuilder, isa
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def builder() -> FuncBuilder:
|
||||
return FuncBuilder()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
from .fixtures import * # noqa
|
||||
|
||||
from ichor import isa, TRUE, FALSE, NOT1
|
||||
from ichor import FALSE, isa, NOT1, TRUE
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,12 @@ Tests coverign the VM interpreter
|
|||
|
||||
from .fixtures import * # noqa
|
||||
|
||||
from ichor import isa, InterpreterError, TRUE, FALSE
|
||||
from ichor import (
|
||||
FALSE,
|
||||
InterpreterError,
|
||||
isa,
|
||||
TRUE,
|
||||
)
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from ichor.state import FUNC, TYPE
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize('sig,parse', [
|
||||
@pytest.mark.parametrize("sig,parse", [
|
||||
(";not;bool;bool", ((), "not", ("bool",), ("bool",))),
|
||||
(";and;bool,bool;bool", ((), "and", ("bool", "bool"), ("bool",))),
|
||||
(";or;bool,bool,bool;bool", ((), "or", ("bool", "bool", "bool"), ("bool",))),
|
||||
|
@ -14,7 +13,7 @@ def test_func_parses(sig, parse):
|
|||
assert FUNC.parse(sig) == parse
|
||||
|
||||
|
||||
@pytest.mark.parametrize('sig,parse', [
|
||||
@pytest.mark.parametrize("sig,parse", [
|
||||
(";bool;true(),false()", ((), "bool", (("true", ()), ("false", ())))),
|
||||
("A,B;pair;pair(a:A,b:B)", (("A", "B"), "pair", (("pair", (("a", "A"), ("b", "B"))),))),
|
||||
])
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
"""Tests covering the Ichor ISA and state model."""
|
||||
|
||||
from ichor.impl import Stackframe
|
||||
from ichor.state import *
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue