Author Topic: Tiny Benchmark Test  (Read 34699 times)

0 Members and 5 Guests are viewing this topic.

Aurel

  • Guest
Re: Tiny Benchmark Test
« Reply #60 on: May 18, 2014, 03:44:23 AM »
Hi Mike...
Quote
What is left to do for you is in fact to write a tokenizer which will substitute each of your language keywords in a given program with a corresponding token - an integer

I think that i alredy have something like this:
from interperter:
Code: [Select]
SUB RUNCODE
'print "RUN CODE..."
'print "PC:" + Str(PC)
INT Start,EndCode
LineNum=0 : Start=0 : EndCode=PC :perr=0
'STRING key$=""
sys key


' *** MAIN LOOP *****
'For LineNum = Start TO EndCode
'get keyword...token(int)
mov ecx,0
again:
'key$=arg0[LineNum]
'do
key = tok[LineNum]
'print "KEY:" + key$
PC=LineNum
'

'if selected is true
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
select key
CASE R_WFORM
exec_Window()

Case R_IF
LineNum = exec_IF()

Case R_ENDIF
'do nothing if TRUE

Case R_SET
exec_Set()

Case R_TXCOLOR
exec_TxColor()

Case R_WTEXT
exec_WText()

Case R_LINE
exec_LineXY()

Case R_CIRCLE
exec_Circle()

Case R_PIX
exec_PsetXY()

Case R_LOOPTO
exec_FOR()

Case R_SHIFT
exec_NEXT()

Case R_JUMP
LineNum=exec_JUMP()

Case R_WINCOLOR
exec_WINCOLOR()

'controls
Case R_CONTROL
exec_WINCONTROL()

End select

'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
lineNum++

If perr=1
print "Error -> Exit from Main Loop!"
'EXIT For
goto out
End If
'Next LineNum ---------------------------

IF PeekMessage (&wm,0,0,0,Pm_Remove)>0 ' //peek
       TranslateMessage (&wm)
       DispatchMessage (&wm)
END IF
 

'----------------------------------------
IF lineNum > EndCode then goto out
dec ecx
jnz again
'end do

out:
Return

End SUB 

You can see here small asm code to... :D

In attachment is complete interpreter..
« Last Edit: May 18, 2014, 01:38:50 PM by Aurel »

Aurel

  • Guest
Re: Tiny Benchmark Test
« Reply #61 on: May 18, 2014, 09:07:52 AM »
And here is small program which draw pine tree .
It took 5.5 sec on my old comp  ::)

Code: [Select]
'chTree
DEFn rise, rad, frad, xshorten
DEFn left, top, width, height, bpx, bpy, tpx, tpy
DEFn x1, y1, x2, y2

WFORM 20,5,440,460,#MMS,0,"ChTree"
wColor 235,235,245
defn ht,xs,aa,msto
defn tpxx,tpyy,bpxx,bpyy,minus4

set msto = -100
set minus4 = -4
set bpx=220 , bpy=410 , tpx=bpx
'brown
txcolor 130, 100, 0
for aa,minus4,4
   set bpxx=bpx+aa, bpyy=bpy-390
  line  bpxx, bpy, bpx, bpyy
next aa
'green
txcolor 30,120,40
set rad=160,tpy=bpy-40
for ht,1,40

  for xs,msto,100,40
    set xshorten=xs/100 
    set rise= RND(0.3),tpxx = tpx+(xshorten*rad),tpyy = tpy-rise*rad
    line tpx, tpy, tpxx, tpyy

    for aa,1,30
       set frad=rnd(0.9)*rad
       set x1=tpx+(xshorten*frad)
       set y1=tpy-rise*frad
       set x2=tpx+xshorten*(frad+rad/5)
       set y2=tpy-rise*frad+(-rise+(RND(0.8)-0.4))*(rad/5)
       line x1, y1, x2, y2
       'wait 1
    next aa
 
  next xs

  set rad=rad-4 , tpy=tpy-9
next ht



.

JRS

  • Guest
Re: Tiny Benchmark Test
« Reply #62 on: May 18, 2014, 09:38:46 AM »
FWIW - Script BASIC is rather flexible with the use of labels. Line numbers in SB are a special form of label. This should freak a few unaware programmers out.  ;D

Code: [Select]
40 FOR x = 1 TO 5
50   IF x = 3 THEN GOTO 10
20   PRINT x,"\n"
30 NEXT
10 END

