The name of the initial branch for new projects is now "main" instead of "master". Existing projects remain unchanged. More information: https://doku.lrz.de/display/PUBLIC/GitLab

Commit 7cba2407 authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

examples/LaTeX extended

parent a5ef6415
...@@ -206,6 +206,7 @@ def add_parser_guard(parser_func): ...@@ -206,6 +206,7 @@ def add_parser_guard(parser_func):
node, rest = parser.visited.get(location, (None, rest)) node, rest = parser.visited.get(location, (None, rest))
# don't overwrite any positive match (i.e. node not None) in the cache # don't overwrite any positive match (i.e. node not None) in the cache
# and don't add empty entries for parsers returning from left recursive calls! # and don't add empty entries for parsers returning from left recursive calls!
# TODO: Bei Gelegenheit messen, ob sich das hier überhaupt lohnt...
if node is None and not grammar.left_recursion_encountered__: if node is None and not grammar.left_recursion_encountered__:
# ortherwise also cache None-results # ortherwise also cache None-results
parser.visited[location] = None, rest parser.visited[location] = None, rest
......
...@@ -52,7 +52,7 @@ def selftest(file_name): ...@@ -52,7 +52,7 @@ def selftest(file_name):
else: else:
# compile the grammar again using the result of the previous # compile the grammar again using the result of the previous
# compilation as parser # compilation as parser
for i in range(1000): for i in range(1):
result = compileDSL(grammar, nil_scanner, result, transformer, compiler) result = compileDSL(grammar, nil_scanner, result, transformer, compiler)
print(result) print(result)
return result return result
......
...@@ -7,22 +7,61 @@ ...@@ -7,22 +7,61 @@
latexdoc = preamble document latexdoc = preamble document
preamble = { command }+ preamble = { command }+
document = [PARSEP] { [PARSEP] paragraph } §EOF document = [PARSEP] "\begin{document}" [PARSEP] frontpages [PARSEP] (chapters | sections)
[bibliography] [index] "\end{document}" §EOF
frontpages = sequence
#######################################################################
#
# document structure
#
#######################################################################
Chapters = { Chapter [PARSEP] }+
Chapter = "\Chapter" block [PARSEP] { sequence | Sections }
Sections = { Section [PARSEP] }+
Section = "\Section" block [PARSEP] { sequence | SubSections }
SubSections = { SubSection [PARSEP] }+
SubSection = "\SubSection" block [PARSEP] { sequence | SubSubSections }
SubSubsections = { SubSubSection [PARSEP] }+
SubSubSection = "\SubSubSection" block [PARSEP] { sequence | Paragraphs }
Paragraphs = { Paragraph [PARSEP] }+
Paragraph = "\paragraph" block [PARSEP] { sequence | SubParagraphs }
SubParagraphs = { SubParagraph [PARSEP] }+
SubParagraph = "\subparagpaph" block [PARSEP] { sequence }
bibliography = "\bibliography" block [PARSEP]
index = "\printindex" [PARSEP
#######################################################################
#
# document content
#
#######################################################################
blockenv = beginenv sequence §endenv blockenv = beginenv sequence §endenv
parblock = /{/ sequence §/}/
parblock = "{" sequence §"}" sequence = { (paragraph | itemize | enumeration | figure | table | blockenv ) [PARSEP] }+
sequence = { paragraph [PARSEP] }+ paragraph = { !blockcmd textelements //~ }+
paragraph = { !blockcmd (command | block | text) //~ }+ textelemts = command | text | block | inlinemath | inlineenv
inlineenv = beginenv { command | block | text }+ endenv inlineenv = beginenv { textelements }+ endenv
beginenv = "\begin{" §NAME §"}" beginenv = "\begin{" §NAME §"}"
endenv = "\end{" §::NAME §"}" endenv = "\end{" §::NAME §"}"
command = CMDNAME [[ //~ config ] //~ block ] command = specialcmd | plaincmd
specialcmd = "\footnote" parblock
plaincmd = CMDNAME [[ //~ config ] //~ block ]
config = "[" cfgtext §"]" config = "[" cfgtext §"]"
block = /{/ { command | text | block } §/}/ block = /{/ { textelements } §/}/
text = { cfgtext | (BRACKETS //~) }+ text = { cfgtext | (BRACKETS //~) }+
cfgtext = { word_sequence | (ESCAPED //~) }+ cfgtext = { word_sequence | (ESCAPED //~) }+
......
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