changeset 21:4761135ff5f7 draft

Add error method to ParseState
author Lewin Bormann <lbo@spheniscida.de>
date Mon, 20 May 2019 22:50:57 +0200
parents 91026ea6211d
children 9fe660fc8efe
files pcombinators/combinators.py pcombinators/primitives.py
diffstat 2 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pcombinators/combinators.py	Mon May 20 22:44:58 2019 +0200
+++ b/pcombinators/combinators.py	Mon May 20 22:50:57 2019 +0200
@@ -63,6 +63,12 @@
             return ''
         return self._input[self._index:]
 
+    class ParseException(Exception):
+        pass
+
+    def error(self, msg):
+        raise ParseException(msg)
+
 class Parser:
     """Super class for all parsers. Implements operator overloading for easier
     chaining of parsers."""
--- a/pcombinators/primitives.py	Mon May 20 22:44:58 2019 +0200
+++ b/pcombinators/primitives.py	Mon May 20 22:50:57 2019 +0200
@@ -56,7 +56,6 @@
         else:
             return None, st
 
-
 class Regex(Parser):
     """Parse a string using a regular expression. The result is either the
     string or a tuple with all matched groups. Result is string."""