示例#1
0
 def call(st):
     for chr in s:
         c = st.next()
         if chr != c:
             raise ParsecError(st, "Expect '{0}' but got {1}".format(s, c))
     else:
         return s
示例#2
0
def eof(state):
    re = None
    try:
        re = state.next()
    except ParsecEof:
        return None
    raise ParsecError(state, "Expect eof but got {0}".format(re))
示例#3
0
 def call(st):
     re = st.next()
     for item in data:
         if re == item:
             raise ParsecError(
                 st, "Expect none item of {0} but got {1}".format(data, re))
     else:
         return re
示例#4
0
 def call(st):
     raise ParsecError(st, message)
示例#5
0
 def call(st):
     re = st.next()
     if re != data:
         return re
     else:
         raise ParsecError(st, "Expect not equal {0}".format(data))
示例#6
0
 def call(st):
     re = st.next()
     if re == data:
         return re
     else:
         raise ParsecError(st, "Expect {0} but got {1}".format(data, re))
示例#7
0
def space(state):
    c = state.next()
    if c.isspace():
        return c
    raise ParsecError(st, "Expect a space but got {0}".format(c))