Commit deb9c81c authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

- DHParser/ebnf.py EBNFCompiler.on_syntax(): static analysis right after...

- DHParser/ebnf.py EBNFCompiler.on_syntax(): static analysis right after compilation  of EBNF already.
parent 59047804
...@@ -178,6 +178,7 @@ class EBNFGrammar(Grammar): ...@@ -178,6 +178,7 @@ class EBNFGrammar(Grammar):
""" """
expression = Forward() expression = Forward()
source_hash__ = "82a7c668f86b83f86515078e6c9093ed" source_hash__ = "82a7c668f86b83f86515078e6c9093ed"
static_analysis_pending__ = False
parser_initialization__ = ["upon instantiation"] parser_initialization__ = ["upon instantiation"]
COMMENT__ = r'#.*(?:\n|$)' COMMENT__ = r'#.*(?:\n|$)'
WHITESPACE__ = r'\s*' WHITESPACE__ = r'\s*'
...@@ -926,8 +927,11 @@ class EBNFCompiler(Compiler): ...@@ -926,8 +927,11 @@ class EBNFCompiler(Compiler):
grammar_python_src = self.assemble_parser(definitions, node) grammar_python_src = self.assemble_parser(definitions, node)
if get_config_value('static_analysis') == 'early': if get_config_value('static_analysis') == 'early':
try: try:
grammar_class = compile_python_object(DHPARSER_IMPORTS + grammar_python_src, self.grammar_name) grammar_class = compile_python_object(DHPARSER_IMPORTS + grammar_python_src,
self.grammar_name)
_ = grammar_class() _ = grammar_class()
grammar_python_src = grammar_python_src.replace(
'static_analysis_pending__ = True', 'static_analysis_pending__ = False', 1)
except NameError: except NameError:
pass # undefined name in the grammar are already cuaght and reported pass # undefined name in the grammar are already cuaght and reported
except GrammarError as error: except GrammarError as error:
......
...@@ -60,7 +60,7 @@ class ArithmeticGrammar(Grammar): ...@@ -60,7 +60,7 @@ class ArithmeticGrammar(Grammar):
expression = Forward() expression = Forward()
variable = Forward() variable = Forward()
source_hash__ = "cf537b22b7a1a2a58c426f99f784285d" source_hash__ = "cf537b22b7a1a2a58c426f99f784285d"
static_analysis_pending__ = True static_analysis_pending__ = False
parser_initialization__ = ["upon instantiation"] parser_initialization__ = ["upon instantiation"]
resume_rules__ = {} resume_rules__ = {}
COMMENT__ = r'' COMMENT__ = r''
......
...@@ -58,7 +58,7 @@ class EBNFGrammar(Grammar): ...@@ -58,7 +58,7 @@ class EBNFGrammar(Grammar):
""" """
expression = Forward() expression = Forward()
source_hash__ = "7ca2bbabfc9bc19ec54e2318bbc4c9c2" source_hash__ = "7ca2bbabfc9bc19ec54e2318bbc4c9c2"
static_analysis_pending__ = True static_analysis_pending__ = False
parser_initialization__ = ["upon instantiation"] parser_initialization__ = ["upon instantiation"]
resume_rules__ = {} resume_rules__ = {}
COMMENT__ = r'#.*(?:\n|$)' COMMENT__ = r'#.*(?:\n|$)'
......
...@@ -58,7 +58,7 @@ class LaTeXGrammar(Grammar): ...@@ -58,7 +58,7 @@ class LaTeXGrammar(Grammar):
tabular_config = Forward() tabular_config = Forward()
text_element = Forward() text_element = Forward()
source_hash__ = "dacb1f9ad5b1c18cdc29c7ddb7878959" source_hash__ = "dacb1f9ad5b1c18cdc29c7ddb7878959"
static_analysis_pending__ = True static_analysis_pending__ = False
parser_initialization__ = ["upon instantiation"] parser_initialization__ = ["upon instantiation"]
resume_rules__ = {} resume_rules__ = {}
COMMENT__ = r'%.*' COMMENT__ = r'%.*'
......
...@@ -59,7 +59,7 @@ class Lyrik_explicit_whitespaceGrammar(Grammar): ...@@ -59,7 +59,7 @@ class Lyrik_explicit_whitespaceGrammar(Grammar):
r"""Parser for a Lyrik_explicit_whitespace source file. r"""Parser for a Lyrik_explicit_whitespace source file.
""" """
source_hash__ = "bcb3cee425961a2148941b492e614bd2" source_hash__ = "bcb3cee425961a2148941b492e614bd2"
static_analysis_pending__ = True static_analysis_pending__ = False
parser_initialization__ = ["upon instantiation"] parser_initialization__ = ["upon instantiation"]
resume_rules__ = {} resume_rules__ = {}
COMMENT__ = r'' COMMENT__ = r''
......
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