parse external files -- which library files call ?

Sean Hinde sean.hinde@REDACTED
Fri Oct 28 01:04:08 CEST 2005


On 27 Oct 2005, at 23:25, Gaspar Chilingarov wrote:

> Hi all!
>
> I need to have files in plaintext format, describing some forms  
> functionality -
> which i need to load, parse and generate html from them.
>
> files will look like this:
>
> {form, personalinfo,
>     [ {firstname, string},
>       {lastname, string},
>       {submit, button}
>     ],
>     fun
>       (List) -> validateForm(List)
>     end
> }
>
>
> so, I need them parse info valid erlkang terms - tuples, lists,  
> funs, etc.
> I understand , that such functionality already is in library :)  
> but , hm, I've
> missed where )

(dcr@REDACTED)25> {ok, B, _}=erl_scan:string(A).
{ok,[{'{',1},
      {atom,1,form},
      {',',1},
      {atom,1,personalinfo},
      {',',1},
      {'[',2},
etc...

(dcr@REDACTED)28> erl_parse:parse_exprs(B ++ [{dot,1}]).
{ok,[{tuple,1,
             [{atom,1,form},
              {atom,1,personalinfo},
              {cons,2,
                    {tuple,2,[{atom,2,firstname},{atom,2,string}]},
                    {cons,3,
                          {tuple,3,[{atom,3,lastname},{atom,3,string}]},
                          {cons,4,{tuple,4,[{atom,4|...},{atom|...}]}, 
{nil,5}}}},
              {'fun',6,
                     {clauses,[{clause,7,
                                       [{var,7,'List'}],
                                       [],
                                       [{call,7,{atom|...}, 
[...]}]}]}}]}]}

This sort of thing?

Sean




More information about the erlang-questions mailing list