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
8a420675
Commit
8a420675
authored
Jul 12, 2018
by
eckhart
Browse files
- added a few remarks to the source code
parent
522259cb
Changes
4
Hide whitespace changes
Inline
Side-by-side
DHParser/parse.py
View file @
8a420675
...
...
@@ -109,7 +109,7 @@ def add_parser_guard(parser_func):
# if location has already been visited by the current parser,
# return saved result
if
location
in
parser
.
visited
:
# no history recording in case of me
o
mized results
# no history recording in case of mem
o
ized results
return
parser
.
visited
[
location
]
if
grammar
.
history_tracking__
:
...
...
@@ -123,7 +123,7 @@ def add_parser_guard(parser_func):
return
None
,
text
parser
.
recursion_counter
[
location
]
+=
1
# run original __call__ method
#
PARSER CALL:
run original __call__ method
node
,
rest
=
parser_func
(
parser
,
text
)
if
grammar
.
left_recursion_handling__
:
...
...
@@ -151,9 +151,11 @@ def add_parser_guard(parser_func):
# because caching would interfere with changes of variable state
# - in case of left recursion, the first recursive step that
# matches will store its result in the cache
# TODO: need a test concerning interference of variable manipulation and left recursion algorithm?
parser
.
visited
[
location
]
=
(
node
,
rest
)
# Mind that meomized parser calls will not appear in the history record!
# Mind that memoized parser calls will not appear in the history record!
# Does this make sense? Or should it be changed?
if
grammar
.
history_tracking__
:
# don't track returning parsers except in case an error has occurred
# remaining = len(rest)
...
...
DHParser/syntaxtree.py
View file @
8a420675
...
...
@@ -206,6 +206,8 @@ class Node(collections.abc.Sized):
"""
Represents a node in the concrete or abstract syntax tree.
TODO: Add some documentation and doc-tests here...
Attributes:
tag_name (str): The name of the node, which is either its
parser's name or, if that is empty, the parser's class name
...
...
examples/LaTeX/LaTeXCompiler.py
View file @
8a420675
...
...
@@ -237,13 +237,11 @@ class LaTeXGrammar(Grammar):
paragraph
=
Forward
()
tabular_config
=
Forward
()
text_element
=
Forward
()
source_hash__
=
"
1329c620430169c2cbeff23b05e049c3
"
source_hash__
=
"
840c0f34c77bbbe0433e7691fe68f884
"
parser_initialization__
=
"upon instantiation"
COMMENT__
=
r
'%.*'
WHITESPACE__
=
r
'[ \t]*(?:\n(?![ \t]*\n)[ \t]*)?'
WSP_RE__
=
mixin_comment
(
whitespace
=
WHITESPACE__
,
comment
=
COMMENT__
)
wspL__
=
''
wspR__
=
WSP_RE__
wsp__
=
Whitespace
(
WSP_RE__
)
EOF
=
RegExp
(
'(?!.)'
)
BACKSLASH
=
RegExp
(
'[
\\\\
]'
)
...
...
examples/XML/XMLCompiler.py
View file @
8a420675
...
...
@@ -277,13 +277,11 @@ class XMLGrammar(Grammar):
extSubsetDecl
=
Forward
()
ignoreSectContents
=
Forward
()
markupdecl
=
Forward
()
source_hash__
=
"
8bfb22526aa4f9b2b66e9aba5ffccf06
"
source_hash__
=
"
205ce13682b5d466a39069a1c1c6108b
"
parser_initialization__
=
"upon instantiation"
COMMENT__
=
r
''
WHITESPACE__
=
r
'\s*'
WSP_RE__
=
mixin_comment
(
whitespace
=
WHITESPACE__
,
comment
=
COMMENT__
)
wspL__
=
''
wspR__
=
''
wsp__
=
Whitespace
(
WSP_RE__
)
EOF
=
NegativeLookahead
(
RegExp
(
'.'
))
S
=
RegExp
(
'
\\
s+'
)
...
...
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