Using Bison to Build Multiple Parsers in the Same Application
Using Bison to Build Multiple Parsers in the Same Application
- Subject: Using Bison to Build Multiple Parsers in the Same Application
- From: Thomas Wetmore <email@hidden>
- Date: Sat, 19 Feb 2011 08:28:00 -0500
Bison is the Free Software Foundation version of yacc, a parser generator. Xcode has a builtin rule for building projects with bison/yacc files. The rule transforms .ym files into two files, y.tab.m and y.tab.h, that are then compiled normally.
A long time problem with yacc is that it uses global name space which prevents a single application from holding two or more generated parsers. Bison solved this problem with two command line options:
-p globalprefix
-b fileprefix
The first changes the names the functions generated in global space so there is no clash (it still uses global name spaces, but you avoid clashes by picking your own prefixes). The second option changes the names of the generated files. Both options work in the Mac OS X version of bison supplied with the development tools. However Xcode co-opts the use of the -b option in the builtin yacc rule in order to change the location of the directory where the files are generated (a directory named DerivedSources deep in the Xcode build subdirectory). So, with Xcode co-opting the -b option simply to change the location of the generated files, developers can't use it to change the names of the generated files. So we're back to the original problem of the inability to have more than one generated parser in the same application.
My questions are:
1) Are there any Cocoa and bison experts out there who have found workable solutions to the problem of having multiple parsers in the same application.
2) Given that I can't solve this problem using the default Cocoa yacc/bison build rules, what would be the issues in writing custom Cocoa target level build phases; I apologize for the ignorance behind asking that question, but the only build phases I have added to Xcode projects are simple file move phases -- I have yet to enter the rarified air of custom script phases.
3) Are there any other parser generators in common use in Mac OS X applications that don't have the problems caused by bison's and yacc's ancient reliance on global name spaces?
Tom Wetmore _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden