Hi John, thank you for our reply it is really helpful.
Can you please also spend a bit of your time to talk about the “permissiveness" of the pattern syntax. For example the string '`.head `.@tail’ is parsed into a message node with selector `.@tail and a receiver variable node `.head. To my knowledge this is not a valid syntax as the names that have a dot in the beginning should become matchers for statements. Also for example if you write `#@literal the list marker is not doing anything when combines with the literal pound as far as I know, and some people are confused about this, were the any reason why this is not simply rising a syntax error? Cheers. Uko > On 11 Dec 2016, at 00:46, John Brant <br...@refactoryworkers.com> wrote: > > On 12/10/2016 02:37 AM, Nicolai Hess wrote: > >> Question : how should a pattern with three variables >> (first/second/third) look like to match the expression >> { (1@2) . Color red . 3} and assign the (sub)-expressions >> 1@2 >> Color red >> 3 >> to the three variables first/second/third ? > > The RB was written before the {} array syntax. It appears that are a few bugs > in the pattern matching for the arrays. The first is that it needs to reset > the isList variable of RBPatternVariableNode when it is part of a dynamic > array. You can fix that by adding this to the end of > RBPatternVariableNode>>parent: method: > > parent isDynamicArray > ifTrue: [ self isStatement > ifFalse: [ isList := false ] ] > > I think this will make the matching work like what you are expecting. If you > want to match multiple statements, you need to add a ".", but if you just > have "`@first", it will only match any expression node. > > While testing I noticed an error in the RBArrayNode>>match:inContext:. The > method doesn't test the lengths of the nodes before sending the #with:do: > message. If you try to match two arrays of different sizes, you get an error. > This should be changed back to be: > > match: aNode inContext: aDictionary > aNode class = self class > ifFalse: [ ^ false ]. > ^ self matchList: statements against: aNode statements inContext: > aDictionary > > > John Brant >