BASIC Interpreter
BASIC Interpreter
Hello everybody,
I'm writing this post because I'm working on a BASIC Interpreter and I need help to improve it. At this moment, the interpreter can interpret most of the FreeBASIC functions. I hope it will be possible to make it 100% compatible with FreeBASIC.
The current main thing to improve is speed and, first of all, it could be very usefull to improve the mid() function to make it work faster.
So if somebody has got a fast code (maybe in assembler) for the mid() function, don't hesitate to post it.
Note : the interpreter will be free and at least partly, if not completely, open source. Everybody contributing to this project will have his/her name mentionned in the credits.
I will send the code and give more information very soon.
Thanks to everybody !
I'm writing this post because I'm working on a BASIC Interpreter and I need help to improve it. At this moment, the interpreter can interpret most of the FreeBASIC functions. I hope it will be possible to make it 100% compatible with FreeBASIC.
The current main thing to improve is speed and, first of all, it could be very usefull to improve the mid() function to make it work faster.
So if somebody has got a fast code (maybe in assembler) for the mid() function, don't hesitate to post it.
Note : the interpreter will be free and at least partly, if not completely, open source. Everybody contributing to this project will have his/her name mentionned in the credits.
I will send the code and give more information very soon.
Thanks to everybody !
-
Hi...
I'm interested to becose i already have one written in CBasic called
'Project One' maby you can use something if you interested.
My atention is rewrite code to Free Basic but i'm still lerning FB(argh..).
I'm interested to becose i already have one written in CBasic called
'Project One' maby you can use something if you interested.
My atention is rewrite code to Free Basic but i'm still lerning FB(argh..).
Why not vdecampo...
Interpreters are good for test code on the fly before compiling.
Many people dont like interpreters becose most interpreters can't make
standalone exe but on the other side offer quick executing .
Free Basic is really great programming language which offer many
ways of programming and i'm fascinating with his capabilities.
I always wanna make simple basic compiler but my current knowlege
about this thematic is still on start becose i'm to busy with real life.
And one simple but very good example of compiler is written in
VB 6 called Libry Compiler which code is free.
I think that will be posible convert this code to FB and make similiar
compiler in Free Basic.
Aurel
Interpreters are good for test code on the fly before compiling.
Many people dont like interpreters becose most interpreters can't make
standalone exe but on the other side offer quick executing .
Free Basic is really great programming language which offer many
ways of programming and i'm fascinating with his capabilities.
I always wanna make simple basic compiler but my current knowlege
about this thematic is still on start becose i'm to busy with real life.
And one simple but very good example of compiler is written in
VB 6 called Libry Compiler which code is free.
I think that will be posible convert this code to FB and make similiar
compiler in Free Basic.
Aurel
mid() function
Concerning the mid() function, maybe what I wrote wasn't really clear. In fact I don't know if there is a way to make a mid() function that works faster than the FreeBASIC one. I was just asking if somebody had an idea ?
Some people will certainly ask why the mid() function is so important in my interpreter : simply because I use it to extract parts of the script lines (extract the function names, parameters, etc...) but maybe there is a faster way to do the same without using mid.
I will send a post with a link to download the interpreter this week end.
Some people will certainly ask why the mid() function is so important in my interpreter : simply because I use it to extract parts of the script lines (extract the function names, parameters, etc...) but maybe there is a faster way to do the same without using mid.
I will send a post with a link to download the interpreter this week end.
-
- Posts: 1186
- Joined: May 08, 2006 21:58
- Location: Crewe, England
this may be useful to you http://www.freebasic.net/forum/viewtopic.php?t=13975
Yes depending on your current parser.
I think that best option for parser will be inline assembly.
I have one somwhere but i dont know where written by Charles Pagge.
by the way i use my own in ABasic which parse trough RichEdit control:
etc ...
Depends on how many words you have in one line.
[/code]
I think that best option for parser will be inline assembly.
I have one somwhere but i dont know where written by Charles Pagge.
by the way i use my own in ABasic which parse trough RichEdit control:
Code: Select all
'---- count words in string ----------------------------------
WC = 1
Pos = InStr(text, " ",0)
While Pos > 0
WC = WC + 1
Pos = InStr(text, " ",pos+1)
Wend
CountWords = WC
'------------------------------------------------
'extract words
'-------------------------------------------------
IF wc>0
SPos = 1
EPos = InStr(text, " ",SPos) - 1
If EPos <= 0 Then EPos = Len(text)
' GW1 is first word(string)
GW1 = RTrim$(LTrim$(Mid$(text, SPos, EPos - SPos + 1)))
ENDIF
IF wc>1
SPos=EPos+2
EPos = InStr(text, " ",SPos) - 1
If EPos <= 0 Then EPos = Len(text)
GW2 = RTrim$(LTrim$(Mid$(text, SPos, EPos - SPos + 1)))
ENDIF
Depends on how many words you have in one line.
[/code]
Antoni
I would love to help the FB developers but unfortunately I am lost on some of the concepts used in the current compiler. My goal in writing an interpreter was to hopefully learn some of these concepts and techniques. After which I would be in a better position to understand whats going on in the compiler.
-Vince
PS: I have already written a lexer which breaks down the source code into literals, numbers, and operators. My next step is to design a VM and work on processing this source.
I would love to help the FB developers but unfortunately I am lost on some of the concepts used in the current compiler. My goal in writing an interpreter was to hopefully learn some of these concepts and techniques. After which I would be in a better position to understand whats going on in the compiler.
-Vince
PS: I have already written a lexer which breaks down the source code into literals, numbers, and operators. My next step is to design a VM and work on processing this source.
I'm glad that you interested Galeon.
I will present here in few steps how i do that for ABasic.
1. Define buffer string like Dim buffer[32766] as String
2.Open file and fill buffer string with source code
3.Load buffer to richedit control
4.Start script with gosub RUNSCRIPT
5.In sub runscript:
6.Get line count - calc how many lines is in richedit
7.decrease conunt to -1
8.Get first line of code in temp string
9.Parse temp string to words
10.If first word in temp string keyword then execute line.
11.repeat this proces to last line.
Like you see my concept is reading code from richedit control not from
file directrly and maby is not so good ( I think that is slower then reading code from file - i'm not sure?
aurel
I will present here in few steps how i do that for ABasic.
1. Define buffer string like Dim buffer[32766] as String
2.Open file and fill buffer string with source code
3.Load buffer to richedit control
4.Start script with gosub RUNSCRIPT
5.In sub runscript:
6.Get line count - calc how many lines is in richedit
7.decrease conunt to -1
8.Get first line of code in temp string
9.Parse temp string to words
10.If first word in temp string keyword then execute line.
11.repeat this proces to last line.
Like you see my concept is reading code from richedit control not from
file directrly and maby is not so good ( I think that is slower then reading code from file - i'm not sure?
aurel