示例#1
0
 def ending():
     def f(acc):
         l = {}
         (a,b) = acc
         if a:
             l['bracket']=a
         if b:
             l['rep']=b.value
         return l
     return (Inner.bracket().possibly() + ((next_type('*') | next_type('?')).possibly())).treat(f).name('ending')
示例#2
0
def nonkey():  #was not_banned
    keyword = [
        'is', 'be', 'are', 'denote', 'define', 'enter', 'namespace', 'stand',
        'if', 'iff', 'inferring', 'the', 'a', 'an', 'we', 'say', 'write',
        'assume', 'suppose', 'let', 'said', 'defined', 'or', 'fix', 'fixed'
    ]

    def p(token):
        return not (c.singularize(token.value) in keyword)

    return c.next_type(['VAR', 'WORD', 'ATOMIC_IDENTIFIER']).if_test(p)
示例#3
0
        def _precedence_level():
            def f(raw):
                ((_, i), pos) = raw
                if len(pos) == 0:
                    l = 'no'
                else:
                    l = pos[0][0][1]
                return (int(i), l)

            return ((next_phrase('with precedence') + c.next_type('INTEGER')) +
                    (next_word('and') + lit('assoc') +
                     next_word('associtivity')).possibly()).treat(f)
示例#4
0
 def nontermprod():
     return (Inner.id() + next_type('/')).treat(lib.fst) + Inner.id()
示例#5
0
 def opt():
     def f(acc):
         ((_,a),_) = acc
         return ('OPT',a)
     return (next_type('(') + Inner.annotated().plus(next_value('|')) + next_type(')')).treat(f).name('opt')
示例#6
0
 def bracket():
     def f(acc):
         ((_,a),_) = acc
         return a
     return (next_type('[') + Inner.annotated().plus() + next_type(']')).treat(f).name('bracket')
示例#7
0
 def dot():
     def f(acc):
         return ('DOT','.')
     return next_type('.').treat(f).name('dot')
示例#8
0
 def label():
     return next_type('LABEL')
示例#9
0
 def escape():
     def f(acc):
         return ('ESCAPED',getvalue(acc))
     return next_type('ESCAPED').treat(f).name('escaped')
示例#10
0
def any_symbol():  # was symbol
    return c.next_type(['SYMBOL'])
示例#11
0
def any_controlseq():  #was controlseq
    return c.next_type(['CONTROLSEQ'])