[comp.sys.mac] YACC and LEX for Macs

shieber@harvard.harvard.edu (01/09/90)

I have a Mac II running THINK C and am interested in getting a version
of Yacc and Lex for it.  Has anyone written such a thing, or ported a
version?  For instance, has anyone ported the GNU Bison and Flex to
Macs?  (From the code I ftped, it didn't look like the GNU people
themselves had done the port.)

Any and all pointers (including to commercial products) would be much
appreciated.

				-- Stuart Shieber
				   shieber@harvard.harvard.edu
				   shieber@harvard.bitnet
-- 
Send compilers articles to compilers@esegue.segue.boston.ma.us
{spdcc | ima | lotus}!esegue.  Meta-mail to compilers-request@esegue.
Please send responses to the author of the message, not the poster.

steve@hp-ptp.HP.COM (Steve_Witten) (01/10/90)

/ hp-ptp:comp.sys.mac / shieber@harvard.harvard.edu /  6:13 pm  Jan  8, 1990 /

I have a Mac II running THINK C and am interested in getting a version
of Yacc and Lex for it.  Has anyone written such a thing, or ported a
version?  For instance, has anyone ported the GNU Bison and Flex to
Macs?  (From the code I ftped, it didn't look like the GNU people
themselves had done the port.)

Any and all pointers (including to commercial products) would be much
appreciated.

				-- Stuart Shieber
				   shieber@harvard.harvard.edu
				   shieber@harvard.bitnet
-- 
Send compilers articles to compilers@esegue.segue.boston.ma.us
{spdcc | ima | lotus}!esegue.  Meta-mail to compilers-request@esegue.
Please send responses to the author of the message, not the poster.
----------

levin@BBN.COM (Joel B Levin) (01/10/90)

In article <1990Jan9.021314.5308@esegue.segue.boston.ma.us> shieber@harvard.harvard.edu writes:
|I have a Mac II running THINK C and am interested in getting a version
|of Yacc and Lex for it.  ...

I have seen at least one, maybe two, commercial versions of Yacc
(probably Lex is available too) advertised in MacTutor.

Flex and Bison have been ported as MPW tools only (i.e. they have to
be run as commands under the MPW shell); as such they are available
from sources like the Sumex archive.  They will not run standalone.

	/JBL
Nets: levin@bbn.com  or {...}!bbn!levin
POTS: (617)873-3463
-- 
Send compilers articles to compilers@esegue.segue.boston.ma.us
{spdcc | ima | lotus}!esegue.  Meta-mail to compilers-request@esegue.
Please send responses to the author of the message, not the poster.

rsfinn@athena.mit.edu (Russell S. Finn) (01/10/90)

In article <1990Jan9.021314.5308@esegue.segue.boston.ma.us> shieber@harvard.harvard.edu writes:
>
>I have a Mac II running THINK C and am interested in getting a version
>of Yacc and Lex for it.  ...

I'm working on porting Bison and Flex to the THINK C environment.  I
was able to bring up Bison fairly quickly, but ran into problems with
Flex which I haven't gotten past yet.  I haven't tested Bison
extensively yet.  No user interface, just the "ccommand" dialog (from
TC 4.0) which lets you type in a command line.

Net denizen Earle Horton has apparently ported Bison and Flex to the
MPW C compiler.  Perhaps he will see this and post some of his
experiences as well.

-- Russ
-- 
Send compilers articles to compilers@esegue.segue.boston.ma.us
{spdcc | ima | lotus}!esegue.  Meta-mail to compilers-request@esegue.
Please send responses to the author of the message, not the poster.

ccel@chance.uucp (CCEL) (01/11/90)

In article <1570019@hp-ptp.HP.COM> steve@hp-ptp.HP.COM (Steve_Witten) writes:
>/ hp-ptp:comp.sys.mac / shieber@harvard.harvard.edu /  6:13 pm  Jan  8, 1990 /
>
>I have a Mac II running THINK C and am interested in getting a version
>of Yacc and Lex for it.  Has anyone written such a thing, or ported a
>version?  For instance, has anyone ported the GNU Bison and Flex to
>Macs?  (From the code I ftped, it didn't look like the GNU people
>themselves had done the port.)

Some time back, GNU got very upset at Apple over a lawsuit Apple tried
against GNU for writing "look-and-feel" software; that is, software
that "works even vaguely" like a Macintosh. Due to this, GNU doesn't
support any Apple machines anywhere (especially the Mac). Pity,
because the GNU software is not only excellent but free, and has
source code and documentation provided. I'm not much of an Apple fan,
and this certainly isn't the place to harp on Macs, so i'll leave it
at that. Included is the "APPLE" file distributed with most GNU
software:

-------------------------------------------------------------------

@unnumbered Special Report: Apple's New Look and Feel

You might have read about the new look-and-feel copyright lawsuit,
Apple vs. Hewlett Packard and Microsoft.  Apple claims the power to
stop people from writing any program that works even vaguely like a
Macintosh.  If they and other look-and-feel plaintiffs triumph, they
will use this new power over the public to put an end to free software
that could substitute for commercial software.

