ideas for a BASIC compiler

Why bother re inventing the wheel? MikroElektronika produce an excellent Basic compiler for PIC/AVR/8051 variants. You can incorporate your own assembler code within it, and it has a full suite of math/floating point/I2C/SPI/UART etc librarys supplied as standard. Costs around $150 and its yours, or if you are producing less than 2k of code - its entirely FREE.

I personally have used this - not for a micky mouse product but a full blown image processing application performing intelligent interactive control of a large FPGA.

formatting link

Icky

Reply to
Icky Thwacket
Loading thread data ...

Really? Ever tried to build a FORTH compiler using YACC?

Hint: Forth has no syntax...

Reply to
invalid

why?

irrelevent

If you have the computing facilities for a BASIC compiler, you can probably scrounge up a 60mhz machine and run a compiler for a real language, one that is defined by accepted standards and has a portable code base.

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.

Reply to
AZ Nomad

How much of that interface code is actually portable ?

The higher level application code might benefit from portability, but anyway, if you have a good and tested code in any language in front of you, it shouldn't be too hard to rewrite the code in your favorite language.

Paul

Reply to
Paul Keinanen

I suspect that you know little or nothing about modern Forth systems.

Where Forth scores is in providing interactivity both for debugging and at run time, e.g. for CGI and web scripting. Modern Forth systems use the same compilation techniques as other languages such as C, and so you get both interactivity and performance.

A side effect of Forth is that the anonymous parameter passing encourages factoring, and hence code reuse. A consequence of this is that good Forth code tends to be smaller than the equivalent C code. It is very rare to be able to write the same application in two languages, but on the one occasion I've seen it done, the Forth system fitted in 32k, and the C code exceeded the 64k limit of the CPU's code space. The application was a significant patment terminal system, and the programmers in both langauages were rated as good/guru by their peers.

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
Reply to
Stephen Pelc

Because it shows a basic flaw in YACC -- there exists a simple language (an infinite number of them, actually) that YACC cannot create a compiler for.

Because it shows that your "It'll let you build compilers for just any architecture and in any grammar" statement above is incorrect.

Very much relevent. YACC cannot create compilers with no syntax.

WAAAAHHH!! That mean old man pointed out that I was wrong about YACC! Now I am going to cry and whine that only that limited subset of compilers that YACC can create are worth anything!! Boo Hoo!!!

Reply to
invalid

Even though YACC stands for Yet Another Compiler Compiler, it cannot create compilers at all. It does help with the error prone task of creating a parser, but after that you are pretty much on your own. And the task of compiler implementation has only just begun.

It is a long time since I played around with Forth, but surely there is some syntax. I don't remember if tokenization rules are hardwired, but if they are, then you can write a trivial syntax description in Yacc that recognizes tokens. Even if you can change the tokenization rules, it is always possible to write a Yacc grammar that recognizes single-character terminal symbols and lets the semantic action take care of tokenization. Not very practical, I admit, but I don't think that was a part of the spec to begin with.

--
Pertti
Reply to
Pertti Kellomäki

In message , AZ Nomad writes

This is comp.arch.embedded?

The same can be said of any language.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Reply to
Chris H

Forth does have a syntax. YACC might not be my choice of implementation parsers but it probably could be used.

w..

Reply to
Walter Banks

Forth certainly does have syntax, it is just very regular and there isn't much of it. A 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.

Try writing a yacc parser for e.g. troff source and/or output files, or even HTML, and you soon give up and decide to write the parser by hand. I'm always relutant to do this because hand written parsers invariably end up as messy bits of code in my experience but sometimes that can't be helped.

--
Andrew Smallshaw
andrews@sdf.lonestar.org
Reply to
Andrew Smallshaw

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"

Reply to
AZ Nomad

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.

Reply to
David Brown

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     /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Reply to
Chris H

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 ----

formatting link
offers corporate packages that have access to 100,000+ newsgroups

Reply to
spam

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

Reply to
Paul Keinanen

through

I suspect he knows little about modern BASIC languages either, from his comments about BASIC.

Reply to
Gary Peek

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
Reply to
Grant Edwards

Only in assembler :-)

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Reply to
Chris H

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.

Reply to
robertwessel2

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 @monlynx.de instead !
Reply to
42Bastian Schick

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.