~jasper/type_stack_calc

0df63d46f4d2e73f0e3f0c908f527bc9e6ef97ae — Jasper den Ouden 1 year, 6 months ago 3f0c8b5
Minor, comments, add lib directory
M README.md => README.md +1 -1
@@ 1,6 1,6 @@

# WIP stack programming language
It's quite fancy, and low (~4000, `make wc` for current)LOC & no dependencies. It (initially) aims at producing C code.
It's quite fancy, and relatively low (~4100, `make wc` for current)LOC & no dependencies. It (initially) aims at producing C code.

It has a stack programming language but ideally want to convert a subset of Python to it.


M bin/tsc.py => bin/tsc.py +1 -1
@@ 28,7 28,7 @@ else:

assert __name__ == '__main__', \
    f"Only intended as program, used as {__main___}"
main = Main(paths=[sys.path[0] + "/examples/"])
main = Main(paths=[sys.path[0] + "/examples/", sys.path[0] + "/lib/"])

i = 0
while i < len(sys.argv):

M script/continuous.sh => script/continuous.sh +1 -1
@@ 26,5 26,5 @@ while true; do
    # Wake the screen locker.
    killall -0 xss-lock
    printf "\u1b[0m"
    #sh script/notify_show.sh &
    sh script/notify_show.sh &
done

M script/show.sh => script/show.sh +6 -2
@@ 40,10 40,14 @@ do_these() {
}

if [ "$FILE" == "script/show.sh" ] ; then  # Selection of them.
    time ls -rc -1 test/{integermath,sc_parser,tp/intersection}.py \
    time ls -r -c -1 test/{integermath,sc_parser,tp/intersection}.py \
        test/sets/{cases,general,range,stepping,intersection}.py \
        examples/{gravity,factorial}.tsc script/show.sh \
        | do_these /dev/null
else  # Just the latest changed one.
else  # Just the latest changed one and one random test.
    time echo "$FILE" | do_these /dev/stdout

    time ls test/{integermath,sc_parser,tp/intersection}.py \
        test/sets/{cases,general,range,stepping,intersection}.py \
        | sort -R | head -n  1 | do_these /dev/null
fi

M type_stack_calc/ib/tc_variant.py => type_stack_calc/ib/tc_variant.py +1 -1
@@ 5,7 5,7 @@
#  by the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.

"""Each combination of types on a user-defined function get's a `FunctionVariant`."""
"""Each combination of types on a user-defined function get's a (Type Calculated)`TCVariant`."""

int_big = 1 << 60


M type_stack_calc/sets/empty.py => type_stack_calc/sets/empty.py +10 -2
@@ 1,15 1,23 @@

class Empty:
    """Represents there not being any result."""
    tkey= ('empty',)

    def set_inside(_self, _y): return False
    def set_inside(_self, _y):
        """Nothing is inside, of course."""
        return False

    def set_intersect(_self, _y):
        """Makes everything else empty too."""
        return the_empty

    def set_union(_self, y): return y
    def set_union(_self, y):
        """Yields to every other thing."""
        return y

    def same_set(_self, y): return type(y) == Empty

    # Note in TC don't really expect to see it.
    def __repr__(self): return "<Empty>"  

the_empty = Empty()

M type_stack_calc/sets/range.py => type_stack_calc/sets/range.py +1 -1
@@ 312,7 312,7 @@ def iparam_from_2(name):  # TODO bit pointless just have `range_` do it.
                return getattr(self, num_attr)(y[0])
            else:
                return getattr(self, range_attr)(y)
        if isinstance(y, (int, float)):
        if isinstance(y, (int, float)):  # WARN: catches bool too!
            return getattr(self, num_attr)(y)
    return ret