This is related to the thread in Geek Culture "making your own language?", and one of the main topics it bytecode.
This isn't exactly bytecode, because the codes arent in single bytes, because it's in string form, but it works it the same way.
Here you go. A description of what it does is given:
`Programming Language for DBPro
sync on : sync rate 60
set display mode 1024,768,32 : hide mouse
`Stuff to set up
type tToken
tok as string
sttype as integer
num as float
endtype
dim token(0) as tToken
global scode as string
type tVar
name as string
vl as float
endtype
dim var(0) as tVar
dim stack(0) as float
global pdown as integer
`Code
`This code with solve the equation 3+(12/(2*3))
`and assign the result to variable 'a'. It will then solve 1+2, and
`assign that to 'b'. It will then create c, and will solve a-b and assign the result, and show the result (2)
setCode("var a push 3 push 12 push 2 push 3 op * op / op + let a clear var b push 1 push 2 op + let b clear var result push a push b op - let result show result")
execute()
`Main Loop
do
sync
loop
`Functions
function setCode(scr$)
scode = scr$
endfunction
function tokenize()
for i=1 to len(scode)
cur$ = mid$(scode,i)
tok$ = tok$ + cur$
if cur$ = " "
tok$ = remChar(tok$," ")
array insert at bottom token()
token(array count(token())).tok = tok$
if tok$ = "push" or tok$ = "pop" or tok$ = "op" or tok$ = "var" or tok$ = "let" or tok$ = "show"
token(array count(token())).sttype = 1
endif
if isNum(tok$)
token(array count(token())).sttype = 2
token(array count(token())).num = val(tok$)
endif
tok$ = ""
endif
next i
array insert at bottom token()
token(array count(token())).tok = tok$
endfunction
function showToks()
for i=1 to array count(token())
text 10,20*i,token(i).tok
next i
endfunction
function execute()
tokenize()
for t=1 to array count(token())
`Get next token
if t<array count(token())
nexttok$ = token(t+1).tok
endif
`For statements
if token(t).sttype = 1
`Create variables
if token(t).tok = "var"
array insert at bottom var()
`Check next token
var(array count(var())).name = nexttok$
endif
`Set variables
if token(t).tok = "let"
varnum = getVar(nexttok$)
var(varnum).vl = stack(array count(stack()))
endif
`Stack Data
`Clear stack
if token(t).tok = "clear"
empty array stack()
endif
`Push onto stack
if token(t).tok = "push"
add to stack stack()
if isNum(nexttok$)
stack(array count(stack())) = val(nexttok$)
else
stack(array count(stack())) = var(getVar(nexttok$)).vl
endif
endif
`Pop off stack
if token(t).tok = "pop"
remove from stack stack()
endif
`Maths
if token(t).tok = "op"
`Plus +
if nexttok$ = "+"
solve# = stack( array count(stack()) -1) + stack( array count(stack()))
remove from stack stack()
remove from stack stack()
add to stack stack()
stack(array count(stack())) = solve#
endif
`Minus -
if nexttok$ = "-"
solve# = stack( array count(stack()) -1) - stack( array count(stack()))
remove from stack stack()
remove from stack stack()
add to stack stack()
stack(array count(stack())) = solve#
endif
`Mult *
if nexttok$ = "*"
solve# = stack( array count(stack()) -1) * stack( array count(stack()))
remove from stack stack()
remove from stack stack()
add to stack stack()
stack(array count(stack())) = solve#
endif
`Divide /
if nexttok$ = "/"
solve# = stack( array count(stack()) -1) / stack( array count(stack()))
remove from stack stack()
remove from stack stack()
add to stack stack()
stack(array count(stack())) = solve#
endif
`Power
if nexttok$ = "^"
solve# = stack( array count(stack()) -1) ^ stack( array count(stack()))
remove from stack stack()
remove from stack stack()
add to stack stack()
stack(array count(stack())) = solve#
endif
endif
`Basic commands
if token(t).tok = "show"
if isNum(nexttok$)
text 10,pdown*20,nexttok$
else
text 10,pdown*20,str$(var(getVar(nexttok$)).vl)
endif
inc pdown
endif
endif
next t
endfunction
function showStack()
for s=1 to array count(stack())
text 10,20*s,str$(stack(s))
next s
endfunction
function getVar(v$)
for v=1 to array count(var())
if var(v).name = v$
exitfunction v
endif
next v
endfunction 0
function isLetter(text$)
if asc(text$)>=asc("a") and asc(text$)<=asc("z") then alpha=1
if asc(text$)>=asc("A") and asc(text$)<=asc("Z") then alpha=1
endfunction alpha
function isNum(text$)
if asc(text$)>=asc("0") and asc(text$)<=asc("9") then num=1
endfunction num
function remChar(st$,r$)
for t=1 to len(st$)
if mid$(st$,t)<>r$
ret$=ret$+mid$(st$,t)
endif
next t
endfunction ret$
The "var" thing makes a new variable. "Push" adds something to a stack. "clear" will clear the stack. "op" will apply an operator such as + or - to the top two items of the stack. "let" will set the variable you give it to the top item of the stack. And "show" will just show what you give it.