I have multiple rules that are like
identifierList ^ identifier, ($, asParser trim, identifier) star It parses a list of identifiers. The output is #('abc' #(#($, 'def') #($, 'ghj'))) What I like to have is an output of #( 'abc' 'def' 'ghj' ) I can produce this by changing the rule to ^ identifier , (($, asParser trim, identifier) ==> [:nodes| nodes second]) star ==> [:nodes| (Array with: nodes first) copyWithAll: nodes second ] But now the rule is uglified. It doesn't work with flatten because I it would flatten all together and I want to have the identifiers separated. What would be useful is a "skip" keyword for the parser so that it is skipped for the output nodes (that would be something like ?: in perl regex). Are there some better way to do this? thanks in advance, Norbert _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
You probably like #separatedBy:
identifierList ^ identifier separatedBy: $, asParser trim Now that does not remove the comma, but you get a flat list that you can easily filter. Cheers, Lukas On 17 June 2011 16:55, Norbert Hartl <[hidden email]> wrote: > I have multiple rules that are like > > identifierList > ^ identifier, ($, asParser trim, identifier) star > > It parses a list of identifiers. The output is > > #('abc' #(#($, 'def') #($, 'ghj'))) > > What I like to have is an output of > > #( 'abc' 'def' 'ghj' ) > > I can produce this by changing the rule to > > ^ identifier , (($, asParser trim, identifier) ==> [:nodes| nodes second]) star > ==> [:nodes| (Array with: nodes first) copyWithAll: nodes second ] > > But now the rule is uglified. It doesn't work with flatten because I it would flatten all together and I want to have the identifiers separated. What would be useful is a "skip" keyword for the parser so that it is skipped for the output nodes (that would be something like ?: in perl regex). > Are there some better way to do this? > > thanks in advance, > > Norbert > > > > _______________________________________________ > Moose-dev mailing list > [hidden email] > https://www.iam.unibe.ch/mailman/listinfo/moose-dev > -- Lukas Renggli www.lukas-renggli.ch _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
Am 17.06.2011 um 17:11 schrieb Lukas Renggli: > You probably like #separatedBy: > > identifierList > ^ identifier separatedBy: $, asParser trim > > Now that does not remove the comma, but you get a flat list that you > can easily filter. Ah, much better indeed. So actually nice would be identifierList ^ identifier separatedBy: $, asParser skip trim :) Althoug skip is probably not the right word. thanks, Norbert > > On 17 June 2011 16:55, Norbert Hartl <[hidden email]> wrote: >> I have multiple rules that are like >> >> identifierList >> ^ identifier, ($, asParser trim, identifier) star >> >> It parses a list of identifiers. The output is >> >> #('abc' #(#($, 'def') #($, 'ghj'))) >> >> What I like to have is an output of >> >> #( 'abc' 'def' 'ghj' ) >> >> I can produce this by changing the rule to >> >> ^ identifier , (($, asParser trim, identifier) ==> [:nodes| nodes second]) star >> ==> [:nodes| (Array with: nodes first) copyWithAll: nodes second ] >> >> But now the rule is uglified. It doesn't work with flatten because I it would flatten all together and I want to have the identifiers separated. What would be useful is a "skip" keyword for the parser so that it is skipped for the output nodes (that would be something like ?: in perl regex). >> Are there some better way to do this? >> >> thanks in advance, >> >> Norbert >> >> >> >> _______________________________________________ >> Moose-dev mailing list >> [hidden email] >> https://www.iam.unibe.ch/mailman/listinfo/moose-dev >> > > > > -- > Lukas Renggli > www.lukas-renggli.ch > > _______________________________________________ > Moose-dev mailing list > [hidden email] > https://www.iam.unibe.ch/mailman/listinfo/moose-dev _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
Free forum by Nabble | Edit this page |