On 05/10/2007, <b class="gmail_sendername">Joel Reymont</b> <<a href="mailto:joelr1@gmail.com">joelr1@gmail.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The result of erl_scan:string/1 has line numbers in it but these get<br>lost once erl_parse:parse/1 runs.<br><br>I would like to have an AST with locations, is there a way to<br>accomplish that?</blockquote><div><br>Sorry I don't really understand what you mean. If you do
<br>
<br>28> {ok,Ts,_}=erl_scan:string("abc([a])->\n1."). <br>
{ok,[{atom,1,abc},<br>
{'(',1},<br>
{'[',1},<br>
{atom,1,a},<br>
{']',1},<br>
{')',1},<br>
{'->',1},<br>
{integer,2,1},<br>
{dot,2}],<br>
2}<br>
29> erl_parse:parse(Ts). <br>
{ok,{function,1,<br>
abc,<br>
1,<br>
[{clause,1,[{cons,1,{atom,1,a},{nil,1}}],[],[{integer,2,1}]}]}}<br>
<br>
you that you do have the line numbers in the AST. If you use parse_term, however, line numbers are removed as it is the term which returned not the AST. </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On a related note, I think it's a bummer that there's no<br>erl_scan:binary/1.</blockquote><div><br>True, true. One of these years ...<br></div><br>Robert<br><br></div>