diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-11-24 22:13:00 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-11-24 22:15:35 +0000 |
| commit | c8516d0a4e9467d4313af4ba63196bca184812b3 (patch) | |
| tree | dd6235081faf3e3fba7ddda3535d6c48654fb781 /mammoth/style_reader/__init__.py | |
| parent | 507700470b46329ea8b1f8191e48fa69a24a8deb (diff) | |
Use recursive descent parser instead of parsimonious
Diffstat (limited to 'mammoth/style_reader/__init__.py')
| -rw-r--r-- | mammoth/style_reader/__init__.py | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/mammoth/style_reader/__init__.py b/mammoth/style_reader/__init__.py deleted file mode 100644 index aca07df..0000000 --- a/mammoth/style_reader/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -from parsimonious.grammar import Grammar -from parsimonious.exceptions import ParseError - -from .html_path_reader import read_html_path, grammar_text as html_path_grammar, read_html_path_node -from .document_matcher_reader import read_document_matcher, grammar_text as document_matcher_grammar, read_document_matcher_node -from ..styles import Style -from .. import results - - -__all__ = ["read_style", "read_html_path", "read_document_matcher"] - - -def read_style(string): - try: - style_node = _grammar.parse(string) - except ParseError: - warning = "Did not understand this style mapping, so ignored it: " + string - return results.Result(None, [results.warning(warning)]) - - return results.success(_read_style_node(style_node)) - - -def _read_style_node(style_node): - document_matcher_node = style_node.children[0] - html_path_node = style_node.children[4] - - document_matcher = read_document_matcher_node(document_matcher_node) - html_path = read_html_path_node(html_path_node) - - return Style(document_matcher, html_path) - - - -_grammar = Grammar(""" -style = document_matcher whitespace "=>" whitespace html_path -""" + html_path_grammar + document_matcher_grammar -) |
