Cogc
Jump to navigation
Jump to search
Cogc (close/open/gotvat/comvar) is a asembeld langege where you need to open every stack and goto every var.
Evrything which suronded by :
are eval as python code.
Example:add :1+ord(' '):
>> add 33
Cogc types
- var : vat is a 8 bit int
- stack : stack is both a namespace and an 8 bit stack
Cogc commands
- create {var} : create {var}
- delete {var} : delete {var} (note that at end of program all vars will be deleted)
- gotvar {var} : goto {var}
- comvar {var} : come from {var}
- add {int} : increments the curent var by {int}
- sub {int} : decrements the curent var by {int}
- input : read one character into current var
- print : print current var as ascii
- while : while current var is not 0
- end : end of while statment
- open {stack} : goto {stack} and set namespace to {stack}
- close {stacl} : come from {stack} and set namespace to global
- push : push 'var' to current open stack and create new 'var' (NOTE: namespace should be cleard)
- pop : pop current open stack create old 'var' (NOTE: namespace should be cleard)
When a stack is open the special variable 'var' is reserved to be the top of stack. '#' is comment. Stacks are created automatecly, no need to create them manualy.
Example truth machene code:
create inp create _cp create _check gotvar _check add 1 comvar _check gotvar inp input print sub :ord('0'): while comvar inp gotvar _check sub 1 comvar _check gotvar inp while comvar inp gotvar _cp add 1 comvar _cp gotvar inp end end comvar inp gotvar _check while comvar _check gotvar _cp print comvar _cp gotvar _check end
Example stack:
create a # creates global a gotvar a add :ord('a'): print # prints a comvar a open stack create a # creates local a govar a add :ord('b'): print # prints b comvar a gotvar var add :ord('c'): comvar var delete a # only 'var' can remain push gotvar var add :ord('d'): print # prints d comvar var pop gotvar var print # prints c comvar var close stack open other gotvar var add :ord('e'): print # prints e comvar var close other open stack gotvar var print # prints c comvar var close stack