In the weeks after the suit was filed, USENET reverberated with
condemnation for Apple.  GNU supporters Richard Stallman, John Gilmore, and
Paul Rubin decided to take action against Apple's no-longer-deserved
reputation as a force for progress.  Apple's reputation comes from having
made better computers; but now, Apple is working to make all non-Apple
computers worse.  If this deprives the public of the future work of many
companies, the harm done would be many times the good that any one company
does.  Our hope was that if the user community realizes how destructive
Apple's present actions are, Apple would lose customers and have more
trouble finding employees.

Our method of action was to print 5000 buttons that say ``Keep Your Lawyers
Off My Computer'' and hand them out at the West Coast Computer Faire.  The
center of the button shows the rainbow-apple logo with a Gigeresque mouth
full of ferocious teeth.  The picture was drawn by Etienne Suvasa, who also
drew the cover for the GNU Emacs manual.  We call the picture ``Apple's New
Look and Feel''.

We gave out nearly 4000 buttons at the show (saving the rest for
afterwards).  The result was a great success: the extent of anger at Apple
was apparent to everyone at the show.  Many of the invited speakers at the
show wore our buttons, spoke about them, or even waved them from the
podium.  The press noticed this: at least one Macintosh user's magazine
carried a photo of the button afterwards.

Some of you may be considering using, buying, or recommending Macintoshes;
you might even be writing programs for them or thinking about it.  Please
think twice and look for an alternative.  Doing those things means more
success for Apple, and this could encourage Apple to persist in its
aggression.  It also encourages other companies to try similar
obstructionism.

[It is because of this boycott that we don't include support for Macontosh
Unix in GNU software.]

You might think that your current project ``needs'' a Macintosh now.  If
you find yourself thinking this way, consider the far future.  You probably
plan to be alive a year or two from now, and working on some other project.
You will want to get good computers for that, too.  But an Apple monopoly
could easily make the price of such computers at that time several times
what it would otherwise be.  Your decision to use some other kind of
machine, or to defer your purchases now, might make sure that the machines
your next project needs are affordable when you need them.

Newspapers report that Macintosh clones will be available soon.  If
you must buy a Macintosh-like machine, buy a clone.  Don't feed the
lawyers!
-------------------------------------------------------------
Cheers

Randy Tidd
rtidd@mwunix.mitre.org
#define DISCLAIM TRUE

earleh@microsoft.UUCP (Earle HORTON) (01/11/90)

In article <1990Jan10.021257.11269@esegue.segue.boston.ma.us>
	rsfinn@athena.mit.edu (Russell S. Finn) writes:
>Net denizen Earle Horton has apparently ported Bison and Flex to the
>MPW C compiler.  Perhaps he will see this and post some of his
>experiences as well.

     Sure.  Note:  This is me, but the address is a little different. 
There are three big problems with porting Flex to a Macintosh
development system, and a few other little ones.

     a) Flex uses lots of global data, chiefly in arrays.  Many
development systems for the Macintosh do not allow more than 32k of
global data.  The approach I chose to use in porting Flex 2.x was to use
Aztec C 3.6c with the "large data" model.  For THINK C, you may want to
convert a bunch of arrays to pointers, then allocate the space for these
pointers from the heap.

     b) The Macintosh character set uses all eight bits of a character. 
Flex uses the high-order bit as a flag, and in addition uses raw chars
as array subscripts.  Combine this with signed chars, and you have a
recipe for program death.  Chars have to be masked to eight bits in
numerous places within Flex, and the code which uses the high bit as a
flag has to be rewritten.  I strongly recommend that you obtain the code
from my port of Flex, rather than attempting this task yourself.

     c) The line demarcation character used in Macintosh 'TEXT' files is
conventionally the carriage return character, with decimal value 13. 
Flex uses a hard-coded '\n' in numerous places to denote newline, and
'\n' is equal to 10 in most non-weird C implementations.  To make Flex
work with Macintosh 'TEXT' files, either filter the input and output so
that Flex sees an end of line as a '\n', or change Flex to use '\r'
instead of '\n' everywhere. 

     There is an ftp archive at ohio-state where you can find a copy of
Berkeley Yacc which is free to use and not subject to the GNU Copyleft. 
I ported this to Aztec C 3.6c, and sent a copy of the sources to sumex
while I was still doing Macintosh development.  Porting to THINK C
should be relatively straightforward.

Earle R. Horton
-- 
Send compilers articles to compilers@esegue.segue.boston.ma.us
{spdcc | ima | lotus}!esegue.  Meta-mail to compilers-request@esegue.
Please send responses to the author of the message, not the poster.

jba@harald.ruc.dk (Jan B. Andersen) (01/16/90)

earleh@microsoft.UUCP (Earle HORTON) writes:

eh>Flex uses a hard-coded '\n' in numerous places to denote newline, and
eh>'\n' is equal to 10 in most non-weird C implementations.  To make Flex
eh>work with Macintosh 'TEXT' files, either filter the input and output so
eh>that Flex sees an end of line as a '\n', or change Flex to use '\r'
eh>instead of '\n' everywhere. 

Shouldn't '\n' be 'whatever-this-system-uses-to-seperate-textlines'?

Just curious...
Jan B. Andersen <jba@dat.ruc.dk>             ("SIMULA does it with CLASS")