[erlang-questions] Specs

James Churchman <>
Fri Jun 10 21:59:47 CEST 2011


ok i FINALLY worked it out thanks, the spec i was passing in did not end in
a full stop :-)

On 10 June 2011 20:38, James Churchman <> wrote:

> Hi Kostis, i must have had an error in my specs then maybe, as otherwise
> they i thought looked similar to yours, but were prefixed with the variable
> name and "::"
>
> Thanks very much for your help
>
> James
>
> On 7 June 2011 21:40, Kostis Sagonas <> wrote:
>
>> 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).
>> {ok,{attribute,1,spec,
>>               {{my_function,1},
>>                [{type,1,'fun',
>>                       [{type,1,product,[{type,1,some_type,[]}]},
>>
>> {type,1,union,[{integer,1,42},{atom,1,gazonk}]}]}]}}}
>>
>> Kostis
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110610/4861e801/attachment.html>


More information about the erlang-questions mailing list