[TRE-general] Another example

Chris Kuklewicz tre-general at list.mightyreason.com
Mon Jan 29 17:03:24 EET 2007


First: I am sorry my last message may have been sent several times -- I was
incompetent for those crucial minutes.

I have another repetition case (thanks to QuickCheck) that may isolate the
interaction of ($) with {2,}.  The one that we disagree on is:

*Main> matchit' "xx" "(.|$){2,}"
("Posix  ",("",array (0,1) [(0,("xx",(0,2))),(1,("",(2,0)))],""))
("TDFA   ",("",array (0,1) [(0,("xx",(0,2))),(1,("x",(1,1)))],""))
("TRE    ",("",array (0,1) [(0,("xx",(0,2))),(1,("",(2,0)))],""))

Where I think TRE should agree with TDFA.

We agree on these variants:

*Main> matchit' "xx" "(.|$)(.|$){1,}"
("Posix  ",("",array (0,2) [(0,("xx",(0,2))),(1,("x",(0,1))),(2,("",(2,0)))],""))
("TDFA   ",("",array (0,2) [(0,("xx",(0,2))),(1,("x",(0,1))),(2,("x",(1,1)))],""))
("TRE    ",("",array (0,2) [(0,("xx",(0,2))),(1,("x",(0,1))),(2,("x",(1,1)))],""))

*Main> matchit' "xx" "(.|$)(.|$)(.|$){0,}"
("Posix  ",("",array (0,3)
[(0,("xx",(0,2))),(1,("x",(0,1))),(2,("x",(1,1))),(3,("",(2,0)))],""))
("TDFA   ",("",array (0,3)
[(0,("xx",(0,2))),(1,("x",(0,1))),(2,("x",(1,1))),(3,("",(2,0)))],""))
("TRE    ",("",array (0,3)
[(0,("xx",(0,2))),(1,("x",(0,1))),(2,("x",(1,1))),(3,("",(2,0)))],""))

*Main> matchit' "xx" "(.|$)(.|$)(.|$)*"
("Posix  ",("",array (0,3)
[(0,("xx",(0,2))),(1,("x",(0,1))),(2,("x",(1,1))),(3,("",(2,0)))],""))
("TDFA   ",("",array (0,3)
[(0,("xx",(0,2))),(1,("x",(0,1))),(2,("x",(1,1))),(3,("",(2,0)))],""))
("TRE    ",("",array (0,3)
[(0,("xx",(0,2))),(1,("x",(0,1))),(2,("x",(1,1))),(3,("",(2,0)))],""))

*Main> matchit' "xx" "(.|$){3,}"
("Posix  ",("",array (0,1) [(0,("xx",(0,2))),(1,("",(2,0)))],""))
("TDFA   ",("",array (0,1) [(0,("xx",(0,2))),(1,("",(2,0)))],""))
("TRE    ",("",array (0,1) [(0,("xx",(0,2))),(1,("",(2,0)))],""))

Adding a maximum count to the {2,} makes us agree:

*Main> matchit' "xx" "(.|$){2,2}"
("Posix  ",("",array (0,1) [(0,("xx",(0,2))),(1,("x",(1,1)))],""))
("TDFA   ",("",array (0,1) [(0,("xx",(0,2))),(1,("x",(1,1)))],""))
("TRE    ",("",array (0,1) [(0,("xx",(0,2))),(1,("x",(1,1)))],""))

*Main> matchit' "xx" "(.|$){2,3}"
"(.|$){2,3}"
("Posix  ",("",array (0,1) [(0,("xx",(0,2))),(1,("",(2,0)))],""))
("TDFA   ",("",array (0,1) [(0,("xx",(0,2))),(1,("x",(1,1)))],""))
("TRE    ",("",array (0,1) [(0,("xx",(0,2))),(1,("x",(1,1)))],""))

*Main> matchit' "xx" "(.|$){2,4}"
("Posix  ",("",array (0,1) [(0,("xx",(0,2))),(1,("",(2,0)))],""))
("TDFA   ",("",array (0,1) [(0,("xx",(0,2))),(1,("x",(1,1)))],""))
("TRE    ",("",array (0,1) [(0,("xx",(0,2))),(1,("x",(1,1)))],""))

*Main> matchit' "xx" "(.|$){2,14}"
("Posix  ",("",array (0,1) [(0,("xx",(0,2))),(1,("",(2,0)))],""))
("TDFA   ",("",array (0,1) [(0,("xx",(0,2))),(1,("x",(1,1)))],""))
("TRE    ",("",array (0,1) [(0,("xx",(0,2))),(1,("x",(1,1)))],""))

Changing (.|$) to (.) makes us agree:

*Main> matchit' "xx" "(.){2,}"
("Posix  ",("",array (0,1) [(0,("xx",(0,2))),(1,("x",(1,1)))],""))
("TDFA   ",("",array (0,1) [(0,("xx",(0,2))),(1,("x",(1,1)))],""))
("TRE    ",("",array (0,1) [(0,("xx",(0,2))),(1,("x",(1,1)))],""))

-- 
Chris


More information about the TRE-general mailing list