home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!cs.utexas.edu!tamsun.tamu.edu!bpb9204
- From: bpb9204@tamsun.tamu.edu (Brent)
- Subject: Re: yacc/lex -like utilities for thinkC?
- Message-ID: <1992Aug27.143139.12460@tamsun.tamu.edu>
- Organization: Texas A&M Univ., Inc.
- References: <1992Aug26.204509.23323@cybernet.cse.fau.edu>
- Date: Thu, 27 Aug 1992 14:31:39 GMT
- Lines: 45
-
- pollansw@cse.fau.edu (Warren Pollans) writes:
- |Are there utilities like the unix yacc and lex available for use
- |with thinkC? I'm taking a compiler-writing course and would like
- |to do as much as possible of the project (1000-1500 lines) at home
- |on my SE (2.5M, probably expanded to 4M). At worst, I can write
- |and test modules at home and put the whole thing together on the
- |unix system (sunOS).
-
- Yes, there are a few. For lex, there is GNU's Flex (fast lexer generator)
- and for yacc there is MacYacc, GNU's bison, and Berkeley yacc (byacc).
-
- MacYacc may not even be available anymore; it was free but some say it was
- buggy. I never used it for anything.
-
- I have found that Bison works great. While it produces huge C source files,
- they compile to almost half of what an AT&T yacc parser would! Also, bison
- has been reengineered (not a port of AT&T yacc) so it's much more efficient.
- AND, bison can be made compatible with yacc.
-
- I have never used byacc.
- GNU's flex works fine for me, also.
-
- Now that I have the quick rundown of the available tools, I want to make some
- comments. First, if you use the GNU tools, be aware they come with certain
- licenses and policies that you may not like. See their Copyright files
- (included with the programs) for details. Personally, I didn't have a problem
- with their policies.
-
- Second, you can quickly develop a compiler with flex and bison. For my
- compiler design project, we had to write a compiler for a subset of pascal.
- Within two hours I had a working flex/bison-based parser. Unfortunately,
- we had to hand-code everything (and we really learned how LL(1) & LALR(1)
- parsers click!). ;-)
-
- If you have to hand-code your scanner ("lexer") and parser, you can still
- find flex and bison great for testing. Use both tools in the beginning to
- get a feel for the grammar you are parsing; it turned out our prof gave us
- many ambiguities in our language, which added about 50% more rules to the
- original grammar. Once you have the grammar figured out, hand-code your
- lexer and test it with the bison parser. Finally, code the parser.
-
- Hope this helps someone.
-
- -Brent, N5VMG
- bpb9204@tamsun.tamu.edu
-