free_vars/1

Richard Carlsson richardc@REDACTED
Mon Sep 8 10:52:35 CEST 2003


On Mon, 8 Sep 2003, Bengt Kleberg wrote:

> epp_dodger has some well thought out functions (unexported, but that
> is easily handled).

Perhaps I should have a look and see what other functions could
be useful if exported.

> unfortunatly the most lowlevel ones (scan_macro/1 and scan_form/1)
> gives the unwanted result of turning the macro into a free variable.
>
> input lines:
> 	case catch free_vars(Lines) of
> 	{error, Reason} ->
> 		io:format( "CRASH ~w: ~s~n", [?MODULE, Reason] );
> 	Free ->
> 		Function_head = function_head( Free ),
> 		io:put_chars(lists:append( Function_head, Lines ))
> 	end,

Lexically, macro names can be both atoms and variables, so you'd need to
encode this in some way that hides such variables from the 'free_vars'
function. I didn't do that.

> the more high level ones (parse_tokens/1 and rewrite_form/1) crash:

Yes, they expect full "forms" (like function definitions and
attributes), not just any expression.

	/Richard

Richard Carlsson (richardc@REDACTED)   (This space intentionally left blank.)
E-mail: Richard.Carlsson@REDACTED	WWW: http://user.it.uu.se/~richardc/
 "Having users is like optimization: the wise course is to delay it."
   -- Paul Graham



More information about the erlang-questions mailing list