Content deleted Content added
→Bytecode spec: split subsection |
|||
(12 intermediate revisions by 10 users not shown) | |||
Line 1:
'''Toi''' is an imperative, type-sensitive language that provides the basic functionality of a [[programming language]]. The language was designed and developed from the ground-up by Paul Longtine.<ref>{{cite web|url=https://github.com/bannana/language/blob/master/doc/OVERVIEW|title=bannana/language|website=[[GitHub]]|date=17 February 2021|publisher=}}</ref> Written in C, Toi was created with the intent to be an educational experience and serves as a learning tool (or toy, hence the name) for those looking to familiarize themselves with the inner-workings of a programming language.<ref>{{cite web|url=https://banna.tech/projects/post/toy_language/|title=banna - useless things|publisher=|access-date=2016-10-23|archive-date=2016-10-24|archive-url=https://web.archive.org/web/20161024151620/https://banna.tech/projects/post/toy_language/|url-status=dead}}</ref>
== Specification<ref>{{cite web|url=https://github.com/bannana/language/blob/master/doc/SPECIFICATION|title=bannana/language|website=[[GitHub]]|date=17 February 2021|publisher=}}</ref><ref>{{Cite web|url=http://dev.nanner.co/language/file/doc/SPECIFICATION.html|title=SPECIFICATION - language - some fools attempt at an interpreted language}}</ref> ==
=== [[Type (computer science)|Types]] ===
Line 64:
Scopes are handled by referencing to either the Global Scope or the Local Scope.
The Local Scope is denoted by '0' in the scope argument when referring to names,
and this scope is initialized when evaluating any new block of code. When a different block of code is called, a new scope is added as a new Namespace level. Namespace levels act as context switches within function contexts. For example, the local namespace must be 'returned to' if that local namespace context needs to be preserved on return. Pushing 'Namespace levels' ensures that for every ''n'' function calls, you can traverse ''n'' instances of previous namespaces. For example, take this namespace level graphic, where each Level is a namespace instance:
Level 0: Global namespace, LSB == '1'.
Line 161:
D<nowiki><[variable]></nowiki> - Dynamic bytecode argument.
----
Hex |
These subroutines operate on the current-working stack(1).
Line 171:
12 DUP - duplicates the top of the stack
13 ROT_THREE - rotates top three elements of stack
20 DEC S<nowiki><scope></nowiki> S<nowiki><type></nowiki> N - declare variable of type
21 LOV S<nowiki><scope></nowiki> N - loads reference variable on to stack
Line 179 ⟶ 178:
23 CTV S<nowiki><scope></nowiki> N D<nowiki><data></nowiki> - loads constant into variable
24 CTS D<nowiki><data></nowiki> - loads constant into stack
Types are in the air at this moment. I'll detail what types there are when
the time comes
----
30 [[typeof|TYPEOF]] - pushes type of TOS on to the stack TBI
31 CAST S<nowiki><type></nowiki> - Tries to cast TOS to <nowiki><type></nowiki> TBI
OPS take the two top elements of the stack, perform an operation and push
Line 208 ⟶ 207:
4D OR - or's TBI
4E XOR - xor's TBI
4F NAND - and's TBI
Things for comparison, < > = ! and so on and so forth.
Line 225 ⟶ 224:
57 OR - Boolean OR
58 AND - Boolean AND
60 STARTL - Start of loop
61 CLOOP - Conditional loop. If TOS is true, continue looping, else break
6E BREAK - Breaks out of loop
6F ENDL - End of loop
These instructions dictate code flow.
----
70 [[GOTO]] A<nowiki><addr></nowiki> - Goes to address
71 JUMPF A<nowiki><n></nowiki> - Goes forward <n> lines
72 IFDO - If TOS is TRUE, do until done, if not, jump to done
Line 247 ⟶ 245:
7E DONE - End of block
7F CALL N - Calls function, pushes return value on to STACK.
80 GETN N<nowiki><name></nowiki> - Returns variable associated with name in object
81 SETN N<nowiki><name></nowiki> - Sets the variable associated with name in object
Line 256 ⟶ 253:
83 INDEXO - Index an object, uses argument stack
84 MODO S<nowiki><OP></nowiki> - Modify an object based on op. [+, -, *, /, %, ^ .. etc.]
FF DEFUN NS<nowiki><type></nowiki> D<nowiki><args></nowiki> - Un-funs everything. no, no- it defines a
function. D is its name, S<nowiki><type></nowiki> is
Line 268 ⟶ 265:
F1 NEW S<scope> N - Instantiates class
F0 RETURN - Returns from function
00 [[Null character|NULL]] - No-op▼
▲ 00 NULL - No-op
01 LC N<nowiki><name></nowiki> - Calls OS function library, i.e. I/O, opening files, etc. TBI
02 PRINT - Prints whatever is on the TOS.
|