Skip to content

Instantly share code, notes, and snippets.

@nox
Created April 27, 2013 18:57
Show Gist options
  • Save nox/5474196 to your computer and use it in GitHub Desktop.
Save nox/5474196 to your computer and use it in GitHub Desktop.
Epp printing lines of parsed files
1> {ok, Epp} = epp:open("t.erl", [], []).
{ok,<0.34.0>}
2> epp:opened_files(Epp).
["t.erl"]
3> epp:parse_file(Epp).
[{attribute,1,file,{"t.erl",1}},
{attribute,1,module,t},
{attribute,-2,file,{"truc.hrl",1}},
{attribute,1,file,{"t.hrl",1}},
{attribute,1,foo,bar},
{attribute,1,file,{"foo/t1.hrl",1}},
{attribute,1,file,{"foo/t2.hrl",1}},
{error,{1,erl_parse,["syntax error before: ",[]]}},
{attribute,2,file,{"foo/t1.hrl",2}},
{function,2,truc,0,[{clause,2,[],[],[{atom,2,machin}]}]},
{attribute,3,file,{"t.hrl",3}},
{attribute,4,file,{"t.erl",4}},
{attribute,-4,file,{"truc.hrl",3}},
{function,3,blah,0,[{clause,3,[],[],[{atom,3,foo}]}]},
{eof,4}]
4> epp:opened_files(Epp).
["foo/t2.hrl","t.erl","foo/t1.hrl","t.hrl"]
5> epp:read_file_line({"t.erl", 1}, Epp).
"-module(t).\n"
6> epp:read_file_line({"t.erl", 2}, Epp).
"-file(\"truc.hrl\", 1).\n"
7> epp:read_file_line({"t.erl", 3}, Epp).
"-include(\"t.hrl\").\n"
8> epp:read_file_line({"t.erl", 4}, Epp).
"\tblah() -> foo.\n"
9> epp:read_file_line({"t.erl", 5}, Epp).
eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment