Пример #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)