def foundWeightedExpression(s, loc, toks):
    """
    PyParsing action to run when a weighted expression is found.

    :returns: Ordered pair of the expression and its weight
    """
    toks.weightedExpression = (toks.expr, toks.weight)
    #print 'found weighted expression', toks.dump()
    expr = list(toks.expr)
    if len(expr) == 1:
        expr = expr[0]
    pair = (expr, toks.weight)
    #print 'returning', pair
    return pair