Mathias Mamsch - 2011-04-08

Hi, I would like to see the following addition to countedArray:

def countedArray( elementExpr, countExpr = None):
    if countExpr is None: countExpr = Word(nums)
    arrayExpr = Forward()
    def countFieldParseAction(s,l,t):
        n = int(t)
        arrayExpr << (n and Group(And(*n)) or Group(empty))
        return
    return ( countExpr.setName("arrayLen").setParseAction(countFieldParseAction, callDuringTry=True) + arrayExpr )

This way arrays expressions like  <3> s1 s2 s3  can also be parsed, where the count expression is not a simple integer. Regards, Mathias