World: r3wp
[Dialects] Questions about how to create dialects
older newer | first last |
Geomol 17-Jul-2007 [189x2] | The start of a BBC BASIC interpreter using string parsing: http://www.fys.ku.dk/~niclasen/rebol/bbcbasic.r |
How do we best get this rolling? I'm interested in making some language interpreters in REBOL, because I see future potential. Reichart and Gregg talked about QBASIC, which I don't know. Where are the specifications for that language? BASIC is a start, and along the line, I would like to dig into other languages as well. Is it best keeping it all public, or should we make new groups for teams interested in this? | |
btiffin 17-Jul-2007 [191] | Very nice... As for the other questions...can't say...but well done sir. And a nice reading code space to boot. |
Gregg 18-Jul-2007 [192x4] | Nice John! I'm not sure how best to get rolling. I'm totally buried at the moment, but I can provide web space for the project if we need that. I also a number of grammars and things here, if we need references. |
Oddly, I don't seem to have a QBASIC grammar. :-\ | |
I started on a VB grammar once, which is similar, and I still have most of my manuals here somewhere. :-) | |
Not sure if the various sites for lex/yacc tools and such might have one/ | |
Geomol 18-Jul-2007 [196x8] | Gregg, first I'm making a simple 'engine' or 'template' for BASIC. Today I implemented expressions, some simple string handling and a little more. I'll make conditions (IF) and loops (FOR), then that should be a good start to build on. |
Uploaded new version of BBC BASIC intepreter. Added expressions and conditions. Added IF and INPUT. Example: >> do http://www.fys.ku.dk/~niclasen/rebol/bbcbasic.r connecting to: www.fys.ku.dk Script: "BBC BASIC" (18-Jul-2007) BASIC v. 0.0.2 >auto 10 input "Name",name$ 20 if name$="Carl" then print "Hi " name$ else print "Hello " name$ 30 0 >run Name?John Hello John | |
So far this is implemented: Keywords: AUTO, DELETE, LIST, NEW, OLD, GOTO, RUN, END, IF, INPUT, LET, PRINT, REM, STOP Functions: COS, SIN Expressions can beside unary +, - use: +, -, *, /, ^, (, ) Conditions can use: or, eor, and, =, <>, <=, >=, <, > | |
It's possible to add strings together and strings can also be tested in conditions. | |
3 datatypes is implemented. Examples: a$ is a string a% is an integer a is a real. | |
*are implemented* | |
Use a zero (0) to leave AUTO. Pressing <Esc> will end the BASIC intepreter. | |
New version 0.1.0 of BBC BASIC. Added FOR ... NEXT loop. Example: >> do http://www.fys.ku.dk/~niclasen/rebol/bbcbasic.r connecting to: www.fys.ku.dk Script: "BBC BASIC" (19-Jul-2007) BASIC v. 0.1.0 >auto 10 for a=10 to pi step -2.3 20 for n%=1 to 3 step 2 30 print a n% 40 next 50 next 60 0 >run 10 1 10 3 7.7 1 7.7 3 5.4 1 5.4 3 | |
[unknown: 9] 18-Jul-2007 [204] | Cute. |
Geomol 19-Jul-2007 [205x2] | A modern BASIC should maybe be able to recognize both lower an UPPER case, like in my examples. The original BBC BASIC distinguish between upper and lower case. I should change my interpreter to work this way, so already written programs will work. |
Or maybe the problem is only with variables!? Hmm | |
Louis 19-Jul-2007 [207] | http://www.programatium.com/en/programming4/qbasic.htm http://www.qbasic.com/wbb/filebase_entry.php?entryid=50& |
Geomol 19-Jul-2007 [208] | New version 0.1.1 of BBC BASIC. Added many keywords, mostly functions. To run: >> do http://www.fys.ku.dk/~niclasen/rebol/bbcbasic.r List of keywords: http://www.fys.ku.dk/~niclasen/rebol/bbcbasic.html |
Geomol 22-Jul-2007 [209x6] | Version 0.2.0 of BBC BASIC uploaded. Added DATA, READ and RESTORE. Added GOSUB and RETURN. Added hex notation, made some changes and fixed bugs. |
This is meant as an implementation of BBC BASIC originally found on the BBC Micro from british Acorn. It's not an emulator of that computer. For emulation of the BBC Micro, I recommend BeebEm. | |
One thing is to implement old languages, it could also be interesting to make a modern BASIC using block parsing in REBOL. That way, it would be possible to easily implement many of the datatypes found in REBOL. Also imagine to be able to have BASIC (or other language) code in the middle of a REBOL script, doing something like: ... (some REBOL code) ... BASIC [ ... (some BASIC code) ... ] ... (more REBOL code) ... | |
The BBC BASIC interpreter is now more than 800 lines of REBOL source (or 20278 bytes). It's 4568 bytes compressed. | |
In the early 80'ies, before the era of PCs, the Amiga, Mac and Linux, there were a whole range of home computers more or less expensive (the BBC Micro were in the high price range back then). They all came with some version of the BASIC language. It was also possible to program in assembler (the BBC had a 6502 CPU). Imagine a new homecomputer with REBOL and rebcode. And many other languages supported as REBOL dialects. It should just have a keyboard, network, some RAM and maybe a memory stick instead of a harddisk. And connection to a monitor. That shouldn't be too costly to produce. Would it sell if the price was right? | |
Oh, and it should have a low-energy CPU to run the scripts, something as the G3, I think IBM made to only use 1-2 Watt. Then it could be sold all over the World. | |
Henrik 22-Jul-2007 [215x3] | geomol, I think you'd have to price it like a midsized calculator |
I think also we need a new age of exploratory computing (meaning, people exploring other than porn sites and youtube), and it requires its own hardware. | |
the problem is that people expect to do everything on a PC, whereas in the 80's, people expected to do everything on a C64. | |
Pekr 22-Jul-2007 [218] | Geomol - there is one strong and modern Basic implementation - Free Basic? |
Geomol 22-Jul-2007 [219] | Pekr, is it strong enough? As datatypes, it support different kinds of integers, floating-point and strings. BASIC as a REBOL dialect would be able to have much more, wouldn't it? |
Gregg 22-Jul-2007 [220] | Wow John! I haven't even had a chance to look at it since the original release and you're already on v2, well, 0.2, but still. :-) And, yes, I think it would be very cool to have a BASIC that supports REBOL's datatypes. Part of my, perhaps not so hidden, agenda for these things--in addition to being great for teaching language design and construction--is to show how REBOL can work *inside* the idioms other languages use. |
Geomol 22-Jul-2007 [221] | :-) I have a feeling, that dialects is a good way to go, because so many problems become much easier to solve. |
Gabriele 23-Jul-2007 [222x2] | Geomol, the problem with such a computer is that it would only appeal to geeks, and geeks already have a pc anyway. for developing countries, there's the OLPC eventually. |
i think, time would better be invested in an OS (both for geeks, and non-geeks). then you can make cheap computers for the OS to run, once it has been recognized, so parents could buy a $100 computer to childs (one each) instead of one big $1000 pc for the family. | |
[unknown: 9] 23-Jul-2007 [224x2] | (http://news.yahoo.com/s/nm/20070720/od_nm/nigeria_pornography_dc;_ylt=A0WTUfF176FG8XwBExgZ.3QA) |
Somthing that translates to all languages, and ages... | |
Geomol 24-Jul-2007 [226x2] | Version 0.3.0 of BBC BASIC uploaded. Added the rest of the string handling: LEFT$, MID$, RIGHT$, STRING$ and INSTR. Added ON, that can change the order of execution. Added DIM, which implement arrays. Both for integers, reals and strings. To run: >> do http://www.fys.ku.dk/~niclasen/rebol/bbcbasic.r List of keywords: http://www.fys.ku.dk/~niclasen/rebol/bbcbasic.html |
Arrays are indexed from zero. Arrays can also be used to index other arrays. Example: >dim name$(4) >dim a(1,1) >name$(3)="Joe" >a(1,0)=3 >print name$(a(1,0)) Joe | |
Geomol 27-Jul-2007 [228x5] | BBC BASIC v. 0.4.0 uploaded. Added procedures and local variables (DEF PROC, ENDPROC and LOCAL). Added TIME, RND and EVAL. Added better error handling. Next thing will be functions, but I'll test procedures some more first. The implementation is based on this user guide: http://www.nvg.ntnu.no/bbc/doc/BBCUserGuide-1.00.pdf |
It's now almost 1400 lines of REBOL source. But still only 4922 bytes compressed. | |
Example use of local variables. In line 70, 'a' is local, because it's a parameter to the procedure, 'b' is still global. After line 80, 'b' also become local to the procedure. After returning from the procedure, both 'a' and 'b' are set back to their global values. In 'proctest', 'a' could have been called anything without changing the global 'a'. >> do http://www.fys.ku.dk/~niclasen/rebol/bbcbasic.html Script: "BBC BASIC" (27-Jul-2007) BASIC v. 0.4.0 >auto 10 a=42 20 b=1 30 proctest(a) 40 print "line 40 : a=";a " b=";b 50 end 60 def proctest(a) 70 print "line 70 : a=";a " b=";b 80 local b 90 a=2:b=2 100 print "line 100: a=";a " b=";b 110 endproc 120 0 >50end >run line 70 : a= 42 b= 1 line 100: a= 2 b= 2 line 40 : a= 42 b= 1 | |
Ups, the line >50end after the program shouldn't have been there, so forget that (even if it works with it included). | |
There still need to be work done on formatted output (PRINT and INPUT statements). | |
Geomol 29-Jul-2007 [233x3] | So far, I've allowed keywords to be either UPPER- or lower-case. I think, I have to restrict them to UPPER-case like in traditional BASIC. Problem is with variable names being assigned by the LET statement. If I define a variable "length": LET length=10 and then use it in some expression, the first part of the variable name is being recognized as the LEN function. In the original BBC BASIC, the above LET statement is ok, while you can't write: LET LENGTH=10 , which will give a syntax error. I conclude, I have to restrict keywords to UPPER-case and then check, when the variables are being defined, so their names don't collide with keywords. |
This probably the same reason, words are separated by space in REBOL. | |
This *is* ... | |
Geomol 30-Jul-2007 [236x2] | It's rather difficult to implement functions (user functions, which the BBC BASIC language support), with the implementing method, I've choosed. Problem is, that the return point need to be saved, while the function code is running. The problem is the same with statements like GOSUB and PROC (procedures), but so far, I've just put some restrictions on those. In this basic, more than one statement can be on each line, if they're separated by colons, ':'. The way it's implemented, this example give a syntax error: GOSUB 100:PRINT "I'm back" My implementation require, that the return point is the next line. That isn't good enough with functions, because they're used in the middle of other statements. Examples: PRINT FNone_function, FNanother_function IF FNmyfunc=42 THEN PRINT "It's 42!" The return point for those need to be in the middle of a statement, in the middle of a line. So I'm at a point, where I consider another implementation of all the statements (more like a real emulation of the BBC computer) or if I just should say "the heck with it" and move on to some other language or another version of a new BASIC language. |
Comments!? | |
btiffin 30-Jul-2007 [238] | Comments, hmmm. You've done an awesome job John. I learned Z-80 assembler back on my TRS-80 before I did much BASIC. When they finally got a computer class in my high school for ninth graders, I was already in grade 12 and laughed at the BASIC. So, instead of having me whining and whinging all class, I got to write a student database program in assembler for my electronics teacher on the Commodore PET. Never been a fan of BASIC, but what you've done can only attract a larger REBOL audience so well done. If you can make it compatible enough to run old DOS frogger.bas you may have a demo that gains worldwide attention. Technically, back to your point, (having sadly only glossed over your codebase), what if you tricked the "line" internals say with pair! or decimal! keeping your own sub-lines invisible to the user? And if you start up a Forth dialect...I'm in. Or at least will show a keener interest watching a guru at work :) |
older newer | first last |