Ejemplo n.º 1
0
def test_output():
    s = "all work and no play makes Jack a dull boy!"
    assert tokensToCode(tokenize(s)) == [(i_output, None)]
Ejemplo n.º 2
0
def test_create_array():
    s = "all workand no play makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_createArray, None)]
Ejemplo n.º 3
0
def test_mul():
    s = "all work and no lpay makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_mul, None)]
Ejemplo n.º 4
0
def test_div():
    s = "all work and no plya makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_div, None)]
Ejemplo n.º 5
0
def test_empty():
    s = "all work and no play makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == []
Ejemplo n.º 6
0
def test_sub():
    s = "all work and no play mkaes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_sub, None)]
Ejemplo n.º 7
0
def test_dup():
    s = "all work aand no play makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_dup, None)]
Ejemplo n.º 8
0
def test_add():
    s = "all work and no paly makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_add, None)]
Ejemplo n.º 9
0
def test_swap():
    s = "all wrk and no play makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_swap, None)]
Ejemplo n.º 10
0
def test_push_marker():
    s = "all work a nd no play makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_pushMarker, None)]
Ejemplo n.º 11
0
def test_push_integer2():
    s = "all work abnd noz play makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_pushInteger, 2),
                                         (i_pushInteger, 26)]
Ejemplo n.º 12
0
def test_label_only():
    s = "All Work and no play makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == []
Ejemplo n.º 13
0
from dull.lexer import tokenize
from dull.assembler import tokensToCode
from dull.runtime import run

import sys

if len(sys.argv) < 2:
    print("Usage: python -m dull <srcfile>")
    sys.exit(1)

srcfile = sys.argv[1]
with open(srcfile, "r") as f:
    lines = f.readlines()
    src = "".join(lines)
    code = tokensToCode(tokenize(src))
    #print("DEBUG code=%s" % (code,))
    run(code)