pyparsing (errata)

Paul McGuire ptmcg at austin.rr._bogus_.com
Thu May 13 21:30:34 EDT 2004


> Dang Griffith proposed one alternative construct, here's another, perhaps
> more explicit:
>     lbrack + ( ( ddot + step + ddot + end ) | (ddot + end) ) + rbrack
>

should be:
     lbrack + start + ( ( ddot + step + ddot + end ) | (ddot + end) ) +
rbrack

> Note that the order of the inner construct is important, so as to not
match
> ddot+end before trying ddot+step+ddot+end; '|' is a greedy matching
> operator, creating a MatchFirst object from pyparsing's class library.
You
> could avoid this confusion by using '^', which generates an Or object:
>     lbrack + ( (ddot + end) ^ ( ddot + step + ddot + end ) ) + rbrack

should be:
     lbrack + start + ( (ddot + end) ^ ( ddot + step + ddot + end ) ) +
rbrack

> This will evaluate both subconstructs, and choose the longer of the two.
>
> Or you can use another pyparsing helper, the delimited list
>     lbrack + delimitedlist( Word(nums+"."), delim=":") + rbrack

at least this one is correct!  No, wait, I mis-cased delimitedList!
should be:
     lbrack + delimitedList( Word(nums+"."), delim=":") + rbrack

> This implicitly suppresses delimiters, so that all you will get back are
> ["1","0.1","1"] in the first case and ["1","2"] in the second.
>
> Happy pyparsing!
> -- Paul
>
>
Sorry for the sloppiness,
-- Paul





More information about the Python-list mailing list