Commit d79756fd authored by di68kap's avatar di68kap

- slight adjustments

parent cd1cbe44
......@@ -18,7 +18,7 @@ DHParser is open source software under the [MIT License](https://opensource.org/
Purpose
-------
Domain specific languages are widespread in computer sciences, but strangely underused in the
Domain specific languages are widespread in computer sciences, but seem to be underused in the
Digital Humanities. While DSLs are often introduced to Digital-Humanities-projects as
[practical adhoc-solution][Müller_2016], these solutions are often somewhat "quick and dirty". In other words they are
more of a hack than a technology. The purpose of DHParsers is to introduce
......@@ -26,7 +26,7 @@ more of a hack than a technology. The purpose of DHParsers is to introduce
[EBNF][ISO_IEC_14977]-based parser generators, but employs the more modern form called "[parsing expression grammar][Ford_2004]"
and [parser combinators][Ford_20XX] as a variant of the classical recursive descent parser.
Why another parser generator? There are plenty of good parser generators out there, e.g. [Añez_2017]. However, DHParser is
Why another parser generator? There are plenty of good parser generators out there, e.g. [Añez's grako parser generator][Añez_2017]. However, DHParser is
intended as a tool that is specifically geared towards digital humanities applications, while most existing parser
generators come from compiler construction toolkits for programming languages. Also, DHParser shall (in the future)
serve as a teching tool, which influences some of its design decisions such as, for example, clearly separating
......@@ -55,7 +55,7 @@ Description
... comming soon ;-)
For a simple self-test run `ParserCombinators.py` from the command line. This compiles the EBNF-Grammer in
For a simple self-test run `dhparser.py` from the command line. This compiles the EBNF-Grammer in
`examples/EBNF/EBNF.ebnf` and outputs the Python-based parser class representing that grammar. The concrete and abstract
syntax tree as well as a full and abbreviated log of the parsing process will be stored in a sub-directory named "DEBUG".
......@@ -64,19 +64,19 @@ syntax tree as well as a full and abbreviated log of the parsing process will be
References
----------
Eckhart Arnold: Domänenspezifische Notationen. Eine (noch) unterschätzte Technologie in den Digitalen Geisteswissenschaften, Präsentation auf dem
[dhmuc-Workshop: Digitale Editionen und Auszeichnungssprachen](https://dhmuc.hypotheses.org/workshop-digitale-editionen-und-auszeichnungssprachen),
München 2016.
Juancarlo Añez: grako, a PEG parser generator in Python, 2017. URL: [bitbucket.org/apalala/grako][Añez_2017]
[Arnold_2016]: https://f.hypotheses.org/wp-content/blogs.dir/1856/files/2016/12/Mueller_Anzeichnung_10_Vortrag_M%C3%BCnchen.pdf
[Añez_2017]: https://bitbucket.org/apalala/grako
Juancarlo Añez: grako, a PEG parser generator in Python, [Añez_2017]
Eckhart Arnold: Domänenspezifische Notationen. Eine (noch) unterschätzte Technologie in den Digitalen Geisteswissenschaften, Präsentation auf dem
[dhmuc-Workshop: Digitale Editionen und Auszeichnungssprachen](https://dhmuc.hypotheses.org/workshop-digitale-editionen-und-auszeichnungssprachen),
München 2016. Short-URL: [tiny.badw.de/2JVT][Arnold_2016]
[Añez_2017]: https://bitbucket.org/apalala/grako
[Arnold_2016]: https://f.hypotheses.org/wp-content/blogs.dir/1856/files/2016/12/EA_Pr%C3%A4sentation_Auszeichnungssprachen.pdf
Brian Ford: Parsing Expression Grammars: A Recognition-Based Syntactic Foundation, Cambridge Massachusetts, 2004.
Brian Ford: Parsing Expression Grammars: A Recognition-Based Syntactic Foundation, Cambridge Massachusetts, 2004. Short-URL:[http://t1p.de/jihs][Ford_2004]
[Ford_2004]: https://pdos.csail.mit.edu/~baford/packrat/popl04/peg-popl04.pdf
......@@ -91,21 +91,21 @@ Berlin Heidelberg 2008.
Dominikus Herzberg: Objekt-orientierte Parser-Kombinatoren in Python,
Blog-Post, September, 18th 2008 on denkspuren. gedanken, ideen,
anregungen und links rund um informatik-themen, URL: [Herzberg_2008a]
anregungen und links rund um informatik-themen, short-URL: [http://t1p.de/bm3k][Herzberg_2008a]
[Herzberg_2008a]: http://denkspuren.blogspot.de/2008/09/objekt-orientierte-parser-kombinatoren.html
Dominikus Herzberg: Eine einfache Grammatik für LaTeX, Blog-Post,
September, 18th 2008 on denkspuren. gedanken, ideen, anregungen und
links rund um informatik-themen, URL: [Herzberg_2008b]
links rund um informatik-themen, short-URL: [http://t1p.de/7jzh][Herzberg_2008b]
[Herzberg_2008b]: http://denkspuren.blogspot.de/2008/09/eine-einfache-grammatik-fr-latex.html
Dominikus Herzberg: Uniform Syntax, Blog-Post, February, 27th 2007 on
denkspuren. gedanken, ideen, anregungen und links rund um
informatik-themen, URL: [Herzberg_2007]
informatik-themen, short-URL: [http://t1p.de/s0zk][Herzberg_2007]
[Herzberg_2007]: http://denkspuren.blogspot.de/2007/02/uniform-syntax.html
......@@ -114,18 +114,18 @@ informatik-themen, URL: [Herzberg_2007]
John MacFarlane, David Greenspan, Vicent Marti, Neil Williams, Benjamin Dumke-von der Ehe, Jeff Atwood:
CommonMark. A strongly defined, highly compatible specification of Markdown, 2017.
CommonMark. A strongly defined, highly compatible specification of Markdown, 2017. [commonmark.org][MacFarlane_et_al_2017]
[MacFarlane_et_al_2017]: http://commonmark.org/
Stefan Müller: DSLs in den digitalen Geisteswissenschaften, Präsentation auf dem
[dhmuc-Workshop: Digitale Editionen und Auszeichnungssprachen](https://dhmuc.hypotheses.org/workshop-digitale-editionen-und-auszeichnungssprachen),
München 2016.
München 2016. Short-URL: [tiny.badw.de/2JVy][Müller_2016]
[Müller_2016]: https://f.hypotheses.org/wp-content/blogs.dir/1856/files/2016/12/Mueller_Anzeichnung_10_Vortrag_M%C3%BCnchen.pdf
[tex_stackexchange_no_bnf]: http://tex.stackexchange.com/questions/4201/is-there-a-bnf-grammar-of-the-tex-language
[tex_stackexchange_latex_parsers]: http://tex.stackexchange.com/questions/4223/what-parsers-for-latex-mathematics-exist-outside-of-the-tex-engines
\ No newline at end of file
[tex_stackexchange_latex_parsers]: http://tex.stackexchange.com/questions/4223/what-parsers-for-latex-mathematics-exist-outside-of-the-tex-engines
......@@ -22,15 +22,15 @@ limitations under the License.
import os
import sys
sys.path.append(os.path.abspath('../../../'))
import ParserCombinators
from ParserCombinators import run_compiler, source_changed
import logs
from DSLsupport import run_compiler, source_changed
MLW_ebnf = os.path.join('..', 'MLW.ebnf')
MLW_compiler = os.path.join('..', 'MLW_compiler.py')
# print(source_changed(MLW_ebnf, MLW_compiler))
ParserCombinators.DEBUG = False
logs.logging_off()
if (not os.path.exists(MLW_compiler) or
source_changed(MLW_ebnf, MLW_compiler)):
......@@ -40,7 +40,7 @@ if (not os.path.exists(MLW_compiler) or
print(errors)
sys.exit(1)
ParserCombinators.DEBUG = "DEBUG"
logs.logging_on()
errors = run_compiler("fascitergula.mlw", MLW_compiler, ".xml")
if errors:
......
......@@ -31,12 +31,24 @@ already exists.
import os
__all__ = ['LOGGING', 'LOGS_DIR']
__all__ = ['logging_on', 'logging_off', 'LOGGING', 'LOGS_DIR']
LOGGING: str = "LOGS" # LOGGING = "" turns logging off!
def logging_on(log_subdir="LOGS"):
"Turns logging of syntax trees and parser history on."
global LOGGING
LOGGING = log_subdir
def logging_off():
"Turns logging of syntax trees and parser history off."
global LOGGING
LOGGING = ""
def LOGS_DIR() -> str:
"""Returns a path of a directory where log files will be stored.
......@@ -53,7 +65,7 @@ def LOGS_DIR() -> str:
"""
global LOGGING
if not LOGGING:
raise AssertionError("Cannot use LOGGING_DIR() if logging is turned off!")
raise AssertionError("Cannot use LOGS_DIR() if logging is turned off!")
dirname = LOGGING
if os.path.exists(LOGGING):
if not os.path.isdir(LOGGING):
......
......@@ -14,8 +14,8 @@ class SelfTest:
def run_tests(tests, namespace):
""" Runs selected tests.
""" Runs only some selected tests from a test suite.
Args:
tests: Either a string or a list of strings that contains the
names of test or test classes. Each test and, in the case
......
......@@ -39,6 +39,14 @@ class DummyParser:
def from_sexpr(s):
"""Generates a tree of nodes from an S-expression.
Example:
>>> from_sexpr("(a (b c))").as_sexpr()
(a
(b
c
)
)
"""
def next_block(s):
s = s.strip()
......
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