TCPS embedded/independent scripting language
NOTE: this is not a full project of mine, but rather a 2-3 day distraction to free my mind from my real projects for a bit so I can think better
It is too late to post a working program, but during my swim meet I had tonight, I decided to make an interpreter for a scripting language that is based on ProceduralBrainF*ck (Pbrain) and Toadskin, which works as a standalone interpreter and an embedded parser for dynamic Axe or Hybrid BASIC scripting. TCPS stands for Turing Complete, Procedural, Stacked scripting language. It works either by accepting arguments from a program in a (char*)array form starting in *L4, or by accepting user input asking for a program to run from at the start of the program run if no valid parameters are given in L4.
Here is an overview on how TCPS works. The scripting language starts at either the specified pointer to program data or user input program names. If in embedded mode, it creates a turing tape of specified length at a given start position, a specified number of stacks of given lengths at given locations, and starts running normally. If in input mode, all of these values are scanned for at the AT header portion of the given program. TCPS supports brainf*ck-like commands with support for math, running internal interlaced compiled assembly code, procedural declarations and runs, and stack operating. The operators:
+ - add operand to cell
- - subtract operand from cell
> - move forward one cell
< - move back one cell
[ - move to ] if current cell is 0
] - if reached with no call trace, goto matching [
( - delimit start of procedure
) - end procedure delimiting
/ - call procedure by name of following letter (if no letter follow //)
// - call procedure of index determined by value of current cell
^ - pop from current stack to current cell
* - push from current cell to current stack
= - set current stack to index determined by following letter (if none, follow ==)
== - set current stack to index determined by current cell value
{ } - delimits interlaced assembly code (compiled to .bin format), can be at most 256 bytes large per block and must end with a RETI instruction
" " - delimits inline ASCII data in the current cell
' ' - delimits inline numerical hex data inserted in the current cell
! - end script execution and prompt interpreter to clean up mess
? - if current cell is zero, end script execution and prompt interpreter to clean up mess
. - display value of current cell in ASCII
, - display value of current cell as a numerical value
Pi OP Pi - Pi symbol delimits math operand (Axe's +,-,*,/,^) taking current cell and the next cell, doing the operation, and storing to current cell
Example program (hello world), in .8xp format and started in execution by user input (non-embedded) mode:
Code:
Another example of me making a procedure that will push all of the ASCII data onto the stack, and pick out every other letter and print it. It even includes error handling! :
Code:
(prints "good day"' or "Err: WTF?" if somehow the cells wouldn't initiate correctly (memory error))
As you can see, it is glorified BF, but it can do a lot for a fast processing speed. Programs are highly polymorphic and interlaced assembly can even change program contents during execution; you have decent math capabilities; you have powerful stacks and procedure workings; hard things like error handling are simple is TCPS; it can be used from Axe code easily (you can even compile the source into part of the program, for easy access) or do it externally with hybrid BASIC (support for straight up BASIC on the way); and loads more.
Interpreter, source, example programs and program loader data, and screenies will most likely come tomorrow until then, have fun processing this wall of smarts in your head! Questions, Comments, Questions, Comments, or even Questions are welcome below!
Happy scripting,
Ashbad
NOTE: this is not a full project of mine, but rather a 2-3 day distraction to free my mind from my real projects for a bit so I can think better
It is too late to post a working program, but during my swim meet I had tonight, I decided to make an interpreter for a scripting language that is based on ProceduralBrainF*ck (Pbrain) and Toadskin, which works as a standalone interpreter and an embedded parser for dynamic Axe or Hybrid BASIC scripting. TCPS stands for Turing Complete, Procedural, Stacked scripting language. It works either by accepting arguments from a program in a (char*)array form starting in *L4, or by accepting user input asking for a program to run from at the start of the program run if no valid parameters are given in L4.
Here is an overview on how TCPS works. The scripting language starts at either the specified pointer to program data or user input program names. If in embedded mode, it creates a turing tape of specified length at a given start position, a specified number of stacks of given lengths at given locations, and starts running normally. If in input mode, all of these values are scanned for at the AT header portion of the given program. TCPS supports brainf*ck-like commands with support for math, running internal interlaced compiled assembly code, procedural declarations and runs, and stack operating. The operators:
+ - add operand to cell
- - subtract operand from cell
> - move forward one cell
< - move back one cell
[ - move to ] if current cell is 0
] - if reached with no call trace, goto matching [
( - delimit start of procedure
) - end procedure delimiting
/ - call procedure by name of following letter (if no letter follow //)
// - call procedure of index determined by value of current cell
^ - pop from current stack to current cell
* - push from current cell to current stack
= - set current stack to index determined by following letter (if none, follow ==)
== - set current stack to index determined by current cell value
{ } - delimits interlaced assembly code (compiled to .bin format), can be at most 256 bytes large per block and must end with a RETI instruction
" " - delimits inline ASCII data in the current cell
' ' - delimits inline numerical hex data inserted in the current cell
! - end script execution and prompt interpreter to clean up mess
? - if current cell is zero, end script execution and prompt interpreter to clean up mess
. - display value of current cell in ASCII
, - display value of current cell as a numerical value
Pi OP Pi - Pi symbol delimits math operand (Axe's +,-,*,/,^) taking current cell and the next cell, doing the operation, and storing to current cell
Example program (hello world), in .8xp format and started in execution by user input (non-embedded) mode:
Code:
AT
1000,L1
1,64,L2
/AT
>"Hello World!"<
+++++++++++
[>.<-]!
Another example of me making a procedure that will push all of the ASCII data onto the stack, and pick out every other letter and print it. It even includes error handling! :
Code:
AT
1000,L1
2,64,L2
/AT
>"gboaodd ddaayy"<
(P >*.< -) =A
(D ++++++++)
:D ^
=B [>^> =A* - =B]
:D [:P] ?
"Err: WTF?" :D
[.>] !
(prints "good day"' or "Err: WTF?" if somehow the cells wouldn't initiate correctly (memory error))
As you can see, it is glorified BF, but it can do a lot for a fast processing speed. Programs are highly polymorphic and interlaced assembly can even change program contents during execution; you have decent math capabilities; you have powerful stacks and procedure workings; hard things like error handling are simple is TCPS; it can be used from Axe code easily (you can even compile the source into part of the program, for easy access) or do it externally with hybrid BASIC (support for straight up BASIC on the way); and loads more.
Interpreter, source, example programs and program loader data, and screenies will most likely come tomorrow until then, have fun processing this wall of smarts in your head! Questions, Comments, Questions, Comments, or even Questions are welcome below!
Happy scripting,
Ashbad