Add support for third-party regex module

Fixes #26.
This commit is contained in:
Akuli
2019-02-17 22:55:49 +02:00
parent 90a5484ea6
commit 0083477f01
4 changed files with 63 additions and 4 deletions

View File

@@ -385,6 +385,25 @@ might be useful if the parser wants to see error tokens for some
reason--perhaps for the purposes of improved error messages or
some other kind of error handling.
Third-Party Regex Module
^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 0.4
The third-party `regex <https://pypi.org/project/regex/>`_ module can be used
with sly. Like this::
from sly import Lexer
import regex
class MyLexer(Lexer):
regex_module = regex
...
Now all regular expressions that ``MyLexer`` uses will be handled with the
``regex`` module. The ``regex_module`` can be set to any module that is
compatible with Python's standard library ``re``.
A More Complete Example
^^^^^^^^^^^^^^^^^^^^^^^