Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
badw-it
DHParser
Commits
f1605c5c
Commit
f1605c5c
authored
Jun 08, 2017
by
di68kap
Browse files
- Tutorial: Lyrik.ebnf fnished (not yet tested)
parent
62c4cfe2
Changes
10
Hide whitespace changes
Inline
Side-by-side
DHParser/dsl.py
View file @
f1605c5c
...
...
@@ -100,11 +100,11 @@ def compile_src(source):
if __name__ == "__main__":
if len(sys.argv) > 1:
result, errors, ast = compile_
{NAME}
(sys.argv[1])
result, errors, ast = compile_
src
(sys.argv[1])
if errors:
for error in errors:
print(error)
sys.exit(1)
sys.exit(1)
else:
print(result)
else:
...
...
DHParser/parsers.py
View file @
f1605c5c
...
...
@@ -743,7 +743,7 @@ class OneOrMore(UnaryOperator):
if
not
node
:
break
if
len
(
text_
)
==
n
:
node
.
add_error
(
dsl_error_msg
(
self
,
'Infinite Loop dtected.'
))
node
.
add_error
(
dsl_error_msg
(
self
,
'Infinite Loop d
e
tected.'
))
results
+=
(
node
,)
if
results
==
():
return
None
,
text
...
...
DHParser/syntaxtree.py
View file @
f1605c5c
...
...
@@ -645,7 +645,7 @@ def map_content(node, func):
########################################################################
#
#
syntax tree
validation functions
#
AST semantic
validation functions
# EXPERIMENTAL!
#
########################################################################
...
...
DHParser/testing.py
View file @
f1605c5c
...
...
@@ -87,7 +87,7 @@ def mock_syntax_tree(sexpr):
return
Node
(
MockParser
(
name
,
':'
+
class_name
),
result
)
def
recompile_grammar
(
ebnf_filename
,
query_remove_error_files
=
True
):
def
recompile_grammar
(
ebnf_filename
):
"""Recompiles an ebnf-grammar if necessary, that is if either no
corresponding 'XXXXCompiler.py'-file exists or if that file is
outdated.
...
...
@@ -120,10 +120,10 @@ def recompile_grammar(ebnf_filename, query_remove_error_files=True):
if
not
errors
:
if
os
.
path
.
exists
(
base
+
'_errors.txt'
):
if
query_remove_error_files
:
answer
=
input
(
'Remove obsolete file '
+
base
+
'_errors.txt (y/n)? '
).
lower
()
if
answer
not
in
{
'y'
,
'yes'
}:
return
#
if query_remove_error_files:
#
answer = input('Remove obsolete file ' + base + '_errors.txt (y/n)? ').lower()
#
if answer not in {'y', 'yes'}:
#
return
os
.
remove
(
base
+
'_errors.txt'
)
...
...
examples/MLW/grammar_tests/test_grammatikposition.ini
0 → 100644
View file @
f1605c5c
[match:lemma]
1:
facitergula
2:
facitergul|a
3:
fasc|itergula
[fail:lemma]
99:
duo
vocabula
[match:HauptLemma]
1:
facitergula
2:
*fascitergula
3:
*
fasciterugl|a
[match:LemmaVarianten]
1:
fasc-itergula
fac-iet-ergula
fac-ist-ergula
fa-rcu-tergula
2:
"
fasc-itergula"
3:
"
fasc-itergula
fac-iet-ergula
ZUSATZ
sim."
[fail:LemmaVarianten]
99:
*
fascitergula
[match:LemmaPosition]
1:
LEMMA
facitergul|a
fasc-itergula
fac-iet-ergula
fac-ist-ergula
fascite-rcu-la
ZUSATZ
sim.
examples/MLW/samples/fascitergula.mlw
View file @
f1605c5c
...
...
@@ -9,7 +9,7 @@ LEMMA facitergul|a
GRAMMATIK
nomen; -ae f.
;
nomen; -ae f.
-us, -i m.: verweis_ziel_001
-um, -i n.: verweis_ziel_002
...
...
@@ -27,15 +27,15 @@ LAT pannus, faciale, sudarium
DEU Gesichts-, Schweißtuch [usu liturg.; de re v. p. 32, 63]
BELEGE
* Catal. thes. Germ. 28,11 (post 851) -um III.
* Form. Sangall. 39 p. 421,16 "munuscula ... direximus, hoc est palliolum ... ,
* Catal.
:
thes. Germ.
;
28,11 (post 851)
"
-um III.
"
* Form.
:
Sangall.
;
39 p. 421,16 "munuscula ... direximus, hoc est palliolum ... ,
-as duas."
* Catal. thes. Germ. 18,7 "-eterculi viginti quatuor".
* Libri confrat. I app. A 6 p. 137,30 "pulpitum ... -a cocco imaginata
* Catal.
:
thes. Germ.
;
18,7 "-eterculi viginti quatuor".
* Libri
:
confrat. I
;
app. A 6 p. 137,30 "pulpitum ... -a cocco imaginata
circumdari iussit pontifex."
* Catal. thes. Germ. 76,15 -rulae II. 40,5 VI vizregule. 129a,5 -sterculas
II. 24,8 -itella X. 114,8 VIII fezdregle. 6,24 fasciutercule
VII. 92,6 fascercule tres. 21,20 IIII festregele.
* Catal.
:
thes. Germ.
;
76,15
"
-rulae II.
";
40,5 VI
"
vizregule.
";
129a,5
"
-sterculas
II.
";
24,8
"
-itella X.
";
114,8 VIII
"
fezdregle.
";
6,24
"
fasciutercule
VII.
";
92,6
"
fascercule tres.
"
21,20 IIII
"
festregele.
"
ZUSATZ saepe.
BEDEUTUNG
...
...
@@ -44,8 +44,8 @@ LAT capital, rica
DEU Kopftuch
BELEGE
* Transl. Libor. I 32 raptis feminarum -is (fa[s]citergiis var. l.).
* II
20 nuditatem membrorum illius (puellae) tegere festinarunt fideles
clerici et laici inprimis cum eorum -cula, dein vestibus solitis.
* Transl.
:
Libor. I
;
32
"
raptis feminarum -is (fa[s]citergiis var. l.).
"
*
Transl.: Libor.
II
;
20
"
nuditatem membrorum illius (puellae) tegere festinarunt fideles
clerici et laici inprimis cum eorum -cula, dein vestibus solitis.
"
AUTORIN Weber
examples/Tutorial/Lyrik.ebnf
0 → 100644
View file @
f1605c5c
gedicht = bibliographisches {LZ}+ [serie] §titel §text
bibliographisches = autor §"," [ZSP] werk §"," [ZSP] ort §"," [ZSP] jahr §"."
autor = namenfolge [verknüpfung]
werk = wortfolge ["." §untertitel] [verknüpfung]
untertitel = wortfolge [verknüpfung]
ort = wortfolge [verknüpfung]
jahr = JAHRESZAHL
serie = !(titel vers ZSP vers) { [ZSP] zeile }+ {LZ}+
titel = zeile
zeile = [LEER] { ZEICHENFOLGE }+
text = { strophe }+
strophe = {LZ+} { [ZSP] vers }+
vers = [LEER] { ZEICHENFOLGE }+
wortfolge = { WORT }+
namenfolge = { NAME }+
verknüpfung = "<" ziel ">"
ziel = ZEICHENFOLGE
WORT = /\w+/~
NAME = /\w+\.?/~
ZEICHENFOLGE = /[^ \n<>]+/~
LEER = /[ \t]+/
ZSP = /\n/~
LZ = /\n[ \t]*\n/~
JAHRESZAHL = /\d\d\d\d/~
ENDE = !/./
examples/Tutorial/Lyrisches_Intermezzo_IV.txt
0 → 100644
View file @
f1605c5c
Heinrich Heine <gnd:118548018>,
Buch der Lieder <urn:nbn:de:kobv:b4-200905192211>,
Hamburg <gnd:4023118-5>, 1927.
Lyrisches Intermezzo
IV.
Wenn ich in deine Augen seh',
so schwindet all' mein Leid und Weh!
Doch wenn ich küsse deinen Mund,
so werd' ich ganz und gar gesund.
Wenn ich mich lehn' an deine Brust,
kommt's über mich wie Himmelslust,
doch wenn du sprichst: Ich liebe dich!
so muß ich weinen bitterlich.
examples/Tutorial/Lyrisches_Intermezzo_IV.xml
0 → 100644
View file @
f1605c5c
<?xml version="1.0" encoding="UTF-8" ?>
<gedicht>
<bibliographisches>
<autor
gnd=
"118548018"
>
Heinrich Heine
</autor>
<werk
href=
"http://www.deutschestextarchiv.de/book/show/heine_lieder_1827"
urn=
"nbn:de:kobv:b4-200905192211"
>
Buch der Lieder
</werk>
<ort
gnd=
"4023118-5"
>
Hamburg
</ort>
<jahr>
1927
</jahr>
<serie>
Lyrisches Intermezzo
</serie>
<titel>
IV.
</titel>
</bibliographisches>
<text>
<strophe>
<vers>
Wenn ich in deine Augen seh',
</vers>
<vers>
so schwindet all' mein Leid und Weh!
</vers>
<vers>
Doch wenn ich küsse deinen Mund,
</vers>
<vers>
so werd' ich ganz und gar gesund.
</vers>
</strophe>
<strophe>
<vers>
Wenn ich mich lehn' an deine Brust,
</vers>
<vers>
kommt's über mich wie Himmelslust,
</vers>
<vers>
doch wenn du sprichst: Ich liebe dich!
</vers>
<vers>
so muß ich weinen bitterlich.
</vers>
</strophe>
</text>
</gedicht>
examples/Tutorial/recompile_grammar.py
0 → 100644
View file @
f1605c5c
#!/usr/bin/python3
"""recompile_grammar.py - recompiles any .ebnf files in the current
directory if necessary
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.
"""
import
sys
sys
.
path
.
extend
([
'../../'
,
'../'
,
'./'
])
from
DHParser.testing
import
recompile_grammar
recompile_grammar
(
'.'
)
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