Toi (programming language): Difference between revisions

Content deleted Content added
m example,the->example, the - Fix a typo in one click
Tags: Mobile edit Mobile web edit Advanced mobile edit
m Reverted edits by Elahemood (talk) (HG) (3.4.13)
 
(11 intermediate revisions by 9 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 161:
D<nowiki><[variable]></nowiki> - Dynamic bytecode argument.
----
Hex | MemnonicMnemonic | arguments - description
 
----
'''1 -==== Stack manipulation''' ====
 
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
 
----
'''2 -==== Variable management''' ====
----
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
 
----
'''3 -==== Type management''' ====
 
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
 
----
'''4 -==== Binary Ops''' ====
 
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
 
----
'''5 -==== [[Conditional (computer programming)|Conditional Expressions]]''' ====
 
Things for comparison, < > = ! and so on and so forth.
Line 225 ⟶ 224:
57 OR - Boolean OR
58 AND - Boolean AND
 
----
'''6 -==== Loops''' ====
----
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
 
----
'''7 -==== Code flow''' ====
 
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.
 
----
'''8 -==== Generic object interface. Expects object on TOS''' ====
----
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.]
 
----
'''==== F - Functions/classes''' ====
 
----
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
 
----
'''0 -==== Special Bytes''' ====
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.