예제 #1
0
def test_output():
    s = "all work and no play makes Jack a dull boy!"
    assert tokensToCode(tokenize(s)) == [(i_output, None)]
예제 #2
0
def test_create_array():
    s = "all workand no play makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_createArray, None)]
예제 #3
0
def test_mul():
    s = "all work and no lpay makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_mul, None)]
예제 #4
0
def test_div():
    s = "all work and no plya makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_div, None)]
예제 #5
0
def test_empty():
    s = "all work and no play makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == []
예제 #6
0
def test_sub():
    s = "all work and no play mkaes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_sub, None)]
예제 #7
0
def test_dup():
    s = "all work aand no play makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_dup, None)]
예제 #8
0
def test_add():
    s = "all work and no paly makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_add, None)]
예제 #9
0
def test_swap():
    s = "all wrk and no play makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == [(i_swap, None)]
예제 #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)]
예제 #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)]
예제 #12
0
def test_label_only():
    s = "All Work and no play makes Jack a dull boy"
    assert tokensToCode(tokenize(s)) == []
예제 #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)