How set path to output of yecc files?

Hi All,

In rebar.config I see option yrl_opts, and documentation yecc.html#file-2 about expected options. So, I’m try find way to put path where generated files will placed. Eg, *.yrl is placed on src/in/*.yrl and I want have generated files in src/out/*.erl - is there a way to do this? I’m ask because by default output files are place on src folder and something tells me that this can be changed :upside_down_face:.

Regards,
–V

5 Likes

It could be changed, but I believe this is going to require a patch to OTP. Specifically adding an outdir option to yecc.erl.

There’s ways you could do this perhaps using a script since yecc will currently accept a parserfile option which will indeed allow you to output it to a specific directory but if you have many yecc files and thus many output files, you’d have to script it so that you pass in these options to yecc yourself on a file by file basis. Short of that, PR required I believe. That said, it would be an easy PR :slight_smile:

Edit:

Here’s a work around using a rebar.config.script :

Files = [{Y, filename:rootname(filename:basename(Y))} || Y <- filelib:wildcard("src/in/*.yrl")],
[yecc:file(Y, [{parserfile, "src/out/" ++ X ++ ".erl"}]) || {Y,X} <- Files].

Note: You’ll probably not want to keep your yecc files within src/in with such a solution. Instead, put them some where else in the root of your project. I don’t believe (off the top of my head) there’s a way to tell rebar to ignore yecc files.

5 Likes