* Rudimentary BASIC->Guile converter
@ 2003-11-29 19:21 Richard Todd
2003-11-30 11:54 ` Luca Saiu
2003-11-30 19:35 ` Thien-Thi Nguyen
0 siblings, 2 replies; 6+ messages in thread
From: Richard Todd @ 2003-11-29 19:21 UTC (permalink / raw)
Cc: richardt
I've written the start of a BASIC -> Guile converter.
It's here:
http://www.vzavenue.net/~rwtodd5128/index.html
It's at a sort of proof-of-concept stage. It can do assignments,
print, input, for/next, goto, if/else/elseif. There are some example
programs in the tests/ directory. Two programs in the src/ directory
use the language module to 1) execute a .bas file, and 2) print out
scheme equivalent of a .bas file.
I don't know if I'll finish it...I guess it depends a little on
whether anyone finds it useful. That's why I'm posting this message.
I just wrote it to get a feel for what writing an X->guile translator
would take. It's a little different than other little interpreters
I've done. A lot of stuff I consider 'normal' for compiling to asm or
bytecode has to be rethought for converting to guile. Primarily
because there's no JMP-to-label command, and also because you can't
blindly string code together (because IF's parens must surround the
conditional code, for instance).
I'd like to get some comments back if people like or don't like the
approach I've taken. If there are ways it could be improved, I'd
like to know about it.
DEPENDENCY: I've used an excellent GPL'ed LALR(1) parser generator,
but I can't seem to get any response from the author about publishing
the guile port of it. So, on my website, you'll also see a
(parse lalr) module, which you'll need. (google found me the actual
work for the port in the form of a message from Thien-Thi Nguyen, so
all I had to actually do was add the (define-module) declaration, and
put it in an autotools framework.
Implementation Comments:
The main weakness of the code I've got (other than not supporting full
BASIC yet), is that there's no traceability between the scheme source
and the original BASIC. So, when errors pop up, you have to
understand the problem in terms of the scheme code, to a degree.
Since projects like this are presumably so people can use BASIC
_instead of_ scheme, the error reporting issue needs work.
INTEROPERABILITY
The plan is to let basic files define modules, so that basic functions
can be used from guile. Also, to a limited degree, BASIC should be able
to invoke guile functions as well. This way, it should be possible to
use BASIC to extend programs that can currently be extended via guile.
I've added a |-quoted |*this-is:a-quoted-symbol*| syntax, so that all
scheme symbols can be referenced from BASIC. Also, the converter checks
to see if globals referenced in the BASIC code are already defined, at which
point it doesn't define them. This way, BASIC code can read and write to
scheme globals.
GOTO STATEMENTS
Supporting GOTO turned out to be the hardest thing, and forced the
entire shape of the translation, for a couple reasons:
1) Scheme doesn't really have an equivalent. I played with call/cc a
little, but eventually decided that I wasn't going to get that
approach to work very easily). I settled on putting each basic block
into a letrec expression, so every basic program (and eventually basic
subroutines) will look like this:
(letrec ((blk-1 (lambda () ... (blk-2)))
(blk-2 (lambda () ... (blk-1)))
...)
(blk-1))
So, it doesn't look natural, but is not that hard to read, either.
Some label names have suffixes on them to help you read the scheme
text.
2) Because you can GOTO into and out of loops, I didn't see an easy
way to preserve WHILE/WEND and FOR/NEXT loops as equivalent scheme
loops. Instead, I had to write the loops like you would in assembly
language, with explicit checks and jumps. In the future, I suppose I
could scan the program and use more efficient scheme loops where there
is no GOTO action.
Richard Todd
richardt at vzavenue net
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Rudimentary BASIC->Guile converter
2003-11-30 11:54 ` Luca Saiu
@ 2003-11-30 11:40 ` rm
2003-11-30 14:50 ` Luca Saiu
0 siblings, 1 reply; 6+ messages in thread
From: rm @ 2003-11-30 11:40 UTC (permalink / raw)
Cc: Richard Todd, guile-user
On Sun, Nov 30, 2003 at 12:54:36PM +0100, Luca Saiu wrote:
> Richard Todd wrote:
> >I've written the start of a BASIC -> Guile converter.
> >[...]
> >
> >I don't know if I'll finish it...I guess it depends a little on
> >whether anyone finds it useful. That's why I'm posting this message.
>
> Don't feel depressed! :-) Your translator seems quite simple, and the
> code it generates is readable enough; I think that due to its simplicity
> it could be useful, at least as a clean example of an X-to-Scheme
> translator. Probably there aren't so many BASIC-eager hackers in the
> free software community, but a reference translator from a little
> language is something useful we still lack.
Even if there are _no_ BASIC-eager hackers (as i hope) there's still
a need for such a translator: guile is meant to be used as an embedable
scripting language and there shure are a lot of end users with a strong
BASIC background.
Another usefull application or the transformer: applications like gnumeric
that need to import files that contain VBA code.
> Polish it keeping it as minimal as you can, and publish it. My two
> cents. :-)
Yes!
>
> To the website maintainers: why don't the Guile web pages (or the
> Free Software Directory) link to all the known free software X-to-Guile
> translators, epsecially the ones implemented in Guile? Having such
> translators is an important project goal if I understand well, and
> publicizing the existing ones could stimulate other people to continue
> the work.
Isn't this a known problem (?) of the "official" GNU websites? No links
to certain projects?
Ralf Mattes
>
> Bye,
>
> --
> Luca Saiu, maintainer of GNU epsilon
> http://www.gnu.org/software/epsilon
>
>
>
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://mail.gnu.org/mailman/listinfo/guile-user
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Rudimentary BASIC->Guile converter
2003-11-29 19:21 Rudimentary BASIC->Guile converter Richard Todd
@ 2003-11-30 11:54 ` Luca Saiu
2003-11-30 11:40 ` rm
2003-11-30 19:35 ` Thien-Thi Nguyen
1 sibling, 1 reply; 6+ messages in thread
From: Luca Saiu @ 2003-11-30 11:54 UTC (permalink / raw)
Cc: guile-user
Richard Todd wrote:
> I've written the start of a BASIC -> Guile converter.
> [...]
>
> I don't know if I'll finish it...I guess it depends a little on
> whether anyone finds it useful. That's why I'm posting this message.
Don't feel depressed! :-) Your translator seems quite simple, and the
code it generates is readable enough; I think that due to its simplicity
it could be useful, at least as a clean example of an X-to-Scheme
translator. Probably there aren't so many BASIC-eager hackers in the
free software community, but a reference translator from a little
language is something useful we still lack.
Polish it keeping it as minimal as you can, and publish it. My two
cents. :-)
To the website maintainers: why don't the Guile web pages (or the
Free Software Directory) link to all the known free software X-to-Guile
translators, epsecially the ones implemented in Guile? Having such
translators is an important project goal if I understand well, and
publicizing the existing ones could stimulate other people to continue
the work.
Bye,
--
Luca Saiu, maintainer of GNU epsilon
http://www.gnu.org/software/epsilon
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Rudimentary BASIC->Guile converter
2003-11-30 14:50 ` Luca Saiu
@ 2003-11-30 14:07 ` Marius Vollmer
0 siblings, 0 replies; 6+ messages in thread
From: Marius Vollmer @ 2003-11-30 14:07 UTC (permalink / raw)
Cc: guile-user
Luca Saiu <positrone@freemail.it> writes:
> In my opinion the best thing to do would be creating an apposite
> category in the Free Software Directory, filling it and then linking
> from the Guile pages to the directory.
Yep, that's what I'm in the process of doing. There is some slowness,
and I probably should push for it a bit more...
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Rudimentary BASIC->Guile converter
2003-11-30 11:40 ` rm
@ 2003-11-30 14:50 ` Luca Saiu
2003-11-30 14:07 ` Marius Vollmer
0 siblings, 1 reply; 6+ messages in thread
From: Luca Saiu @ 2003-11-30 14:50 UTC (permalink / raw)
Cc: Richard Todd, guile-user
rm@fabula.de wrote:
> [About linking to all known X-to-Guile translators from the Guile
> web pages]
> Isn't this a known problem (?) of the "official" GNU websites? No links
> to certain projects?
As a GNU maintainer I am informed about that; a GNU Project policy
forbids to link to pages which are commercial-oriented or which
advertise proprietary software (and I think this policy is reasonable
and coherent, but that's another matter); surely there is no problem in
linking to a page describing the translator project, if (a) it's free
software and if (b) its web page satisfies the constraints above.
Even if (b) doesn't hold for a given translator at least a link to
the project tarball (and the author's e-mail address, if the author
agrees) can be *surely* included, without any problem.
In my opinion the best thing to do would be creating an apposite
category in the Free Software Directory, filling it and then linking
from the Guile pages to the directory.
Regards,
--
Luca Saiu, maintainer of GNU epsilon
http://www.gnu.org/software/epsilon
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Rudimentary BASIC->Guile converter
2003-11-29 19:21 Rudimentary BASIC->Guile converter Richard Todd
2003-11-30 11:54 ` Luca Saiu
@ 2003-11-30 19:35 ` Thien-Thi Nguyen
1 sibling, 0 replies; 6+ messages in thread
From: Thien-Thi Nguyen @ 2003-11-30 19:35 UTC (permalink / raw)
Cc: guile-user
From: Richard Todd <richardt@vzavenue.net>
Date: Sat, 29 Nov 2003 13:21:15 -0600
The main weakness of the code I've got (other than not supporting
full BASIC yet), is that there's no traceability between the scheme
source and the original BASIC.
perhaps you can jam the source properties of generated forms w/
information from the original (BASIC) source. that just solves
the "where" question of a signalled error, however.
thi
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-11-30 19:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-29 19:21 Rudimentary BASIC->Guile converter Richard Todd
2003-11-30 11:54 ` Luca Saiu
2003-11-30 11:40 ` rm
2003-11-30 14:50 ` Luca Saiu
2003-11-30 14:07 ` Marius Vollmer
2003-11-30 19:35 ` Thien-Thi Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).