EmbeddedRelated.com
Forums

ideas for a BASIC compiler

Started by Frank Buss June 1, 2008
AZ Nomad wrote:
> On Tue, 3 Jun 2008 12:06:37 +0100, Chris H <chris@phaedsys.org> wrote: >> In message <slrng496lp.qkv.aznomad.3@ip70-176-155-130.ph.ph.cox.net>, AZ >> Nomad <aznomad.3@PremoveOBthisOX.COM> writes >>> FORTH became irrelevent when acquiring a 16mhz machine with 64K of ram became >>> trivial. > >> This is comp.arch.embedded? > >>> Also, FORTH is a write-only language. > >> The same can be said of any language. > > > No. Most langauges are read-write languages in that you can > actually read the code you've written. Forth, as a write-only language, > gives you code that is nearly completely unreadable. > > Unless, of course, you like reading pages and pages of "OVER + SWAP DO"
No, most languages can be read-write or write-only, depending on the skills of the person reading and the person writing. It is perfectly possible to write write-only code in C (if you haven't seen such code, lucky you!), and perfectly possible to write read-write code in Forth, perl, and even APL. Forth requires thinking in a slightly different way from C and other imperative languages, as do other languages with different paradigms (such as functional programming languages). So if you are unfamiliar with that sort of language, you'll have a lot of trouble understanding it at first. But with experience, well-written Forth is just as legible as well-written C or any other language you know well.
In message <slrng4ah4j.vcq.aznomad.3@ip70-176-155-130.ph.ph.cox.net>, AZ 
Nomad <aznomad.3@PremoveOBthisOX.COM> writes
>On Tue, 3 Jun 2008 12:06:37 +0100, Chris H <chris@phaedsys.org> wrote: >>In message <slrng496lp.qkv.aznomad.3@ip70-176-155-130.ph.ph.cox.net>, AZ >>Nomad <aznomad.3@PremoveOBthisOX.COM> writes >>>FORTH became irrelevent when acquiring a 16mhz machine with 64K of ram became >>>trivial. > >>This is comp.arch.embedded? > >>> Also, FORTH is a write-only language. > >>The same can be said of any language. > > >No. Most langauges are read-write languages in that you can >actually read the code you've written. Forth, as a write-only language, >gives you code that is nearly completely unreadable. > >Unless, of course, you like reading pages and pages of "OVER + SWAP DO"
OK so you don't like FORTH C is a write only language... come to hat so is C++ and I find I fall asleep with COBOL -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
On Tue, 3 Jun 2008, AZ Nomad wrote:

> Unless, of course, you like reading pages and pages of "OVER + SWAP DO" >
What you refer to are an artifact of Forth's data stack. A very simple and powerful means of passing data from routine (word) to other words. Actually, in well factored Forth, stack primitives and manipulation are generally confined to lower level words, and quickly become irrelevant as higer level domain specific words are developed. Admittedly, good forth is an art form, and the language can be used in either a top down or bottom up approach, but is very good at functional decomposition, and incremental testing. In essence, you can translate app notes directly into bit twiddling driver words, and test them incrementally on the target hardware as you develop them, without the compile link download cycle, as the development system on many forths is on-board. At the same time, you can develop a high level abstraction which sits atop your hardware layer, and is extremely easy for anyone to follow the logic ... ---- Posted via Pronews.com - Premium Corporate Usenet News Provider ---- http://www.pronews.com offers corporate packages that have access to 100,000+ newsgroups
On Tue, 3 Jun 2008 12:06:37 +0100, Chris H <chris@phaedsys.org> wrote:

>In message <slrng496lp.qkv.aznomad.3@ip70-176-155-130.ph.ph.cox.net>, AZ >Nomad <aznomad.3@PremoveOBthisOX.COM> writes >>FORTH became irrelevent when acquiring a 16mhz machine with 64K of ram became >>trivial. > >This is comp.arch.embedded? > >> Also, FORTH is a write-only language. > >The same can be said of any language.
COBOL (especially Grace Hopper) really assumed, that the accountant could do his/her programming by him/herself in the 1950's. Of course, this became true only with the spreadsheet (1990's). Paul
Stephen Pelc wrote:
> On Mon, 02 Jun 2008 20:13:29 -0500, AZ Nomad > <aznomad.3@PremoveOBthisOX.COM> wrote: > >> FORTH became irrelevent when acquiring a 16mhz machine with 64K of ram became >> trivial. Also, FORTH is a write-only language. Few people like wading through >> pages of stuff like "OVER + SWAP DO". It was great for small minis during >> the 70's or small micros during the 80's, but it's usefulness has come and >> gone. > > I suspect that you know little or nothing about modern Forth > systems.
I suspect he knows little about modern BASIC languages either, from his comments about BASIC.
On 2008-06-03, invalid@example.com <invalid@example.com> wrote:
> > > > AZ Nomad wrote: > >>Read a book on yacc. It'll let you build compilers >>for just any architecture and in any grammar. > > Really? Ever tried to build a FORTH compiler using YACC? > > Hint: Forth has no syntax...
Huh? It must have syntax. Otherwise any random string of characters would have to be a valid program. I can't imagine that's true... -- Grant Edwards grante Yow! I like your SNOOPY at POSTER!! visi.com
In message <46udneE56bbw_9jVnZ2dnUVZ_r6rnZ2d@visi>, Grant Edwards 
<grante@visi.com> writes
>On 2008-06-03, invalid@example.com <invalid@example.com> wrote: >> >> >> >> AZ Nomad wrote: >> >>>Read a book on yacc. It'll let you build compilers >>>for just any architecture and in any grammar. >> >> Really? Ever tried to build a FORTH compiler using YACC? >> >> Hint: Forth has no syntax... > >Huh? It must have syntax. Otherwise any random string of >characters would have to be a valid program. I can't imagine >that's true...
Only in assembler :-) -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
On Jun 3, 6:51=A0am, Andrew Smallshaw <andr...@sdf.lonestar.org> wrote:
> Forth certainly does have syntax, it is just very regular and there > isn't much of it. =A0A yacc parser for forth is fairly straightforward. > Where yacc has problems is with grammars that are not context free, > which is generally a Bad Thing any in programming language design.
Indeed, the syntax is so trivial, that I think a hand written parser in C would be fewer lines of code than the Yacc grammar. OTOH, it's not nearly that simple given the ability to define compiling words throws a major monkey wrench into the works, although with non-interactive Forth systems, that's something less of an issue. Although I'd certainly not actually use Yacc for this.
On Tue, 3 Jun 2008 16:57:35 +0100, Chris H <chris@phaedsys.org> wrote:

>>On 2008-06-03, invalid@example.com <invalid@example.com> wrote: >>> Hint: Forth has no syntax... >> >>Huh? It must have syntax. Otherwise any random string of >>characters would have to be a valid program. I can't imagine >>that's true... > >Only in assembler :-)
Even assembler has a syntax. And even machine code on most CPU does have one (as there are illegal opcodes). -- 42Bastian Do not email to bastian42@yahoo.com, it's a spam-only account :-) Use <same-name>@monlynx.de instead !
AZ Nomad wrote:
> Really? Ever tried to build a FORTH compiler using YACC? > Hint: Forth has no syntax...
Walter Banks wrote:
> Forth does have a syntax. YACC might not be my choice > of implementation parsers but it probably could be used.
The problem isn't that FORTH has no syntax, but rather that the syntax is extensible, e.g., with BUILD...DOES one can add new control structures. YACC isn't suitable for parsing FORTH because it generally can only handle a fixed syntax. You could use YACC to build a parser for the base FORTH syntax, if you didn't care about the inability to parse FORTH programs that include syntactic extensions.