When using Erlang's yecc to generate a parser from a grammar definition, my file compiled successfully with yecc:file/1, but the generated code wouldn't compile, with the following error:
src/parse.yrl:364:2: function file/2 undefined
I searched for file in the generated code, but found only module attributes -file(...) over and over again.
This was caused by me failing to include a period
.at the end of a function defined in theErlang code.section of my.yrlfile. It seems that the code compiles fine fromyecc, but the lack of a period on the end of a function definition meant that the-file(...)annotation was being treated like a function call after a minus-sign.The generated code looked like this:
After adding the period to the end of the function in the
.yrlfile, the code compiled successfully.