22.1.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit bebd3fa3 authored by eckhart's avatar eckhart

ebnf.py: added a fast-path ebnf-Parser if less flexibility regarding the variants

of EBNF-syntax is acceptable.
parent b00c2671
...@@ -674,13 +674,13 @@ def get_ebnf_grammar() -> EBNFGrammar: ...@@ -674,13 +674,13 @@ def get_ebnf_grammar() -> EBNFGrammar:
raise AttributeError raise AttributeError
except AttributeError: except AttributeError:
if mode in ('fixed', 'configurable'): if mode in ('fixed', 'configurable'):
grammar = FixedEBNFGrammar() grammar = FixedEBNFGrammar(static_analysis=False)
if mode == "fixed": if mode == "fixed":
# configure grammar once # configure grammar once
update_scanner(grammar, get_config_value('delimiter_set')) update_scanner(grammar, get_config_value('delimiter_set'))
THREAD_LOCALS.ebnf_grammar_singleton = grammar THREAD_LOCALS.ebnf_grammar_singleton = grammar
else: else:
grammar = EBNFGrammar() grammar = EBNFGrammar(static_analysis=False)
THREAD_LOCALS.ebnf_grammar_singleton = grammar THREAD_LOCALS.ebnf_grammar_singleton = grammar
if mode == 'configurable': if mode == 'configurable':
# configure grammar on each request of the grammar object # configure grammar on each request of the grammar object
......
...@@ -1121,9 +1121,11 @@ class Grammar: ...@@ -1121,9 +1121,11 @@ class Grammar:
def __init__(self, root: Parser = None, static_analysis: Optional[bool] = None) -> None: def __init__(self, root: Parser = None, static_analysis: Optional[bool] = None) -> None:
"""Constructor of class Grammar. """Constructor of class Grammar.
:param root: Overrides default root parser. By default the root parser :param root: If not None, this is goind to be the root parser of the grammar.
is the parser assigned to the class field `root__`. This is useful for This allows to first construct an ensemble of parser objects and then
executing or testing certain parts of a complex parser ensemble. 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 :param static_analysis: If not None, this overrides the config value
"static_analysis". "static_analysis".
""" """
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment