Adoption of perl/javascript-style regexp syntax

Ulf Wiger ulf.wiger@REDACTED
Tue Jun 2 16:58:15 CEST 2009


mats cronqvist wrote:
> Ulf Wiger <ulf.wiger@REDACTED> writes:
> 
>> This *will* compile:
>>
>> -module(m).
>> -export([f/0]).
>>
>> -r"\b".
>>
>> f() ->
>>     b.
> 
>   argh... 
> 
>> Changing the meaning of r"\b", it will no longer compile.
> 
>   but... the -r is handled by the preprocessor, not? so the parser
>   will never see the -r"\b" bit, and it will still compile.

No, the preprocessor (epp) gets the 'attribute' form from the
parser, and only deals with certain attributes. The compiler
deals with some others, and external tools (like dialyzer)
can also rely on attributes.

They are part of the grammar.

attribute -> '-' atom attr_val     : build_attribute('$2', '$3').
...

attr_val -> expr                     : ['$1'].
attr_val -> expr ',' exprs           : ['$1' | '$3'].
attr_val -> '(' expr ',' exprs ')'   : ['$2' | '$4'].


(From erl_parse.yrl)

BR,
Ulf W
-- 
Ulf Wiger
CTO, Erlang Training & Consulting Ltd
http://www.erlang-consulting.com


More information about the erlang-questions mailing list