Question:
I have made (or was attempting to create) a turing complete novelty “pRoGrAmMiNg LaNgUaGe” and it successfully pointed to where it was going to execute, but then fails to.
Repl link:
https://replit.com/@-jpg/clank-000#main.clk
Output:
pedro? [y/n]:y
['0001', 'IF', 'IS_PEDRO', 'STR', 'y', '0002', '0003'], [0001]
found
0002
['0002', 'INP', '0000', 'RES', 'no', 'pedro', ':('], [0001]
['0003', 'INP', '0000', 'RES', 'yes', 'pedro', ':)'], [0001]
done
pedro? [y/n]:y
this is an input, the y at the end means you typed a y
['0001', 'IF', 'IS_PEDRO', 'STR', 'y', '0002', '0003'], [0001]
['0002', 'INP', '0000', 'RES', 'no', 'pedro', ':('], [0001]
['0003', 'INP', '0000', 'RES', 'yes', 'pedro', ':)'], [0001]
the first list in each line is the tokenized code. alongisde it, in brackets (so you see there is no space) is the searching pointer.
it checks if the first element of that list is it, if so, starts executing that line of code.
I guess i should explain syntax for clank while we are here
IF IS_PEDRO STR y 0002 0003
if
gets recognized by the interpreter and executes the code for it from clank_op folder
is_pedro
is the first thing to be compared, and has to be in variable form
str
tells the if
interpreter (yes there is kind-of sub interpreters) that it is gonna compare is_pedro
with a string
y
is the string
0002 0003
jump to 0002 if true, else jump to 0003
INP 0000 RES no pedro :(
inp
gets recognized by the interpreter and starts forming an input
0000
tells it to move to 0000 when done
res
variable name to write to
everything after gets written to the screen as input. i use inputs here because i made inputs before print???
found
0002
found
means it found the address
0002
means its pointing to line 0002 to start executing.
done
the processor function process()
finished pointing to and executing the data, required for any function.
if you would like to debug this by creating your own module in clank_op, set moveto
to the line you want to move to after, and proccess()
finishes this and actually moves to that address. process()
is required at the end as it leads to executing the next line of code. you also need to define read
yourself
for example, a simple if function in psuedo code:
read = line.split() # required (for input)
if this = that:
moveto = read[input number] # required for selecting line to move to
else:
moveto = read[input number] # required for above reason
process() # required (for moving to next instruction)