diff --git a/.gitignore b/.gitignore index 4790153..0d20b64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ -*.o -*.hi *.pyc diff --git a/.hgignore b/.hgignore index dd75852..bb6d589 100644 --- a/.hgignore +++ b/.hgignore @@ -1,5 +1,3 @@ syntax: glob -*.o -*.hi *.pyc diff --git a/README.markdown b/README.markdown index 69cf59a..2c3bdbd 100644 --- a/README.markdown +++ b/README.markdown @@ -40,6 +40,7 @@ For 0.3: * explicitly-addressed memory locations. * generate 6502 code (either Ophis assembler or machine code `PRG` files.) * `while` loops. +* `repeat` loops. * a little demo that actually compiles and runs on a C64 emulator. For 0.4 and/or beyond: diff --git a/src/sixtypical/analyzer.py b/src/sixtypical/analyzer.py index 817b039..4de072b 100644 --- a/src/sixtypical/analyzer.py +++ b/src/sixtypical/analyzer.py @@ -3,7 +3,7 @@ import sys from sixtypical.ast import Program, Defn, Routine, Block, Instr -from sixtypical.parser import ConstantRef, LocationRef +from sixtypical.model import ConstantRef, LocationRef UNINITIALIZED = 'UNINITIALIZED' diff --git a/src/sixtypical/evaluator.py b/src/sixtypical/evaluator.py index 0f075f3..eee5a27 100644 --- a/src/sixtypical/evaluator.py +++ b/src/sixtypical/evaluator.py @@ -1,7 +1,7 @@ # encoding: UTF-8 from sixtypical.ast import Program, Defn, Routine, Block, Instr -from sixtypical.parser import ConstantRef, LocationRef +from sixtypical.model import ConstantRef, LocationRef # TODO: should not inherit from dict diff --git a/src/sixtypical/model.py b/src/sixtypical/model.py new file mode 100644 index 0000000..6d97dd7 --- /dev/null +++ b/src/sixtypical/model.py @@ -0,0 +1,30 @@ +"""Data/storage model for SixtyPical.""" + +class LocationRef(object): + def __init__(self, name): + self.name = name + + def __repr__(self): + return 'LocationRef(%r)' % self.name + + +class ConstantRef(object): + def __init__(self, value): + self.value = value + + def __repr__(self): + return 'ConstantRef(%r)' % self.value + + +# TODO type=byte + +REG_A = LocationRef('a') +REG_X = LocationRef('x') +REG_Y = LocationRef('y') + +# TODO type=bit + +FLAG_Z = LocationRef('z') +FLAG_C = LocationRef('c') +FLAG_N = LocationRef('n') +FLAG_V = LocationRef('v') diff --git a/src/sixtypical/objects.py b/src/sixtypical/objects.py deleted file mode 100644 index 99df4f2..0000000 --- a/src/sixtypical/objects.py +++ /dev/null @@ -1,31 +0,0 @@ - - -class Type(object): - pass - -class BitType(Type): - pass - -class ByteType(Type): - pass - -class MemoryLocation(object): - def __init__(self, name, type_=ByteType, readonly=False): - self.name = name - self.type_ = type_ - self.readonly = readonly - - -regA = MemoryLocation('a') -regX = MemoryLocation('x') -regY = MemoryLocation('y') - -regC = MemoryLocation('c', type=BitType) -regZ = MemoryLocation('z', type=BitType) -regN = MemoryLocation('n', type=BitType) -regV = MemoryLocation('v', type=BitType) - - -class Context(dict): - # maps MemoryLoction -> properties: uninitialized, initialized, written - pass diff --git a/src/sixtypical/parser.py b/src/sixtypical/parser.py index 31ed021..8f04d9d 100644 --- a/src/sixtypical/parser.py +++ b/src/sixtypical/parser.py @@ -3,6 +3,7 @@ import re from sixtypical.ast import Program, Defn, Routine, Block, Instr +from sixtypical.model import LocationRef, ConstantRef class Scanner(object): @@ -69,28 +70,6 @@ class Scanner(object): return False -# - - - - - - -class LocationRef(object): - def __init__(self, name): - self.name = name - - def __repr__(self): - return 'LocationRef(%r)' % self.name - - -class ConstantRef(object): - def __init__(self, value): - self.value = value - - def __repr__(self): - return 'ConstantRef(%r)' % self.value - - -# - - - - - - class Parser(object): def __init__(self, text): self.scanner = Scanner(text)