EmbeddedRelated.com
Forums

ideas for a BASIC compiler

Started by Frank Buss June 1, 2008
On Mon, 09 Jun 2008 13:41:46 -0700, Eric Smith <eric@brouhaha.com> wrote:
>AZ Nomad wrote:
<what I had written was snipped> I didn't write this next part.
>> 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.
carry on.

Eric Smith wrote:

> 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.
As I said earlier YACC might not be my choice of implementation parsers but it probably could be used. Many languages have features that are often added by hand in parsers. C's typedef for example. Your point is well taken that forth has compiler implementation issues especially for a language that was designed to be an efficient extensible interpreter. w..


Walter Banks wrote:

>Your point is well taken that forth has compiler >implementation issues
Actually, it is YACC that has forth implementation issues. Nothing wrong with that, of course; it is simply the wrong tool for the job.
>especially for a language that was designed to be an >efficient extensible interpreter.
No it wasn't. Forth was designed to be an efficient and extensible incremental compiler. -- misc.business.product-dev: a Usenet newsgroup about the Business of Product Development. -- Guy Macon <http://www.guymacon.com/>
Walter Banks wrote:
> especially for a language that was designed to be an > efficient extensible interpreter.
Guy Macon wrote:
> No it wasn't. Forth was designed to be an efficient > and extensible incremental compiler.
I'd never heard that Moore had any such intention, but certainly almost all ordinary FORTH systems fail at that, in that they produce threaded interpretive code, not native code.
Op Tue, 10 Jun 2008 16:27:43 -0700 schreef Eric Smith:

> Walter Banks wrote: >> especially for a language that was designed to be an >> efficient extensible interpreter. > > Guy Macon wrote: >> No it wasn't. Forth was designed to be an efficient >> and extensible incremental compiler. > > I'd never heard that Moore had any such intention, but certainly > almost all ordinary FORTH systems fail at that, in that they > produce threaded interpretive code, not native code.
If you had followed the trend for the last decade(s), you would have known that most modern Forths compile to native code and are nearly or equally fast as languages like C. -- Coos
On Wed, 11 Jun 2008 01:54:32 +0200, Coos Haak <chforth@hccnet.nl> wrote:
>Op Tue, 10 Jun 2008 16:27:43 -0700 schreef Eric Smith:
>> Walter Banks wrote: >>> especially for a language that was designed to be an >>> efficient extensible interpreter. >> >> Guy Macon wrote: >>> No it wasn't. Forth was designed to be an efficient >>> and extensible incremental compiler. >> >> I'd never heard that Moore had any such intention, but certainly >> almost all ordinary FORTH systems fail at that, in that they >> produce threaded interpretive code, not native code.
>If you had followed the trend for the last decade(s), you would have known >that most modern Forths compile to native code and are nearly or equally >fast as languages like C.
Many systems have the capability, but more often than not, the code has to be tweaked to compile. Good for support functions, but lousy for application development. While forth was popular in the 80's on micros, I don't know of anybody or any organization that used compilation. It was always too much trouble. Nowadays, almost nobody uses forth. It's too easy to get access to a machine faster than 30mhz and to run a compiler for a more programer friendly language.
On Tue, 10 Jun 2008 21:42:21 -0500, AZ Nomad
<aznomad.3@PremoveOBthisOX.COM> wrote:

>On Wed, 11 Jun 2008 01:54:32 +0200, Coos Haak <chforth@hccnet.nl> wrote: >>Op Tue, 10 Jun 2008 16:27:43 -0700 schreef Eric Smith:
>>If you had followed the trend for the last decade(s), you would have known >>that most modern Forths compile to native code and are nearly or equally >>fast as languages like C.
We haven't shipped a new threaded code system in over ten years.
>Many systems have the capability, but more often than not, the code has to be >tweaked to compile.
The only compilation issues stem from the standards changes over the last 15 years or so, just like other languages.
>While forth was popular in the 80's on micros, I don't >know of anybody or any organization that used compilation. It was always >too much trouble.
So 20+ years ago represents current practice? Now haul out your 20 year old C compiler. Stephen -- Stephen Pelc, stephenXXX@mpeforth.com MicroProcessor Engineering Ltd - More Real, Less Time 133 Hill Lane, Southampton SO15 5AF, England tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691 web: http://www.mpeforth.com - free VFX Forth downloads
On Wed, 11 Jun 2008 09:30:35 GMT, Stephen Pelc <stephenXXX@mpeforth.com> wrote:
>On Tue, 10 Jun 2008 21:42:21 -0500, AZ Nomad ><aznomad.3@PremoveOBthisOX.COM> wrote: >>While forth was popular in the 80's on micros, I don't >>know of anybody or any organization that used compilation. It was always >>too much trouble.
>So 20+ years ago represents current practice? Now haul out >your 20 year old C compiler.
A 20 year old C compiler is a huge improvement over FORTH. The resource limitations that made FORTH a good choice twenty years ago simply don't exist any more.
In message <slrng501ni.iug.aznomad.3@ip70-176-155-130.ph.ph.cox.net>, AZ 
Nomad <aznomad.3@PremoveOBthisOX.COM> writes
>On Wed, 11 Jun 2008 09:30:35 GMT, Stephen Pelc <stephenXXX@mpeforth.com> wrote: >>On Tue, 10 Jun 2008 21:42:21 -0500, AZ Nomad >><aznomad.3@PremoveOBthisOX.COM> wrote: >>>While forth was popular in the 80's on micros, I don't >>>know of anybody or any organization that used compilation. It was always >>>too much trouble. > >>So 20+ years ago represents current practice? Now haul out >>your 20 year old C compiler. > >A 20 year old C compiler is a huge improvement over FORTH. The resource >limitations that made FORTH a good choice twenty years ago simply don't >exist any more.
Just as well no one uses an 8051 any more then isn't it? -- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/


AZ Nomad wrote:

>A 20 year old C compiler is a huge improvement over FORTH. >The resource limitations that made FORTH a good choice >twenty years ago simply don't exist any more.
Do you want to tell the people in that factory in China that are banging out 100,000 products per hour -- every one programmed in FORTH -- that you just repealed the laws of economics and that saving a few cents per unit is no longer important, or should I? I am always amazed at those who imagine that anything that they have no personal experience with cannot possibly exist. -- Guy Macon <http://www.guymacon.com/>