From 5bc676b074a651a70b3b259182a94120c036d74a Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 29 Nov 2016 21:54:31 +0000 Subject: Raise error on unrecognised string matcher --- mammoth/styles/parser/document_matcher_parser.py | 3 +-- mammoth/styles/parser/token_iterator.py | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'mammoth/styles/parser') diff --git a/mammoth/styles/parser/document_matcher_parser.py b/mammoth/styles/parser/document_matcher_parser.py index 0024ac8..7f117b7 100644 --- a/mammoth/styles/parser/document_matcher_parser.py +++ b/mammoth/styles/parser/document_matcher_parser.py @@ -59,8 +59,7 @@ def _parse_string_matcher(tokens): elif tokens.try_skip(TokenType.SYMBOL, "^="): return document_matchers.starts_with(parse_string(tokens)) else: - # TODO raise - pass + raise LineParseError("Unrecognised string matcher: {0}".format(tokens.next_value())) def _parse_numbering(tokens): if tokens.try_skip(TokenType.SYMBOL, ":"): diff --git a/mammoth/styles/parser/token_iterator.py b/mammoth/styles/parser/token_iterator.py index 027775b..fded56d 100644 --- a/mammoth/styles/parser/token_iterator.py +++ b/mammoth/styles/parser/token_iterator.py @@ -12,12 +12,12 @@ class TokenIterator(object): def peek_token_type(self): return self._tokens[self._index].type - def next_value(self, token_type): + def next_value(self, token_type=None): return self._next(token_type).value - def _next(self, token_type): + def _next(self, token_type=None): token = self._tokens[self._index] - if token.type == token_type: + if token_type is None or token.type == token_type: self._index += 1 return token else: -- cgit v1.2.3