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')
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)
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)
def nontermprod(): return (Inner.id() + next_type('/')).treat(lib.fst) + Inner.id()
def opt(): def f(acc): ((_,a),_) = acc return ('OPT',a) return (next_type('(') + Inner.annotated().plus(next_value('|')) + next_type(')')).treat(f).name('opt')
def bracket(): def f(acc): ((_,a),_) = acc return a return (next_type('[') + Inner.annotated().plus() + next_type(']')).treat(f).name('bracket')
def dot(): def f(acc): return ('DOT','.') return next_type('.').treat(f).name('dot')
def label(): return next_type('LABEL')
def escape(): def f(acc): return ('ESCAPED',getvalue(acc)) return next_type('ESCAPED').treat(f).name('escaped')
def any_symbol(): # was symbol return c.next_type(['SYMBOL'])
def any_controlseq(): #was controlseq return c.next_type(['CONTROLSEQ'])