Toi (programming language): Difference between revisions

Content deleted Content added
Rjgordon (talk | contribs)
No edit summary
Yobot (talk | contribs)
m WP:CHECKWIKI error fixes, added uncategorised, deadend tags using AWB
Line 1:
{{Dead end|date=October 2016}}
'''Toy''' 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>https://github.com/bannana/language/blob/master/doc/OVERVIEW</ref>. Written in C, Toy 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>https://banna.tech/projects/post/toy_language/</ref>.
 
== Specification<ref>https://github.com/bannana/language/blob/master/doc/SPECIFICATION</ref> ==
 
 
== Specification<ref>https://github.com/bannana/language/blob/master/doc/SPECIFICATION</ref> ==
=== Types ===
0 VOID - Null, no data
Line 31:
** The operating stack where current running instructions push/pop to.
*** refer to STACK DEFINITION
 
* Namespace instance
** Data structure that holds the references to variable containers, also proving the interface for Namespace Levels.
*** refer to NAMESPACE DEFINITION
 
* Arguement stack
** Arguments to function calls are pushed on to this stack, flushed on call.
*** refer to STACK DEFINITION, FUNCTION DEFINITION
 
* Program counter
** An interface around bytecode to keep track of traversing line-numbered instructions.
Line 79 ⟶ 76:
Level 1: Namespace level.
Level 2: Namespace level, where Local Level is at 2, LSB == '0'.
 
 
Global scope names (LSB == 1 in the scope arguement) are persistient
Line 89 ⟶ 85:
When the namespace arguement equals 0, the current namespace is referenced.
The global namespace is 1 by default, and any other namespaces must be declared
by using the
 
==== VARIABLE DEFINITION ====
Line 166 ⟶ 162:
A<[variable]> - Address Arguement.
D<[variable]> - Dynamic bytecode arguement.
----
-------------------------------------------------------------------------------
Hex | Memnonic | arguments - description
----
-------------------------------------------------------------------------------
'''1 - Stack manipulation'''
 
These subroutines operate on the current-working stack(1).
----
-------------------------------------------------------------------------------
10 POP S<n> - pops the stack n times.
11 ROT - rotates top of stack
12 DUP - duplicates the top of the stack
13 ROT_THREE - rotates top three elements of stack
----
-------------------------------------------------------------------------------
'''2 - Variable management'''
----
-------------------------------------------------------------------------------
20 DEC S<scope> S<type> N<ref> - declare variable of type
21 LOV S<scope> N<ref> - loads reference variable on to stack
22 STV S<scope> N<ref> - stores TOS to reference variable
23 CTV S<scope> N<ref> D<data> - loads constant into variable
24 CTS D<data> - 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 - pushes type of TOS on to the stack TBI
31 CAST S<type> - Tries to cast TOS to <type> TBI
----
-------------------------------------------------------------------------------
'''4 - Binary Ops'''
OPS take the two top elements of the stack, preform an operation and push
the result on the stack.
----
-------------------------------------------------------------------------------
40 ADD - adds
41 SUB - subtracts
Line 214 ⟶ 210:
4E XOR - xor's TBI
4F NAND - and's TBI
----
-------------------------------------------------------------------------------
'''5 - Conditional Expressions'''
 
Line 220 ⟶ 216:
Behaves like Arithmetic instructions, besides NOT instruction. Pushes boolean
to TOS
----
-------------------------------------------------------------------------------
50 GTHAN - Greater than
51 LTHAN - Less than
Line 230 ⟶ 226:
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<addr> - Goes to address
71 JUMPF A<n> - Goes forward <n> lines
Line 251 ⟶ 247:
7D ERR - Start error block, uses TOS to evaluate error TBI
7E DONE - End of block
7F CALL N<ref> - Calls function, pushes return value on to STACK.
----
-------------------------------------------------------------------------------
'''8 - Generic object interface. Expects object on TOS'''
----
-------------------------------------------------------------------------------
80 GETN N<name> - Returns variable assosiated with name in object
 
Line 265 ⟶ 261:
 
84 MODO S<OP> - Modify an object based on op. [+, -, *, /, %, ^ .. etc]
----
-------------------------------------------------------------------------------
F - Functions/classes
----
-------------------------------------------------------------------------------
FF DEFUN N<ref> S<type> D<args> - Un-funs everything. no, no- it defines a
function. D<ref> is its name, S<type> is
the return value, D<args> is the args.
 
FE DECLASS N<ref> D<args> - Defines a class.
 
FD DENS S<ref> - Declares namespace
 
F2 ENDCLASS - End of class block
 
F1 NEW S<scope> N<ref> - Instantiates class
F0 RETURN - Returns from function
----
-------------------------------------------------------------------------------
'''0 - SPECIAL BYTES'''
----
-------------------------------------------------------------------------------
00 NULL - No-op
 
Line 294 ⟶ 290:
0E ARGB - Builds arguement stack
 
0F PC S<ref> - Primitive call, calls a subroutine A<ref>. A list of TBI
primitive subroutines providing methods to tweak
objects this bytecode set cannot touch. Uses argstack.
 
=== Compiler/Translator/Assembler ===
 
 
==== LEXICAL ANALYSIS ====
Line 350 ⟶ 345:
that will take arguemets specified and lookahead and lookbehind to formulate the
correct bytecode equivilent.
 
==References==
{{Reflist}}
 
{{Uncategorized|date=October 2016}}