Search code examples
xcode4yacclex

Lex and Yacc Xcode 4


How to set up lex and Yacc with Xcode 4? What custom script should I write in the Build Rules to do that?

I have one lex file abc.l and one yacc file cba.y both placed in the same directory as that of other project source files. parser.ymm

%{
    #include<iostream>
    #include<stdio.h>
    #include "querystructure.h"
    using namespace std;
    static int col_id = 0;


extern void yyerror (char* message);
extern int yylex ();
%}

lexer.l/lexer.lm

%{
    #include <stdio.h>
    #include "y.tab.h"

%}

Solution

  • It sounds like all you need to do is to rename your *.y file to *.ym:

    I am extremely pleased that all I had to do was make the suffix to the yacc file be .ym instead of .y to get Xcode to do all the right things.

    I have not tried this, but the linked post suggests that XCode has enough smarts built into it in order to deal with parser generators "automagically".