Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
DHParser
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
badw-it
DHParser
Commits
7cba2407
Commit
7cba2407
authored
Jul 08, 2017
by
Eckhart Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/LaTeX extended
parent
a5ef6415
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
8 deletions
+48
-8
DHParser/parsers.py
DHParser/parsers.py
+1
-0
dhparser.py
dhparser.py
+1
-1
examples/LaTeX/LaTeX.ebnf
examples/LaTeX/LaTeX.ebnf
+46
-7
No files found.
DHParser/parsers.py
View file @
7cba2407
...
...
@@ -206,6 +206,7 @@ def add_parser_guard(parser_func):
node
,
rest
=
parser
.
visited
.
get
(
location
,
(
None
,
rest
))
# 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!
# TODO: Bei Gelegenheit messen, ob sich das hier überhaupt lohnt...
if
node
is
None
and
not
grammar
.
left_recursion_encountered__
:
# ortherwise also cache None-results
parser
.
visited
[
location
]
=
None
,
rest
...
...
dhparser.py
View file @
7cba2407
...
...
@@ -52,7 +52,7 @@ def selftest(file_name):
else
:
# compile the grammar again using the result of the previous
# compilation as parser
for
i
in
range
(
1
000
):
for
i
in
range
(
1
):
result
=
compileDSL
(
grammar
,
nil_scanner
,
result
,
transformer
,
compiler
)
print
(
result
)
return
result
...
...
examples/LaTeX/LaTeX.ebnf
View file @
7cba2407
...
...
@@ -7,22 +7,61 @@
latexdoc = preamble document
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
parblock = /{/ sequence §/}/
parblock = "{" sequence §"}"
sequence = { (paragraph | itemize | enumeration | figure | table | blockenv ) [PARSEP] }+
sequence = { paragraph [PARSEP]
}+
paragraph = { !blockcmd (command | block | text) //~ }+
paragraph = { !blockcmd textelements //~
}+
textelemts = command | text | block | inlinemath | inlineenv
inlineenv = beginenv {
command | block | text
}+ endenv
inlineenv = beginenv {
textelements
}+ endenv
beginenv = "\begin{" §NAME §"}"
endenv = "\end{" §::NAME §"}"
command = CMDNAME [[ //~ config ] //~ block ]
command = specialcmd | plaincmd
specialcmd = "\footnote" parblock
plaincmd = CMDNAME [[ //~ config ] //~ block ]
config = "[" cfgtext §"]"
block = /{/ {
command | text | block
} §/}/
block = /{/ {
textelements
} §/}/
text = { cfgtext | (BRACKETS //~) }+
cfgtext = { word_sequence | (ESCAPED //~) }+
...
...
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