
Hi Alexandre,
Meanwhile, I have implemented SVA's first_match and ##[i:j].
The latter is just syntactic sugar: a ##[i:j] b = a:([*i:j];b) ##[i:j] b = [*i:j];b ##i = ##[i:i]
While you are at this, maybe you could also implement SVA's ##[*] and ##[+] (as sugar for ##[0:$] and ##[1:$]) for completeness? Please also note that the equality a ##[i:j] b = a:([*i:j];b) is wrong (despite being recommended in some textbooks!), e.g. {empty_word} ##[0:1] {a} =[by definition] = ({empty_word} ##0 {a}) | ({empty_word} ##1 {a}) = {} | {a} = {a} but {empty_word} : ([*0:1];{a}) = {} The reason is that ##0 always loses the empty word. Hence, it's best to split off ##0 (fusion) from ##[i>0:j] (union of concatenations) and handle them separately. Regards, Victor.

On Fri, May 17, 2019 at 5:44 PM Victor Khomenko <victor.khomenko@newcastle.ac.uk> wrote:
While you are at this, maybe you could also implement SVA's ##[*] and ##[+] (as sugar for ##[0:$] and ##[1:$]) for completeness?
Yes I can. I have seen those operators on a couple of presentations online, but could not find any mention of them in the language reference manual.
Please also note that the equality a ##[i:j] b = a:([*i:j];b) is wrong (despite being recommended in some textbooks!), e.g.
Ouch. So currently, assuming j>0, I use these rules a ##[i:j] b = a;[*i-1:j-1];b if i > 0 a ##[0:j] b = a:([*0:j];b) // wrong if a accepts [*0] Do you agree with the following replacement? a ##[i:j] b = a;[*i-1:j-1];b if i > 0 a ##[0:j] b = a:([*0:j];b) if a rejects [*0] a ##[0:j] b = (a;[*0:j]):b if a accepts [*0] but b rejects [*0] a ##[0:j] b = (a:b) | (a;[*0:j-1];b) if a and b both reject [*0] The goal is just to avoid duplicating a and b when possible. -- Alexandre Duret-Lutz

On Fri, May 17, 2019 at 10:16 PM Alexandre Duret-Lutz <adl@lrde.epita.fr> wrote:
a ##[i:j] b = a;[*i-1:j-1];b if i > 0 a ##[0:j] b = a:([*0:j];b) if a rejects [*0] a ##[0:j] b = (a;[*0:j]):b if a accepts [*0] but b rejects [*0] a ##[0:j] b = (a:b) | (a;[*0:j-1];b) if a and b both reject [*0]
I meant a and b both accept [*0] on the last line. It's implemented. -- Alexandre Duret-Lutz
participants (2)
-
Alexandre Duret-Lutz
-
Victor Khomenko