コード例 #1
0
    def __init__(self):
        family      = Regex(r'([^%s]|(\\[%s]))*' %
                            (family_punc, family_punc)) \
                      .setParseAction(self._family)
        size        = Regex(r"([0-9]+\.?[0-9]*|\.[0-9]+)") \
                      .setParseAction(self._size)
        name        = Regex(r'[a-z]+') \
                      .setParseAction(self._name)
        value       = Regex(r'([^%s]|(\\[%s]))*' %
                            (value_punc, value_punc)) \
                      .setParseAction(self._value)

        families = (family + ZeroOrMore(Literal(',') + family)).setParseAction(
            self._families)

        point_sizes = (size + ZeroOrMore(Literal(',') + size)).setParseAction(
            self._point_sizes)

        property = ((name + Suppress(Literal('=')) + value +
                     ZeroOrMore(Suppress(Literal(',')) + value))
                    | name).setParseAction(self._property)

        pattern = (Optional(families) + Optional(Literal('-') + point_sizes) +
                   ZeroOrMore(Literal(':') + property) + StringEnd())

        self._parser = pattern
        self.ParseException = ParseException
コード例 #2
0
        #print 'subsup', toks
        prev, undersym, down, oversym, up = toks[0]

        if self.is_overunder(prev):
            prev.neighbors['below'] = down
            prev.neighbors['above'] = up
        else:
            prev.neighbors['subscript'] = down
            prev.neighbors['superscript'] = up

        return loc, [prev]


handler = Handler()

lbrace = Literal('{').suppress()
rbrace = Literal('}').suppress()
lbrack = Literal('[')
rbrack = Literal(']')
lparen = Literal('(')
rparen = Literal(')')
grouping = lbrack | rbrack | lparen | rparen

bslash = Literal('\\')

langle = Literal('<')
rangle = Literal('>')
equals = Literal('=')
relation = langle | rangle | equals

colon = Literal(':')
コード例 #3
0
ファイル: mathtext.py プロジェクト: jtomase/matplotlib
        prev, undersym, down, oversym, up = toks[0]

        if self.is_overunder(prev):
            prev.neighbors['below'] = down
            prev.neighbors['above'] = up
        else:
            prev.neighbors['subscript'] = down
            prev.neighbors['superscript'] = up

        return loc, [prev]



handler = Handler()

lbrace = Literal('{').suppress()
rbrace = Literal('}').suppress()
lbrack = Literal('[')
rbrack = Literal(']')
lparen = Literal('(')
rparen = Literal(')')
grouping = lbrack | rbrack | lparen | rparen

bslash = Literal('\\')


langle = Literal('<')
rangle = Literal('>')
equals = Literal('=')
relation = langle | rangle | equals