Oxygen Basic
Programming => Example Code => Data Processing => Topic started by: Aurel on September 22, 2014, 09:35:44 AM
-
Hi to all...
If anyone wish to try how work or to see how is created this small and simple
direct or tokenized interpreter written in Oxygen basic in attachment is complete
release with source code .
Every part of interpreter and code editor is written in Oxygen Basic.
(thanks to Charles ) .. :)
.
-
..and here is a small screenshot ( mouse move circles)...
.
-
Hi Aurel,
there comes along an error with ruben2.
if you click onto the window, then start it again and again. >:(
is this a new mesh by you?
.
-
is this a new mesh by you?
yes Peter it is by me or by strange o2 trigering.... :-[
-
No i mess up messages... ::)
I hope that is now fixed....
source is updated and is in folder RubSrc
.
-
mayaM ...
wform 0,0,600,480,#SYS,0,"mayaM"
wcolor 0,0,0
txcolor 200,220,250
defn pi,rr,gg,bb,n
set pi = 3.14
defn level,angle,i
defn insize,x1,y1,x2,y2,d
set level = 300,angle = 0
set x1=200,y1=200
for n,0,100
set angle=angle + 20
for i,1,9
set d=9
set x2 = x1 + cos(angle/d) * (d*10)
set y2 = y1 + sin(angle*d)*2 * (d*10)
set rr=RAND(255),gg=RAND(255),bb=250
txcolor rr,gg,bb
Line x2,y2,x1,y1
circle x2,y2,d
set angle=angle - 20
set d=d-1
next i
next n
.
-
Aurel, for what is pi here?
-
hi Peter
Just for testing ..
-
I just can confirm that ruben3 work under new oxygen dll
also @mousemove event work fine :)
'@mousemove
wform 0,0,600,400,#MMS,0,"Mouse Move test"
defn y,y2,rr,gg,bb
defn mx,my,rc
'set my = 100
WAIT 0
@MOUSEMOVE
@MOUSEX mx
@MOUSEY my
set rc = RAND(10)
set rr=RAND(255),gg=RAND(155),gg=RAND(255)
txcolor 0,0,0,rr,gg,bb
circle mx,my,rc
@OFF
.
-
well it looks that left mouse button down work fine
'@mousemove + left button down
wform 0,0,600,400,#MMS,0,"Mouse Move test"
defn y,y2,rr,gg,bb
defn mx,my,rc
WAIT 0
@MOUSEMOVE
@MOUSEX mx
@MOUSEY my
set rr=RAND(255),gg=RAND(155),gg=RAND(255)
txcolor 0,0,0,rr,gg,bb
set rc = RAND(10)
circle mx,my,rc
@OFF
@LEFTMBDOWN
txcolor 0,0,200,255,255,255
circle mx,my,30
@OFF
.
-
RubenDev Circles.
include "ss.inc"
window 600,400,1
cls 255,255,255
int y,y2,rr,gg,bb
int mx,my,rc
while keydown(27)=0
'cls 255,255,255
mx = xMouse
my = yMouse
rc = rand(8,20)
color rand(32,255),rand(32,155),rand(32,255),255
fillcircle mx,my,rc
if MouseButton()=1
color 0,0,0,255
drawcircle mx,my,40
endif
color 0,0,0,255
drawstring 200,16,"RUBENDEV CIRCLES"
redraw
wait 10
wend
winExit
-
Work great Peter :D
This is SDL example right ?
it is interesting that your o2 example use 26 GDI objects ad ruben need 48
and is strange that in some cases not work ...looks like DC coruption or something >:(
Peter
do you can create same program with GDI only ?
if is not problem for you ...
i am interested how pure GDI o2 program work
thnks...
-
just a small bug-fix ...
.
-
Aurel,
Can you post of list of features you plan to add to your BASIC going forward? It's better to warn folks ahead of time so they aren't disappointed with a surprise. Don't give up on Ruben as it helps Charles make O2 more stable and lets Charles think about alternative ways.
-
Aurel,
Can you post of list of features you plan to add to your BASIC going forward? It's better to warn folks ahead of time so they aren't disappointed with a surprise. Don't give up on Ruben as it helps Charles make O2 more stable and lets Charles think about alternative ways.
Hi John
I will continue with ruben...currently i don't have enough free time..
well what i have in plan..hmm i am not sure.
currently ...ruben is very primitive interpreter few graphic commands and just float varible type
math function,few window controls ...
so i must add
event-messages
more controls & related commands
strings & string operations
(this culd be tricky & little bit in unusual style) ::)
probably some sort of container/asociative array ..or
(maybe with OOP - i like OOP things in o2) ;)
html control or something similar
(via EB dll- seems that work so-so)
-
You may want to look at the My-BASIC source to get a few ideas how to handle some of the core BASIC logic for Ruben.
-
Yes i can and i already did that...
but concept is completely different...
-
i found this on ALLBASIC forum:
This is how I would do it if I were creating a basic interpreter. Here is the BNF description for TinyBasic
<line> = <number> <statement> <CR>
<statement> <CR>
<statement> = PRINT <printlist>
PR <printlist>
INPUT <varlist>
LET <var> = <expression>
<var> = <expression>
GOTO <expression>
GOSUB <expression>
RETURN
IF <expression> <relop> <expression> THEN <statement>
IF <expression> <relop> <expression> <statement>
REM <commentstring>
CLEAR
RUN
RUN <exprlist>
LIST
LIST <exprlist>
<printlist> =
<printitem>
<printitem> :
<printitem> <separator> <printlist>
<printitem> = <expression>
"<characterstring>"
<varlist> = <var>
<var> , <varlist>
<exprlist> = <expression>
<expression> , <exprlist>
<expression> = <unsignedexpr>
+ <unsignedexpr>
- <unsignedexpr>
<unsignedexpr> = <term>
<term> + <unsignedexpr>
<term> - <unsignedexpr>
<term> = <factor>
<factor> * <term>
<factor> / <term>
<factor> = <var>
<number>
( <expression> )
<function>
<function> = RND ( <expression> )
USR ( <exprlist> )
<number> = <digit>
<digit> <number>
<separator> = , | ;
<var> = A | B | ... | Y | Z
<digit> = 0 | 1 2 | ... | 9
<relop> = < | > | = | <= | >= | <> | ><
-
..also i found old topic by SteveA( i miss this guy)..
interesting he use same Factor() & term() in his expression parser
like me in ruben ( but i ue this for expression evaluator) ..funny.
SUB Term()
Local ch$, pii, tValue, ismultop, ich
Factor()
tValue = dreturn
pii = epos
ch$ = pstring$(pii)
IsMultop(ch$)
ismultop = ireturn
WHILE (ismultop = 1)
ich = ASC(ch$)
SWITCH ich
CASE 42
Match()
Factor()
tValue = tValue * dreturn
BREAK
CASE 47
Match()
Factor()
tValue = tValue / dreturn
BREAK
CASE 94
Match()
Factor()
tValue = tValue ^ dreturn
BREAK
CASE 37
Match()
Factor()
ireturn = INT(dreturn)
tValue = INT(tValue)
tValue = mod(tValue, ireturn)
BREAK
END SWITCH
pii = epos
ch$ = pstring$(pii)
IsMultop(ch$)
ismultop = ireturn
WEND
dreturn = tValue
END SUB
' ---------- end Term ----------
SUB Factor()
Local ch$, pii, isalpha, fvalue
pii = epos
ch$ = pstring$(pii)
IF (ch$ = "(") THEN
Match()
Expression()
fvalue = dreturn
Match()
ELSE
GetNum()
fvalue = dreturn
ENDIF
dreturn = fvalue
END SUB
' ---------- end Factor ----------
-
i found this on ALLBASIC forum:
There is a lot of good stuff there posted by multiple BASIC developers. Definitely a good place to check out if building your own BASIC interpreter is your life time goal.
I'm speaking as someone that picked up a production stable BASIC to carry on with. I can only imagine what it would be like writing it from scratch. :o
-
Actually Ed Davis' Toy interpreter is a very good place to start at. It is bytecode-driven (hence fast) and extendable. Fixed size arrays for its code and variable storage are currently its only limitation that can be easily overcome in O2 using array pointer overlays as necessary and msvcrt.dll's malloc() or calloc() and free() functions to manage the code/program memory in real time.
-
I can only imagine what it would be like writing it from scratch.
well ...i like it -from scratch,scratch....scratch
it is more funny than use already created ::)
-
scratch
it is more funny than use already created
Translation: It's more fun than using an existing BASIC project.
If I was young and fearless like you, I might agree.