[erlang-questions] scanning a hrl file, for macros.

fess fess-erlang@REDACTED
Thu Mar 5 23:14:09 CET 2009

I have an hrl file with a bunch of macro's in it that are just a bunch  
of strings.  [ The names of query vars used in urls ]  I'd like to  
generate a javascript file from this which has the same mappings.  I  
could simply write a function that explicitly uses each of the macros  
and outputs the javascript.  [ which is what I'm doing. ] However It  
would be nice just to have the list in one place. So, I tried to  
erl_scan/erl_parse it.

erl_scan returns tokens which includes the defines. I could go on from  
there and manually parse the defines. However, I thought that if I got  
a parsed form it would be easier to pick out the macros.

so I moved on to erl_parse, however, I get errors with  
erl_parse:parse_form and erl_parse:parse_exprs, [ {1,erl_parse,"bad  
attribute"}, and {2,erl_parse,["syntax error before: ",["'-'"]]}   
respectively ], the file when included compiles so I'm guessing it's  
not an actual syntax problem.

My tokens look like this:

  ... ]

So, then I thought, ok,  maybe erl_parse needs this stuff to be pre  
processed?  Next I tried out epp:parse_file/3 on it
but that seemed to me to expect to apply macros,  not necessarily show  
you that they were there.

So, clearly I'm not getting things here.   Any pointers would be  


More information about the erlang-questions mailing list