[erlang-questions] Parse-transforming !! to a function call

Philip Robinson chlorophil@REDACTED
Sun Aug 12 01:52:08 CEST 2007

On 8/12/07, Joel Reymont <joelr1@REDACTED> wrote:
> I would like x !! y to be transformed into mod:func(x, y). Is this
> possible?

AFAIK a parse_transform can only work on a legal AST.

x !! y is not turned into a valid AST via c(module).

parse_transform(AST, _Options) ->
    [io:format("~p~n", [Node]) || Node <- AST],

-compile({parse_transform, show_ast}).
test() -> x !! y.

1> c(show_ast), c(test).
{error,{5,erl_parse,["syntax error before: ",["'!'"]]}}
./test.erl:5: syntax error before: '!'

i.e.: An error is produced before show_ast can do anything about it.

I do not know if it would be possible to get around this by using any
of the various Erlang parse tools.  (If you do find a way then please
let me know!)


More information about the erlang-questions mailing list