1

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"

%}
Julius Canute
  • 221
  • 5
  • 16

1 Answers1

3

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".

Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
  • The lexer is not getting included...I am getting the following error:y.tab.c:1327:16: error: use of undeclared identifier 'yylex'; – Julius Canute Dec 25 '11 at 04:44
  • @JuliusCanute This is a complete shot in the dark, but try renaming your `*.l` file to `*.lm` and see if it works. – Sergey Kalinichenko Dec 25 '11 at 04:48
  • Still getting the following error: Undefined symbols for architecture x86_64: "yylex()", referenced from: yyparse() in y.tab.o ld: symbol(s) not found for architecture x86_64 – Julius Canute Dec 25 '11 at 04:55
  • @JuliusCanute This is probably related to your grammar/lexer files. Could you update the question with the top portion of both? The only parts of interest are between `%{` and `}%` – Sergey Kalinichenko Dec 25 '11 at 05:01
  • @JuliusCanute It's getting late in my time zone, I wouldn't be able to reply till tomorrow. Take a look at the answer in [this thread](http://stackoverflow.com/questions/1596239/simple-flex-bison-c) to see if you may be missing an `extern "C"` declaration somewhere. – Sergey Kalinichenko Dec 25 '11 at 05:11