jrs@laptop:~/sb/sb22/test$ scriba testlnum.sb
1
2
jrs@laptop:~/sb/sb22/test$

Script BASIC also allows you to use the same label name multiple times in your script as long as it isn't in the same scope.

Code: [Select]
SUB One
  IF global_var = 1 THEN GOTO Done
  EXIT SUB
  Done:
END SUB

SUB Two
  IF global_var = 2 THEN GOTO Done
  EXIT SUB
  Done:
END SUB



Mike Lobanovsky

  • Guest
Re: Tiny Benchmark Test
« Reply #63 on: May 18, 2014, 12:48:45 PM »
Hey John,

That line number feature looks like a first class admission fee to BP.org! ;D

Mike Lobanovsky

  • Guest
Re: Tiny Benchmark Test
« Reply #64 on: May 18, 2014, 12:57:01 PM »
Aurel,

Where's the awinh.inc file, please?

Charles Pegge

  • Guest
Re: Tiny Benchmark Test
« Reply #65 on: May 18, 2014, 01:04:27 PM »
Hi Mike, You will find a copy in  OxygenBasic: projectsB\Scintilla. This is Aurel's area :)


For old times sake, OxygenBasic accepts line numbers too. As in ScriptBasic, they are treated as labels. I think they might be useful for diagnostics, and providing numerical references to sections.

Because they are labels, exotic formats can be used:

100.01.44A
« Last Edit: May 18, 2014, 01:13:46 PM by Charles Pegge »

Mike Lobanovsky

  • Guest
Re: Tiny Benchmark Test
« Reply #66 on: May 18, 2014, 01:05:43 PM »
Thanks Charles,

Going there right away.

Aurel

  • Guest
Re: Tiny Benchmark Test
« Reply #67 on: May 18, 2014, 01:15:40 PM »
here is awinh.


.

Mike Lobanovsky

  • Guest
Re: Tiny Benchmark Test
« Reply #68 on: May 18, 2014, 01:24:00 PM »
Thanks Aurel,

Your ruben2.exe compiles but it doesn't run your tree script. It breaks on Set and Get calls (see picture).

Where can I get the BMP's for ruben2.o2bas? What other bells and whistles does it need? Perhaps the absence of these components renders the final exe inoperative?

.
« Last Edit: May 18, 2014, 01:44:25 PM by Mike Lobanovsky »

Aurel

  • Guest
Re: Tiny Benchmark Test
« Reply #69 on: May 18, 2014, 01:41:16 PM »
Mike..i see ,sorry wrong version..
try this one from attachment...


PS:BMP's for ruben2.o2bas ?
Mike ruben2 don't have any bitmaps ,what you see is probably code editor
for ruben called RCode which is just a modification of ASciEdit for OxygenBasic..ok?
The tree code you can save on disk in same folder where you compile ruben interpreter
then just drag & drop file into interpreter exe and must work.
If you need code for code editor there is no problem...

.
« Last Edit: May 18, 2014, 01:55:28 PM by Aurel »

Mike Lobanovsky

  • Guest
Re: Tiny Benchmark Test
« Reply #70 on: May 18, 2014, 01:53:21 PM »
Sorry Aurel,

This one doesn't work for me either. Please give me some other sample script. And what extensions do you use for your scripts? .BAS? .RUB?

Aurel

  • Guest
Re: Tiny Benchmark Test
« Reply #71 on: May 18, 2014, 01:59:48 PM »
Mike ..
extension is .rub
But because you use xp i think that must work.
When you say that you can compile ruben2 to exe ..right?

Aurel

  • Guest
Re: Tiny Benchmark Test
« Reply #72 on: May 18, 2014, 02:04:39 PM »
Ok Mike in attachment is everything you need to try..
just unpack and run RCode2.exe...
i only can hope that will work

.

Mike Lobanovsky

  • Guest
Re: Tiny Benchmark Test
« Reply #73 on: May 18, 2014, 02:09:11 PM »
Yes, it compiles fine. Then I drag-and-drop the script onto ruben2.exe. It builds the main window but then reports that it can't find all the vars that are declared in the DEFn rise, rad, frad, xshorten line and aborts.

OK I will try the entire pack. I'll inform you tomorrow about my results.

Thanks,

Aurel

  • Guest
Re: Tiny Benchmark Test
« Reply #74 on: May 18, 2014, 02:11:17 PM »
ok... ;)