r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Dialects] Questions about how to create dialects

Geomol
18-Jul-2007
[201x3]
*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   :)
Geomol
30-Jul-2007
[239]
Thanks for the input! I thought about something similar, having a 
sub-pointer as you speak of. It could work. But I got the feeling, 
it'll be a better design, if it's done like the original, using an 
internal format with byte-code for the keywords. I have to judge, 
how much work it is.


I'm interested in Greggs original ideas, which got me going with 
this, to implement different languages. I'll consider Forth as the 
next one.
btiffin
30-Jul-2007
[240]
Forth has a very (untouchable actually) immersive feel to it.  As 
long as you avoid working with the sad sad current trend of text 
file forth, everything you do in Forth is Forth.  Editor commands...Forth, 
disk management Forth, debugger Forth, locate and cross reference, 
Forth.  Anyway I'm still questing for a REBOL enviroment that allows 
that immersive feel.  No brain switching to Editor, back to console 
command brain, then another brain switch to file manager, bobloblaw. 
 Mondo powerful when you can keep your brain in one mode for a full 
eight hours.  Even building Forth was Forth.  I do kinda miss it, 
but only for semimental reasons.  REBOL is just too cool to think 
about going back.
Gregg
30-Jul-2007
[241]
John, it sounds great. I'm just totally strapped for time, or I'd 
be in there baning on it and learning from what you've done.
Geomol
1-Aug-2007
[242]
What is a good Forth version as a reference system? ANS Forth? I 
also need a place to look, where the language is explained in a clear 
and short form.
Gregg
1-Aug-2007
[243x3]
http://www.retroforth.org/
http://www.colorforth.com/cf.html
http://www.xs4all.nl/~thebeez/4tH/4thide.htm
http://maschenwerk.de/foerthchen/

http://www.fig-uk.org/byof.htm
http://www.complang.tuwien.ac.at/forth/threaded-code.html

http://www.amresearch.com/starting_forth/
http://thinking-forth.sourceforge.net/
http://www.ultratechnology.com/1xforth.htm

http://c2.com/cgi/wiki?ForthLanguage
I have a lot more links here as well, but the best reference may 
be Brian, since he was a real live Forth user. I also have a couple 
books on my shelf, but...
Leo Brodie's books, Starting Forth and Thinking Forth, are the seminal 
works on the language.
btiffin
1-Aug-2007
[246x2]
You beat me to it Gregg.  Starting Forth by Leo Brodie.  It includes 
the old school (and really the only reason to use Forth) block editor. 
 Without the block editor Forth is pretty much just another language, 
with it (and after getting used to EDLIN style editing), you get 
the immersive holy grail.  Thinking Forth is quite a bit more cerebral, 
but I know it's been made available in PDF, but I found this...

http://home.iae.nl/users/mhx/sf.htmlso far.
Never mind the link so much.  just a dup of one of Greggs.
Gregg
1-Aug-2007
[248]
I never got into Forth more than playing around, but I *love* the 
idea of the immersive experience. REBOL is that in many ways for 
me, because I can think about so many things using REBOL as a context. 
I think the idea of dialects could lead us to domain specific environments 
that are like Forth, in that they are highly focused and immersive.
btiffin
1-Aug-2007
[249]
Forth Inc will send you a copy of of Swiift   http://www.forth.com
 it has a block editor, but they've moved away from supporting it 
so they could 'do Windows'...a pity.  And wait...did I say Forth 
was "just another language"?  Where did THAT come from?   Long live 
REBOL.  :)
Geomol
1-Aug-2007
[250]
:-)