Implemented interpreter, almost fully documented

This commit is contained in:
hellerve
2015-07-08 16:38:49 +02:00
parent a96a5fe1f7
commit 9d4406907a
6 changed files with 137 additions and 22 deletions

View File

@@ -91,7 +91,7 @@ class Reserved(Parser):
returns -- a Result object | None
"""
if pos < len(tokens) and tokens[pos] == [self.value, self.tag]:
if pos < len(tokens) and tokens[pos][0] == self.value and tokens[pos][1] is self.tag:
return Result(tokens[pos][0], pos + 1)
else:
return None
@@ -170,7 +170,7 @@ class Alternate(Parser):
def __call__(self, tokens, pos):
"""
Calls the parser. Returns a result if either
parser matches, otherwisu returns None.
parser matches, otherwise returns None.
tokens -- the token list
pos -- the position to check