Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
badw-it
DHParser
Commits
1e0bc6d8
Commit
1e0bc6d8
authored
Apr 21, 2017
by
di68kap
Browse files
- compiler code gnerierung in ebnf.py und dsl.py angepasst. Noch nicht getestet
parent
48220a99
Changes
6
Hide whitespace changes
Inline
Side-by-side
DHParser/dsl.py
View file @
1e0bc6d8
...
...
@@ -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:
...
...
DHParser/ebnf.py
View file @
1e0bc6d8
...
...
@@ -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
+
'_AST
T
ransform'
pl
_name
=
self
.
grammar_name
+
'
_ASTPipeline
'
tt_name
=
self
.
grammar_name
+
'_AST
_t
ransform
ation_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
):
...
...
tests/test_dsl.py
0 → 100644
View file @
1e0bc6d8
#!/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.
"""
tests/test_ebnf.py
View file @
1e0bc6d8
#!/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
...
...
tests/test_parsers.py
View file @
1e0bc6d8
#!/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>
...
...
tests/test_syntaxtree.py
View file @
1e0bc6d8
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment