Exemple #1
0
def _build(name, set):
    # make sure longest equal-prefix items are first
    set = set[:]
    set.sort()
    set.reverse()
    l, u, r = [], [], []
    for item in set:
        l.append(objectgenerator.Literal(value=item.lower()))
        u.append(objectgenerator.Literal(value=item.upper()))
        r.append(objectgenerator.Literal(value=item))
    c[name + '_lc'] = objectgenerator.FirstOfGroup(children=l)
    c[name + '_uc'] = objectgenerator.FirstOfGroup(children=u)
    c[name] = objectgenerator.FirstOfGroup(children=r)
Exemple #2
0
def _build(data):
    """Build the name:time map and match rule for each dataset"""
    data = data[:]
    data.sort()  # get shortest and least values first forcefully...
    # then reverse that, to get longest first...
    data.reverse()
    names = []
    mapping = {}
    for key, value in data:
        names.append(objectgenerator.Literal(value=key))
        mapping[key] = value
    rule = objectgenerator.FirstOfGroup(children=names)
    return mapping, rule
Kilo
Lima
Mike
November
Oscar
Papa
Quebec
Romeo
Sierra
Tango
Uniform
Victor
Whiskey
Xray X-ray
Yankee
Zulu""")

set1, set2 = [], []
for item in _letters:
    set1.append(objectgenerator.Literal(value=item))
    set2.append(objectgenerator.Literal(value=string.lower(item)))

military_alphabet_char = objectgenerator.FirstOfGroup(children=set1)
military_alphabet_char_lower = objectgenerator.FirstOfGroup(children=set2)
del set1, set2

c["military_alphabet_char"] = military_alphabet_char
c["military_alphabet_char_lower"] = military_alphabet_char_lower

common.share(c)
Exemple #4
0
    ("whitespace", "whitespacechar", "whitespace"),
    ("punctuation", "punctuationchar", "punctuation"),
    ("octdigits", "octdigit", "octdigits"),
    ("hexdigits", "hexdigit", "hexdigits"),
    ("printable", "printablechar", "printable"),
]:
    try:
        value = getattr( string, source )
        c[ single ] = objectgenerator.Range( value = value )
        c[ repeat ] = objectgenerator.Range( value = value, repeating =1 )
    except AttributeError:
        pass

# locale-module items
_lc = locale.localeconv()
c[ "locale_decimal_point" ] = objectgenerator.Literal( value = _lc["decimal_point"] )
c[ "locale_thousands_seperator" ] = objectgenerator.Literal( value = _lc["thousands_sep"] )

del _lc

# common, but not really well defined sets
# this is the set of characters which are interpreted
# specially by Python's string-escaping when they
# follow a \\ char.

from simpleparse.stt import TextTools
c[ "EOF" ] = objectgenerator.Prebuilt( value = (
    (None, TextTools.EOF, TextTools.Here),
) )

common.share( c )
Exemple #5
0
Papa
Quebec
Romeo
Sierra
Tango
Uniform
Victor
Whiskey
Xray X-ray
Yankee
Zulu""".split()

set1,set2 = [], []
for item in _letters:
    set1.append(
        objectgenerator.Literal( value=item)
    )
    set2.append(
        objectgenerator.Literal( value=item.lower())
    )

military_alphabet_char = objectgenerator.FirstOfGroup(
    children = set1
)
military_alphabet_char_lower = objectgenerator.FirstOfGroup(
    children = set2
)
del set1, set2

c[ "military_alphabet_char" ] = military_alphabet_char
c[ "military_alphabet_char_lower" ] = military_alphabet_char_lower