Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
badw-it
DHParser
Commits
16a25786
Commit
16a25786
authored
Jul 07, 2021
by
Eckhart Arnold
Browse files
parser.py, ebnf.py: Allow Parsers for resume-skipping (refactorings pending)
parent
3eefd06d
Changes
12
Hide whitespace changes
Inline
Side-by-side
scratch/key_value_example.py
0 → 100755
View file @
16a25786
#!/usr/bin/env python
# A mini-DSL for a key value store
from
DHParser
import
create_parser
# specify the grammar of your DSL in EBNF-notation
grammar
=
'''@ drop = whitespace, strings
key_store = ~ { entry }
entry = key "=" ~ value
key = /\w+/~ # Scannerless parsing: Use regular
value = /
\"
[^"
\n
]*
\"
/~ # expressions wherever you like'''
# generating a parser is almost as simple as compiling a regular expression
# parser = create_parser(grammar) # parser factory for thread-safety
parser
=
create_parser
(
grammar
)
text
=
'''
title = "Odysee 2001"
director = "Stanley Kubrick"
'''
if
__name__
==
"__main__"
:
result
=
parser
(
text
)
assert
not
result
.
errors
,
str
(
result
.
as_sxpr
())
build_cython-modules.bat
→
scratch/outdated/
build_cython-modules.bat
View file @
16a25786
File moved
build_cython-modules.sh
→
scratch/outdated/
build_cython-modules.sh
View file @
16a25786
File moved
buildpackages.bat
→
scratch/outdated/
buildpackages.bat
View file @
16a25786
File moved
buildpackages.sh
→
scratch/outdated/
buildpackages.sh
View file @
16a25786
File moved
cythonize_stringview.bat
→
scratch/outdated/
cythonize_stringview.bat
View file @
16a25786
File moved
cythonize_stringview.sh
→
scratch/outdated/
cythonize_stringview.sh
View file @
16a25786
File moved
setup.py
→
scratch/outdated/
setup.py
View file @
16a25786
...
...
@@ -22,7 +22,7 @@ cythonize_modules = [
'DHParser/ebnf.py'
,
]
with
open
(
'README.md'
,
encoding
=
'utf-8'
)
as
f
:
with
open
(
'
../../
README.md'
,
encoding
=
'utf-8'
)
as
f
:
read_me
=
f
.
read
()
setuptools
.
setup
(
...
...
setup_stringview.py
→
scratch/outdated/
setup_stringview.py
View file @
16a25786
...
...
@@ -24,7 +24,7 @@ cythonize_modules = [
# 'DHParser/ebnf.py',
]
with
open
(
'README.md'
,
encoding
=
'utf-8'
)
as
f
:
with
open
(
'
../../
README.md'
,
encoding
=
'utf-8'
)
as
f
:
read_me
=
f
.
read
()
setuptools
.
setup
(
...
...
upload.sh
→
scratch/outdated/
upload.sh
View file @
16a25786
File moved
upload_test.sh
→
scratch/outdated/
upload_test.sh
View file @
16a25786
File moved
tests/test_toolkit.py
View file @
16a25786
...
...
@@ -38,8 +38,8 @@ from DHParser.log import log_dir, start_logging, is_logging, suspend_logging, re
class
TestLoggingAndLoading
:
def
setup
(
self
):
self
.
tmpname
=
'tmp_'
+
concurrent_ident
()
self
.
filename
=
os
.
path
.
join
(
"test"
,
self
.
tmpname
,
"
test
.py"
)
if
os
.
path
.
isdir
(
'test'
)
\
else
os
.
path
.
join
(
self
.
tmpname
,
"
test
.py"
)
self
.
filename
=
os
.
path
.
join
(
"test"
,
self
.
tmpname
,
"
key_value_example
.py"
)
if
os
.
path
.
isdir
(
'test'
)
\
else
os
.
path
.
join
(
self
.
tmpname
,
"
key_value_example
.py"
)
self
.
dirname
=
os
.
path
.
dirname
(
self
.
filename
)
self
.
code1
=
"x = 46
\n
"
self
.
code2
=
"def f():
\n
return 46"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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