From bebd3fa3085e53a55d6113cfdcc136d411f40582 Mon Sep 17 00:00:00 2001 From: eckhart Date: Sun, 14 Jun 2020 19:23:21 +0200 Subject: [PATCH] ebnf.py: added a fast-path ebnf-Parser if less flexibility regarding the variants of EBNF-syntax is acceptable. --- DHParser/ebnf.py | 4 ++-- DHParser/parse.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/DHParser/ebnf.py b/DHParser/ebnf.py index 8599882..6ae47e2 100644 --- a/DHParser/ebnf.py +++ b/DHParser/ebnf.py @@ -674,13 +674,13 @@ def get_ebnf_grammar() -> EBNFGrammar: raise AttributeError except AttributeError: if mode in ('fixed', 'configurable'): - grammar = FixedEBNFGrammar() + grammar = FixedEBNFGrammar(static_analysis=False) if mode == "fixed": # configure grammar once update_scanner(grammar, get_config_value('delimiter_set')) THREAD_LOCALS.ebnf_grammar_singleton = grammar else: - grammar = EBNFGrammar() + grammar = EBNFGrammar(static_analysis=False) THREAD_LOCALS.ebnf_grammar_singleton = grammar if mode == 'configurable': # configure grammar on each request of the grammar object diff --git a/DHParser/parse.py b/DHParser/parse.py index 42f3514..5ecdd16 100644 --- a/DHParser/parse.py +++ b/DHParser/parse.py @@ -1121,9 +1121,11 @@ class Grammar: def __init__(self, root: Parser = None, static_analysis: Optional[bool] = None) -> None: """Constructor of class Grammar. - :param root: Overrides default root parser. By default the root parser - is the parser assigned to the class field `root__`. This is useful for - executing or testing certain parts of a complex parser ensemble. + :param root: If not None, this is goind to be the root parser of the grammar. + This allows to first construct an ensemble of parser objects and then + link those objects in a grammar-object, rather than adding the parsers + as fields to a derived class of class Grammar. (See the doc-tests in this + module for examples.) :param static_analysis: If not None, this overrides the config value "static_analysis". """ -- GitLab