(?) Unix utilities lex and yacc on the mac?

(?) Unix utilities lex and yacc on the mac?

Post by Bev Schwar » Wed, 16 Mar 1994 04:02:15



I have to port a unix application which uses the UNIX utilities lex and
yacc to a macintosh.  In either the MPW or Think environments, is there
an equivalent?  Are there lexical analyzer and/or parsing tools available
for $$ or on the public domain?
I am programming in C and C++.

-Bev

------------------------------
--
Bev Schwartz                    BBN Corporation

617-873-2453                    Cambridge, MA 02138

 
 
 

(?) Unix utilities lex and yacc on the mac?

Post by Dan Eldr » Wed, 16 Mar 1994 04:34:42



>I have to port a unix application which uses the UNIX utilities lex and
>yacc to a macintosh.  In either the MPW or Think environments, is there
>an equivalent?  Are there lexical analyzer and/or parsing tools available
>for $$ or on the public domain?
>I am programming in C and C++.

>-Bev

Look for bison and flex; they've been ported as standalone applications
using Think C's cconsole function (i.e. crude interface, but, hey, it works).
Look at one of the sumex-aim mirror sites.  Versions exist also for MPW.

If you're brave and have a bit of time, 5 (or preferrably 8) meg of memory,
and about 10 meg of disk space, you can install MiNT which is a shell
ported from Atari which runs most unix programs.  It's still buggy
i.e. you can easily make it crash if you try, but is well behaved if
you are.  You can run make, gcc, byacc, bison, and flex under MiNT,
among almost everything else commonly used on unix systems.  I especially
like using the text utilities like grep, sed, awk, tr, ...  It sort of
lives in it's own world and you can't yet develop standalone Mac applications
under MiNT (that I'm aware of), but the files generated under MiNT can
be accessed under Finder (though you have to run files through a CR/LF
filter to resolve the usual unix/Mac incompatibility).

Another, more offbeat solution is Coco, available at neptune.ethz.ch.
There are Modula-2 and Oberon versions for the Mac.  If you use the
Modula-2 version, you can use MacMETH 3.2 (available also at neptune)
to compile the generated scanner and parser.  MacMETH, btw, is IMO
the best free standalone compiler for the mac, though the interface
is not mac-like and Modula-2 isn't exactly a mainstream language (though
it's easy to adapt if you know pascal).  It comes with libraries so you
can easily write Mac standalone applications.  MacMETH also comes with a very
nice and complete manual, unusual for freeware.  Coco is also very nice and is
much easier to use than Yacc/Lex, partly because the parser which is
generated is humanly readable so you could modify it.  Unfortunately,
it's only good for LL(1) (one symbol lookahead) grammars, which is one
reason that the output is readable.  It also generates a recursive
descent parser, which is sometimes criticized for being a resource
hog (but it doesn't bother me; let the computer do the hard work).

        - Dan