toka.nbk: Home | Index | Previous Page: WordClasses
These are words that are built into the Toka executable. If the bootstrap.toka can not be found, these are the only words that will be provided.
<< ( ab-c ) Shift 'a' left by 'b' bits
>> ( ab-c ) Shift 'a' right by 'b' bits
and ( ab-c ) Perform a bitwise AND
or ( ab-c ) Perform a bitwise OR
xor ( ab-c ) Perform a bitwise XOR
#args ( -n ) Return the number of arguments
arglist ( -a ) Return a pointer to the
argument list.
< ( ab-f ) Compare 'a' and 'b', return
a flag
> ( ab-f ) Compare 'a' and 'b', return
a flag
= ( ab-f ) Compare 'a' and 'b', return
a flag
<> ( ab-f ) Compare 'a' and 'b', return
a flag
. ( n- ) Display the TOS
emit ( c- ) Display the ASCII character
for TOS
type ( a- ) Display a string
bye ( - ) Quit Toka
# ( n- ) Push the following cell to
the stack.
@ ( a-n ) Fetch the value in memory
location 'a'
! ( na- ) Store 'n' to memory location
'a'
c@ ( a-n ) Fetch a byte from memory
location 'a'
c! ( na- ) Store byte 'n' to memory
location 'a'
copy ( sdc- ) Copy 'c' bytes from 's' to
'd'
cell-size ( -n ) Return the size of a cell
char-size ( -n ) Return the size of a char
:stack ( - ) Display all values on the
data stack
:stat ( - ) Display information about
Toka's memory use, stacks,
and dictionary.
:see ( "- ) Decompile the specified quote
is ( a"- ) Attach a name to a quote
( a$- ) Non-parsing form
is-macro ( a"- ) Attach a name to a quote
( a$- ) Non-parsing form
is-data ( a"- ) Attach a name to data memory
( a$- ) Non-parsing form
` ( "-a ) Return a quote corresponding
to the specified word.
( $-a ) Non-parsing form
:name ( n-$ ) Return the name of a dictionary entry
:xt ( n-a ) Return the address of a dictionary entry
:class ( n-n ) Return the class # of a dictionary entry
from ( "- ) Set the library to import from
( $- ) Non-parsing form
import ( n"- ) Import a function taking 'n'
arguments.
( n$- ) Non-parsing form
as ( "- ) Rename the last defined word
( $- ) Non-parsing form
file.open ( $m-n ) Open a specified file with
the specified mode.
file.close ( n- ) Close the specified file handle
file.read ( nbl-r ) Read 'l' bytes into buffer 'b'
from file handle 'n'. Returns
the number of bytes read.
file.write ( nbl-w ) Write 'l' bytes from buffer 'b'
to file handle 'n'. Returns
the number of bytes written.
file.size ( n-s ) Return the size (in bytes)
of the specified file.
file.seek ( nom-a ) Seek a new position in the
file. Valid modes are
START, CURRENT, and END. These
have values of 1, 2, and 3.
file.pos ( n-a ) Return a pointer to the current
offset into the file.
keep ( a-a ) Mark quotes/allocated memory
as permanent.
gc ( - ) Clean the garbage
malloc ( n-a ) Allocate 'n' bytes of memory
heap ( -a ) Variable pointing to the top
of the local heap
compiler ( -a ) Variable holding the compiler
state
count ( a-ac ) Return an address/count pair
for a string
+ ( ab-c ) Add TOS and NOS
- ( ab-c ) Subtract TOS from NOS
* ( ab-c ) Multiply TOS by NOS
/mod ( ab-cd ) Divide and get remainder
base ( -a ) Variable containg the current
numeric base
parser ( -a ) Variable holding current parser
mode.
escape-sequences ( -a) Variable determining if
escape sequences are used.
>number ( a-nf ) Attempt to convert a string
to a number
parse ( d-a ) Parse until the character
represented by 'd' is found.
Return a pointer to the string
include ( "- ) Attempt to open a file and
add it to the input stack.
( $- ) Non-parsing form
needs ( "- ) Attempt to include a file
from the library (normally
/usr/share/toka/library)
( $- ) Non-parsing form
end. ( - ) Remove the current file from
the input stack
[ ( -a ) Create a new quote
] ( - ) Close an open quote
invoke ( a- ) Execute a quote
compile ( a- ) Compile the code needed to call 'a'
iterate ( na- ) Execute a quote 'n' times
+iterate ( na- ) Execute a quote 'n' times
ifTrueFalse ( fab- ) Invoke 'a' if 'f' flag is
true, 'b' if false.
recurse ( - ) Compile a call to the top
quote.
i ( -n ) Return the current loop index
whileTrue ( a- ) Execute quote. If the quote
returns TRUE, execute again.
otherwise end the cycle.
whileFalse ( a- ) Execute quote. If the quote
returns FALSE, execute again.
otherwise end the cycle.
dup ( n-nn ) Duplicate the TOS
drop ( n- ) Drop the TOS
swap ( ab-ba ) Exchange the TOS and NOS
>r ( n- ) Push TOS to return stack, DROP
r> ( -n ) Pop TORS to the data stack
depth ( -n ) Return the number of items
on the stack
These are additional words, provided in bootstrap.toka. They significantly expand the core language.
#! ( "- ) Parse to the end of the line
and scrap the results.
( ( "- ) Parse until ) is found and scrap
the results
.PRIM_WORD ( -n ) Class # for primitive words
.PRIM_MACRO ( -n ) Class # for primitive macros
.DATA ( -n ) Class # for data elements
.WORD ( -n ) Class # for quote words
.MACRO ( -n ) Class # for quote macros
SPACE ( -n ) ASCII value for SPACE character
CR ( -n ) ASCII value for CR character
LF ( -n ) ASCII value for LF character
ESC ( -n ) ASCII value for ESC character
TAB ( -n ) ASCII value for TAB character
wsparse ( -a ) Parse until a SPACE is encountered
lnparse ( -a ) Parse to the end of the line,
leave the resulting string on the
stack.
FALSE ( -f ) Value returned for FALSE
TRUE ( -f ) Value returned for TRUE
ifTrue ( fq- ) Execute quote ('q') if flag ('f') is TRUE
ifFalse ( fq- ) Execute quote ('q') if flag ('f') is FALSE
>char ( n-c ) Convert the value on TOS to a single character
char: ( "-c ) Parse ahead and return one character
" ( "-$ ) Parse until " is encountered and return a string
cr ( - ) Display a CR character
space ( - ) Display a space
tab ( - ) Display a tab
." ( "- ) Parse to the next ", display the string.
clear ( - ) Clear the screen
normal ( - ) Set the colors back to the default
bold ( - ) Set the bold attribute for the foreground color
black ( - ) Set the foreground color to black
red ( - ) Set the foreground color to red
green ( - ) Set the foreground color to green
yellow ( - ) Set the foreground color to yellow
blue ( - ) Set the foreground color to blue
magenta ( - ) Set the foreground color to magenta
cyan ( - ) Set the foreground color to cyan
white ( - ) Set the foreground color to white
onBlack ( - ) Set the background color to black
onRed ( - ) Set the background color to red
onGreen ( - ) Set the background color to green
onYellow ( - ) Set the background color to yellow
onBlue ( - ) Set the background color to blue
onMagenta( - ) Set the background color to magenta
onCyan ( - ) Set the background color to cyan
onWhite ( - ) Set the background color to white
nip ( xy-y ) Remove the second item on the stack
rot ( abc-bca ) Rotate top three values on stack
-rot ( abc-acb ) Rotate top three values on stack twice
over ( xy-xyx ) Put a copy of NOS above the TOS
tuck ( xy-yxy ) Put a copy of TOS under NOS
2dup ( xy-xyxy ) Duplicate the top two items on the stack
2drop ( xy- ) Drop TOS and NOS
reset ( *- ) Drop all items on the stack
r@ ( -x ) Get a copy of the top item on the return stack
1+ ( x-y ) Increase value on stack by 1
1- ( x-y ) Decrease value on stack by 1
negate ( x-y ) Invert the sign of TOS
/ ( xy-z ) Divide two numbers
mod ( xy-z ) Divide two numbers and get remainder
not ( x-y ) Invert the value 'x'
*/ ( abc-d ) (a*b)/c
chars ( x-y ) Multiply TOS by char-size. Useful w/arrays
char+ ( x-y ) Increase TOS by char-size
char- ( x-y ) Decrease TOS by char-size
cells ( x-y ) Multiply TOS by cell-size. Useful w/arrays
cell+ ( x-y ) Increase TOS by cell-size
cell- ( x-y ) Decrease TOS by cell-size
+! ( xa- ) Add 'x' to the value in address 'a'
-! ( xa- ) Subtract 'x' from the value in address 'a'
on ( a- ) Set a variable to TRUE
off ( a- ) Set a variable to FALSE
toggle ( a- ) Toggle a variable between TRUE and FALSE
variable ( "- ) Create a variable
variable| ( "- ) Create multiple variables
hex ( - ) Set the base to hexadecimal (16)
decimal ( - ) Set the base to decimal (10)
binary ( - ) Set the base to binary (2)
octal ( - ) Set the base to octal (8)
"R" ( -x ) Mode for file.open
"R+" ( -x ) Mode for file.open
"W" ( -x ) Mode for file.open
"W+" ( -x ) Mode for file.open
"A" ( -x ) Mode for file.open
"A+" ( -x ) Mode for file.open
START ( -x ) Mode for file.seek
CURRENT ( -x ) Mode for file.seek
END ( -x ) Mode for file.seek
file.slurp ( $-a ) Read a file into a dynamically allocated buffer
is-array ( n"- ) Create an array of size 'n'
get-element ( ia-n ) Get element 'i' from array 'a'
put-element ( nia- ) Put value 'n' into element 'i' of array 'a'
get-char-element ( ia-n ) Get char-size element 'i' from
array 'a'
put-char-element ( nia- ) Put char-size value 'n' into element 'i' of
array 'a'
<list> ( -a ) Stores a list of pointers used by { and }
{ ( - ) Start a scoped area
} ( - ) End a scoped area
+action ( aq"- ) Create a new word (") with the action of the
specified quote (q) and data element (a)
value ( "- ) Create a new value
to ( - ) Set the value of a value
value| ( "- ) Create multiple values
words-within ( n- ) Display all words with a specified class #
:prims ( - ) Display all primitives
:quotes ( - ) Display all named quotes
:datas ( - ) Display all named data items
words ( - ) Display all names in the dictionary
toka.nbk: Home | Index | Previous Page: WordClasses
Notebook exported on Sunday, 1 July 2007, 19:54:43 PM EDT