Commits

Waldemar Kornewald committed 7f67305

added anychar rule for matching characters without using 'a' | 'b' | ... constructs

  • Participants
  • Parent commits 2b7fdd1

Comments (0)

Files changed (1)

File pymeta/runtime.py

 
     rule_letterOrDigit = letterOrDigit
 
+    def anychar(self, chars):
+        """
+        Match any of the given chars.
+        """
+        x, e = self.rule_anything()
+        if x in chars:
+            return x, e
+        else:
+            e[1] = expected("any of: %s" % chars)
+            raise _MaybeParseError(*e)
+
+    rule_anychar = anychar
+
     def digit(self):
         """
         Match a single digit.