[erlang-questions] Specs

Kostis Sagonas <>
Tue Jun 7 22:40:46 CEST 2011

James Churchman wrote:
> Hi guys
> When you parse a file with the epp module it has no problems with specs
> However when using erl_scan then passing on to erl_parse, in order to parse a string not a file, it fails on -specs in the code
> Is there a spec aware version of the erl_parse module ?

I find this question a bit strange... the erl_parse module *is* spec 
aware. This is actually how specs are parsed in the system.

Does the following do what you want?

42> SpecInString = "-spec my_function(some_type()) -> 42 | 'gazonk'.",
42> {ok, Toks, 1} = erl_scan:string(SpecInString),
42> erl_parse:parse_form(Toks).


More information about the erlang-questions mailing list