diff --git a/src/parse.py b/src/parse.py index cdadea9..24db521 100644 --- a/src/parse.py +++ b/src/parse.py @@ -76,14 +76,14 @@ # Reads a token, possibly of a certain value -def read_token(stream, value): +def read_token(stream, value, context): s = stream.pop() if s is None: - raise ParseErrorException(ParseError.NO_TOKEN, None, None, None) + raise ParseErrorException(ParseError.NO_TOKEN, None, None, context) elif s.type != SyntaxType.TOKEN: - raise ParseErrorException(ParseError.NOT_TOKEN, s, None, None) + raise ParseErrorException(ParseError.NOT_TOKEN, s, None, context) elif value is not None and s.value != value: - raise ParseErrorException(ParseError.WRONG_TOKEN, s, value, None) + raise ParseErrorException(ParseError.WRONG_TOKEN, s, value, context) return s @@ -91,9 +91,9 @@ class NoteSkipper: # Skip a note def skip_note(self, stream): - read_token(stream, "StartNote") + read_token(stream, "StartNote", None) while True: - s = read_token(stream, None) + s = read_token(stream, None, None) # Don't allow StartNote in notes if s.value in ["StartNote"]: raise ParseErrorException(ParseError.FOUND_STARTNOTE, s, None, None) @@ -120,16 +120,16 @@ return tokens -# The recursive descent parser in a wrapper class for easy testing +# The recursive dNoneescent parser in a wrapper class for easy testing class Parser: # Parses a text syntax node def parse_text(self, stream): buffer = "" - s = read_token(stream, "StartText") + s = read_token(stream, "StartText", None) location = s.location # Parse following tokens while True: - s = read_token(stream, None) + s = read_token(stream, None, None) # Don't allow StartText in text if s.value in ["StartText"]: raise ParseErrorException(ParseError.FOUND_STARTTEXT, s, None, None) @@ -144,7 +144,7 @@ # Parses a boolean syntax node def parse_bool(self, stream): - s = read_token(stream, None) + s = read_token(stream, None, None) if s.value == "True": return Syntax(True, s.location, SyntaxType.BOOL) elif s.value == "False":