Open arademaker opened 3 years ago
No hidden interaction. The rule is compiled as left-to-right, then the resulting transducer is reversed (yielding right-to-left longest-match). The alphabet transducer is also reversed to make it all work. The alphabet could have been defined explicitly like the below (without reversal):
def Alphabet [a | g | n | {gn} | {hg}];
def InsertBrackets [ Alphabet @-> %} ... %{ ].r;
yielding the same result.
Following the video https://youtu.be/F8F422GldwY, I could reproduce the same behaviour but I really didn't understand why the reverse of the Alphabet worked in the InsertBrackets rule.
For instance, if I got it right, the InsertBrackets will be looking for the sequence
hg
inangha
? I suppose there is some hidden interaction between the@->
and the.r
operator not described in the video.. Am I missing something?