0
votes

I am currently working on a simple compiler using flex and bison. folder structure : MainFolder --> src --> Compiler which has the following files add_inp.flex, bison.y main.c and a stack.c Basically when I run individually they compile fine and produce the following files flex produce lex.yy.c and bison produces add_inp.tab.c & add_inp.tab.h the following is my GNUmake file

     lex.yy.c: src/dplc/add_inp.flex bison.tab.c src/dplc/bison.tab.h
           flex src/dplc/add_inp.flex   

     bison.tab.c: src/dplc/bison.y 
           bison -d -t src/dplc/bison.y

     a.exe: src/dplc/main.c lex.yy.c bison.tab.c
            gcc src/dplc/main.c


    clean: 
      rm src/dplc/bison.tab.c src/dplc/bison.tab.h src/dplc/lex.yy.c src/dplc/a.exe

I get this error

make: *** No rule to make target `src/dplc/bison.y', needed by `bison.tab.c'.  Stop.

if I have not compiled the the flex and bison programs individually :

make: *** No rule to make target `src/dplc/bison.y', needed by `bison.tab.c'.  Stop.

I appreciate any help on this Also I need to do Build as well for these programs to run along with the Executor written in Java can someone please give in some suggeston on how I could get that done?

2
Is src/dplc/bison.y present from the directory you are trying to run make?another.anon.coward
The error message is telling you that make can't find src/dplc/bison.y, which is needed to create bison.tab.cChris Dodd

2 Answers

1
votes

This was how I got it to work thanks everyone for all your help.

  CC=gcc
  IDIR =src/dplc/
  CFLAGS=-I$(IDIR)
  a.exe: src/dplc/main.c lex.yy.c bison.tab.c 
$(CC) src/dplc/main.c $(CFLAGS) -I.
    bison.tab.c: src/dplc/bison.y 
bison -d -t src/dplc/bison.y
    lex.yy.c: src/dplc/add_inp.flex bison.tab.c bison.tab.h 
flex src/dplc/add_inp.flex  

    clean: 
rm bison.tab.c bison.tab.h lex.yy.c a.exe
0
votes

You're telling make about a file src/dplc/bison.y, but you claim that your directory structure is MainFolder --> src --> Compiler. Shouldn't that then be src/Compiler/bison.y?