[Issue 11765] std.regex: Negation of character class is not applied to base class first

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 10 12:24:46 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=11765



--- Comment #7 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2014-01-10 12:24:42 PST ---
Ruby makes me nervous:

print /[^abc[e-f]&&[ybc]]/.match('~haystack')

Prints '~' meaning that ^ operator has _lower_ priority then '&&'.

I'm surprised but it's the precedent.

And indeed the following reports empty set and warnings about '-' without
escape i.e. '--' is not supported...

print /[^1--[2]]/.match("0123456789")

re.rb:2: warning: character class has '-' without escape: /[^2--[1]]/
re.rb:2: empty range in char class: /[^2--[1]]/

> [^1-[2]]
> 123456789
> 
> It matches "3".

And .NET is disappointing
[^[2]-1]
doesn't match anything. They somehow special cased only the form of [..-[set]]
and arbitrary nesting of it.

So we have no good precedents.
My thoughts are to make it proper operator precedence grammar 
with priorities:
0 - implict union (pieces that stand together, evaluated first)
1 - ^ (negation)
2 - &&
3 - -- 
4 - || (explicit union, evaluated last)

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list