Re: XCode 4 and Yacc and Lex files
Re: XCode 4 and Yacc and Lex files
- Subject: Re: XCode 4 and Yacc and Lex files
- From: Thomas Wetmore <email@hidden>
- Date: Sun, 03 Apr 2011 12:22:31 -0400
Jari,
In Xcode 4 there are four build settings for yacc:
Generate Debugging Directives
Generated File Stem
Insert #line Directives
Other yacc flags
My guess is that you can do whatever you need using these. I was hesitant about how well Xcode would support yacc when I first had to add custom parsers to a couple applications. I feared such an old and now relatively unused technology would have been not much cared about by the Apple engineers. I was especially pleased when I learned that not only is yacc fully supported, but Apple had added support for .ym files, which are yacc files where the semantic actions and other custom escapes can be written in Objective-C. An Apple glow moment. Later, when I had to put two custom parsers in the same application, and learned about the "Generated File Stem" setting, I had another Apple glow moment.
Hope this leads to an Apple glow moment for you too!
Tom Wetmore
On Apr 3, 2011, at 11:52 AM, Jari Perttunen wrote:
> Thank you Tom for your advice.
>
> You were right: the problem was indeed the #line lines generated by bison and flex.
> I recompiled manually Yacc and Lex files without the #line lines, imported the generated c++ source
> and header files to my project and the project build succeeded.
>
> Now I just have to find my command line binary to be able to use it :).
>
> As you say the ideal solution is to let XCode handle Yacc and Lex files.
> I am just not able to enter successfully the command for the Yacc file
>
> /usr/bin/bison -d --no-lines --debug -p l -o parser_tab.cpp parser.y
>
> into the build system starting from "System Yacc rule" --> "Copy to Target" --> "Yacc source files using Script".
> Is this the way at all to tell XCode to handle Yacc files with custom script?
>
> (The problem is similar for the Lex file, but I assume the solution is also similar)
>
> On 2 Apr 2011, at 22:30, Thomas Wetmore wrote:
>
>> Jari,
>>
>> I have had no problems with yacc (don't use lex) on Xcode 3 or 4. But I keep the yacc files in the project and let Xcode's default rules take care of them for me. I use .ym files instead of .y files so the semantic actions and other code can be written in Objective-C instead of plain C.
>>
>> Your issue might be caused by the #line lines that are inserted into the generated files when you run yacc by hand. Xcode might be trying to report errors and unable to resolve the #line values back to an original yacc or lex file. I think there is an option you can use when calling yacc/bison to keep those lines from being generated.
>>
>> I would bit the bullet and put your lex and yacc files in your project and let Xcode handle them for you. Xcode can even handle projects with more than one yacc file through a build setting available via the target settings panel. Good luck finding where Xcode puts the derived files with Xcode4! You will find them after awhile.
>>
>> 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