Adoption of perl/javascript-style regexp syntax
mats cronqvist
masse@REDACTED
Tue Jun 2 17:45:55 CEST 2009
Ulf Wiger <ulf.wiger@REDACTED> writes:
> 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)
but still. couldn't the grammar can be extended to compile this;
-module(m).
-r"bla".
foo() ->
r"foo".
without changing the meaning of this;
-module(m).
-r"bla".
foo() ->
"foo".
by adding something like
raw_string -> 'r' raw_string : build_raw_string('$2')
to the grammar?
I obviously have no idea what I'm talking about here...
mats
More information about the erlang-questions
mailing list