0

I'm really new to lex/yacc/bison and parsers in general.

I created lex and yacc files (not sure if the programs themselves are relevant here), then compiled with the following commands in Terminal on my Mac:

    lex lexer.l
    yacc -d example.y
    cc lex.yy.c y.tab.c -o example

Which made example.y disappear from my computer, and replaced it with y.tab.c and y.tab.h, and lex.yy.c also showed up though lexer.l was still there.

But I did not have any a.out or anything like that to run.

So I edited lexer.l and compiled it again.

Now lex.yy.c has disappeared and Terminal tells me:

    lexer.l:53: name defined twice

I want to decompile the lexer.l file and make everything semi normal again! Halp!

Thanks in advance everybody!!!

  • 3
    If your `example.y` file "disappeared" then you did something else that removed it. Neither the `yacc` command nor the compiler would do such a thing. Are you sure you named the executable `example` and not `examply.y` and overwrote the Yacc file? – Some programmer dude Mar 14 '16 at 15:25
  • 2
    And to answer your question, no, you can't "decompile" a Lex or Yacc file from the autogenerated code. If `lex` and `yacc` left comments about the original rules you could use them to recreate the files, but there's no tool to do it automatically. – Some programmer dude Mar 14 '16 at 15:27
  • Oooh... I thought the yacc file was supposed to disappear.... now I feel sick... it was definitely called example.y, because the file name went red in my Xcode window where the files that were open were listed. – Camellia Wunderbar Mar 14 '16 at 15:43
  • Wait, you mean, if I accidentally typed in cc lex.yy.c y.tab.c -o example.y something like my file disappearing might happen? – Camellia Wunderbar Mar 14 '16 at 15:44
  • cc lex.yy.c y.tab.c -o example.y <<< oops. I did. I feel sick. maybe I can rewrite the file still... thank you very much. – Camellia Wunderbar Mar 14 '16 at 15:49

0 Answers0