Commit 1e0bc6d8 authored by di68kap's avatar di68kap

- compiler code gnerierung in ebnf.py und dsl.py angepasst. Noch nicht getestet

parent 48220a99
......@@ -110,7 +110,7 @@ def compile_{NAME}(source):
"""Compiles ``source`` and returns (result, errors, ast).
"""
return full_compilation(source, {NAME}Scanner,
{NAME}Grammar(), {NAME}_ASTPipeline, {NAME}Compiler())
{NAME}Grammar(), {NAME}Transform, {NAME}Compiler())
if __name__ == "__main__":
if len(sys.argv) > 1:
......
......@@ -215,14 +215,15 @@ class EBNFCompiler(CompilerBase):
if not self.definition_names:
raise EBNFCompilerError('Compiler has not been run before calling '
'"gen_AST_Skeleton()"!')
tt_name = self.grammar_name + '_ASTTransform'
pl_name = self.grammar_name + '_ASTPipeline'
tt_name = self.grammar_name + '_AST_transformation_table'
tf_name = self.grammar_name + 'Transform'
transtable = [tt_name + ' = {',
' # AST Transformations for the ' +
self.grammar_name + '-grammar']
for name in self.definition_names:
transtable.append(' "' + name + '": no_operation,')
transtable += [' "": no_operation', '}', '', pl_name + ' = [%s]' % tt_name, '']
transtable += [' "": no_operation', '}', '', tf_name +
' = partial(traverse, processing_table=%s)' % tt_name, '']
return '\n'.join(transtable)
def gen_compiler_skeleton(self):
......
#!/usr/bin/python3
"""test_dsl.py - tests of the dsl-module of DHParser
Author: Eckhart Arnold <arnold@badw.de>
Copyright 2017 Bavarian Academy of Sciences and Humanities
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
#!/usr/bin/python3
"""test_ebnf.py - tests of the EBNFcompiler-module of DHParser
"""test_ebnf.py - tests of the ebnf module of DHParser
Author: Eckhart Arnold <arnold@badw.de>
......@@ -24,7 +24,6 @@ from functools import partial
import os
import sys
sys.path.append(os.path.abspath('../../'))
from DHParser.syntaxtree import traverse
from DHParser.parsers import full_compilation, Retrieve, WHITESPACE_KEYWORD
from DHParser.ebnf import EBNFGrammar, EBNFTransform, EBNFCompiler
from DHParser.dsl import compileEBNF
......
#!/usr/bin/python3
"""test_parsers.py - tests of the parsercombinators-module
of DHParser
"""test_parsers.py - tests of the parsers-module of DHParser
Author: Eckhart Arnold <arnold@badw.de>
......
......@@ -2,7 +2,6 @@
"""test_syntaxtree.py - test of syntaxtree-module of DHParser
Author: Eckhart Arnold <arnold@badw.de>
Copyright 2017 Bavarian Academy of Sciences and Humanities
......
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