Beispiel #1
0
 def processor(state):
     newstate = self(state)
     if isParseSuccess(newstate):
         return newstate
     # fail if any input has been consumed
     if not self.arbitraryLookAhead() and inputConsumed(newstate, state):
         return newstate
     newstate2 = other(state)
     return newstate2 if isParseSuccess(newstate2) else mergeErrors(newstate, newstate2)
Beispiel #2
0
 def processor(state):
     tree = []
     while True:
         newstate = parser(state)
         if isParseError(newstate):
             break
         tree.append(parseSuccessTree(newstate))
         state = newstate
     return setParseSuccessTree(state, tree) if not inputConsumed(newstate, state) else newstate
Beispiel #3
0
 def processor(state):
     tree = []
     while True:
         newstate = parser(state)
         if isParseError(newstate):
             break
         tree.append(parseSuccessTree(newstate))
         state = newstate
     return setParseSuccessTree(
         state, tree) if not inputConsumed(newstate, state) else newstate
Beispiel #4
0
 def processor(state):
     newstate = self(state)
     if isParseSuccess(newstate):
         return newstate
     # fail if any input has been consumed
     if not self.arbitraryLookAhead() and inputConsumed(
             newstate, state):
         return newstate
     newstate2 = other(state)
     return newstate2 if isParseSuccess(newstate2) else mergeErrors(
         newstate, newstate2)
Beispiel #5
0
 def processor(state):
     errors = []
     for pr in parsers:
         newstate = pr(state)
         if isParseSuccess(newstate):
             return newstate
         # fail if any input has been consumed
         if not pr.arbitraryLookAhead() and inputConsumed(newstate, state):
             return newstate
         errors.append(newstate)
     return mergeErrorsMany(*errors)
Beispiel #6
0
 def processor(state):
     errors = []
     for pr in parsers:
         newstate = pr(state)
         if isParseSuccess(newstate):
             return newstate
         # fail if any input has been consumed
         if not pr.arbitraryLookAhead() and inputConsumed(newstate, state):
             return newstate
         errors.append(newstate)
     return mergeErrorsMany(*errors)