Adoption of perl/javascript-style regexp syntax

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


mats cronqvist wrote:
> Ulf Wiger <ulf.wiger@REDACTED> writes:
> 
>> The problem is that this uses regular tokens and has a valid
>> parse scan result today:
>>
>> 4> erl_scan:string("r'\b'.").
>> {ok,[{atom,1,r},{atom,1,'\b'},{dot,1}],1}
>>
> 
>   eh? 
> 
>   first off, it should be r"\b".

Same objection applies.

>   second, it will scan, but not parse...
> 
> 1> {ok,Ts,_} = erl_scan:string("r\"\b\".").
> {ok,[{atom,1,r},{string,1,"\b"},{dot,1}],1}
> 
> 2> erl_parse:parse(Ts).
> {error,{1,erl_parse,["syntax error before: ","\"\\b\""]}}
> 
>   or do I misunderstand you?

First, I was going to hang my head in shame for posting
without thinking hard enough, but what I meant was that it
could be part of a valid parse.

This *will* compile:

-module(m).
-export([f/0]).

-r"\b".

f() ->
     b.


Changing the meaning of r"\b", it will no longer compile.

(I did say that breaking existing code was unlikely... ;-)

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


More information about the erlang-questions mailing list