# [erlang-questions] Problem parsing Erlang code

Sean Hinde <>
Tue Nov 20 18:46:51 CET 2007

```Works for me:

12> S = "show({'bicycling' = A, 1010 = B}) -> show_activity(A, B,
4,\"bicycling, <10\").".
"show({'bicycling' = A, 1010 = B}) -> show_activity(A, B,
4,\"bicycling, <10\")."
13> {ok, Toks, _} = erl_scan:string(S).
{ok,[{atom,1,show},
{'(',1},
{'{',1},
{atom,1,bicycling},
{'=',1},
{var,1,'A'},
{',',1},
{integer,1,1010},
{'=',1},
{var,1,'B'},
{'}',1},
{')',1},
{'->',1},
{atom,1,show_activity},
{'(',1},
{var,1,'A'},
{',',1},
{var,1,'B'},
{',',1},
{integer,1,4},
{',',1},
{string,1,"bicycling, <10"},
{')',1},
{dot,1}],
1}
14> erl_parse:parse(Toks).
{ok,{function,1,
show,
1,
[{clause,1,
[{tuple,1,
[{match,1,{atom,1,bicycling},{var,
1,'A'}},
{match,1,{integer,1,1010},{var,
1,'B'}}]}],
[],
[{call,1,
{atom,1,show_activity},
[{var,1,'A'},
{var,1,'B'},
{integer,1,4},
{string,1,"bicycling, <10"}]}]}]}}

On 20 Nov 2007, at 17:28, Joel Reymont wrote:

>
> On Nov 20, 2007, at 5:17 PM, Tony Garnock-Jones wrote:
>
>> Did you want a "." instead of a ";" at the end of the string?
>
>
> That's what I thought before sending the message. It doesn't help,
> though.
>
> 5> S1 = "show({'bicycling' = A, 1010 = B}) -> show_activity(A, B, 4,
> \"bicycling, <10\").".
> "show({'bicycling' = A, 1010 = B}) -> show_activity(A, B, 4,
> \"bicycling, <10\")."
> 6> {ok, Toks1, _} = erl_scan:string(S).
> {ok,[{atom,1,show},
>      {'(',1},
>      {'{',1},
>      {atom,1,bicycling},
>      {'=',1},
>      {var,1,'A'},
>      {',',1},
>      {integer,1,1010},
>      {'=',1},
>      {var,1,'B'},
>      {'}',1},
>      {')',1},
>      {'->',1},
>      {atom,1,show_activity},
>      {'(',1},
>      {var,1,'A'},
>      {',',1},
>      {var,1,'B'},
>      {',',1},
>      {integer,1,4},
>      {',',1},
>      {string,1,"bicycling, <10"},
>      {')',1},
>      {';',1}],
>     1}
> 7> {ok, AbsForm} = erl_parse:parse(Toks1).
> =ERROR REPORT==== 20-Nov-2007::17:05:35 ===
> Error in process <0.37.0> with exit value: {{badmatch,{error,
> {999999,erl_parse,["syntax error before: ",[]]}}},[{erl_eval,expr,3}]}
>
> ** exited: {{badmatch,{error,{999999,erl_parse,["syntax error before:
> ",[]]}}},
>             [{erl_eval,expr,3}]} **
>
> --
> http://wagerlabs.com
>
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
>
> http://www.erlang.org/mailman/listinfo/erlang-questions

```