Exemple #1
0
 def processor(state):
     newstate = parser(state)
     if isParseSuccess(newstate):
         tree = parseSuccessTree(newstate)
         return setParseSuccessTree(newstate, transform(tree))
     else:
         return newstate
Exemple #2
0
 def processor(state):
     newstate = parser(state)
     if isParseSuccess(newstate):
         tree = parseSuccessTree(newstate)
         return setParseSuccessTree(newstate, transform(tree))
     else:
         return newstate
Exemple #3
0
 def processor(state):
     tree = []
     for pr in parsers:
         state = pr(state)
         if isParseError(state):
             return state
         tree.append(parseSuccessTree(state))
     return setParseSuccessTree(state, tree)
Exemple #4
0
 def processor(state):
     tree = []
     for pr in parsers:
         state = pr(state)
         if isParseError(state):
             return state
         tree.append(parseSuccessTree(state))
     return setParseSuccessTree(state, tree)
Exemple #5
0
 def processor(state):
     state = self(state)
     if isParseError(state):
         return state
     newstate = other(state)
     if isParseError(newstate):
         return newstate
     return setParseSuccessTree(newstate, filter(lambda x: x is not None,
                                                 [parseSuccessTree(state), parseSuccessTree(newstate)]))  # filter out 'skipped' input
Exemple #6
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
Exemple #7
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
Exemple #8
0
 def processor(state):
     state = self(state)
     if isParseError(state):
         return state
     newstate = other(state)
     if isParseError(newstate):
         return newstate
     return setParseSuccessTree(
         newstate,
         filter(lambda x: x is not None,
                [parseSuccessTree(state),
                 parseSuccessTree(newstate)
                 ]))  # filter out 'skipped' input
Exemple #9
0
 def processor(state):
     return setParseSuccessTree(state, tree)
Exemple #10
0
 def processor(state):
     return setParseSuccessTree(state, tree)
Exemple #11
0
 def processor(state):
     newstate = many(parser)(state)
     if isParseSuccess(newstate):
         newstate = setParseSuccessTree(newstate, None)
     return newstate
Exemple #12
0
 def processor(state):
     newstate = many(parser)(state)
     if isParseSuccess(newstate):
         newstate = setParseSuccessTree(newstate, None)
     return newstate