Commit 8a420675 authored by eckhart's avatar eckhart
Browse files

- added a few remarks to the source code

parent 522259cb
...@@ -109,7 +109,7 @@ def add_parser_guard(parser_func): ...@@ -109,7 +109,7 @@ def add_parser_guard(parser_func):
# if location has already been visited by the current parser, # if location has already been visited by the current parser,
# return saved result # return saved result
if location in parser.visited: if location in parser.visited:
# no history recording in case of meomized results # no history recording in case of memoized results
return parser.visited[location] return parser.visited[location]
if grammar.history_tracking__: if grammar.history_tracking__:
...@@ -123,7 +123,7 @@ def add_parser_guard(parser_func): ...@@ -123,7 +123,7 @@ def add_parser_guard(parser_func):
return None, text return None, text
parser.recursion_counter[location] += 1 parser.recursion_counter[location] += 1
# run original __call__ method # PARSER CALL: run original __call__ method
node, rest = parser_func(parser, text) node, rest = parser_func(parser, text)
if grammar.left_recursion_handling__: if grammar.left_recursion_handling__:
...@@ -151,9 +151,11 @@ def add_parser_guard(parser_func): ...@@ -151,9 +151,11 @@ def add_parser_guard(parser_func):
# because caching would interfere with changes of variable state # because caching would interfere with changes of variable state
# - in case of left recursion, the first recursive step that # - in case of left recursion, the first recursive step that
# matches will store its result in the cache # 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) 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__: if grammar.history_tracking__:
# don't track returning parsers except in case an error has occurred # don't track returning parsers except in case an error has occurred
# remaining = len(rest) # remaining = len(rest)
......
...@@ -206,6 +206,8 @@ class Node(collections.abc.Sized): ...@@ -206,6 +206,8 @@ class Node(collections.abc.Sized):
""" """
Represents a node in the concrete or abstract syntax tree. Represents a node in the concrete or abstract syntax tree.
TODO: Add some documentation and doc-tests here...
Attributes: Attributes:
tag_name (str): The name of the node, which is either its 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 parser's name or, if that is empty, the parser's class name
......
...@@ -237,13 +237,11 @@ class LaTeXGrammar(Grammar): ...@@ -237,13 +237,11 @@ class LaTeXGrammar(Grammar):
paragraph = Forward() paragraph = Forward()
tabular_config = Forward() tabular_config = Forward()
text_element = Forward() text_element = Forward()
source_hash__ = "1329c620430169c2cbeff23b05e049c3" source_hash__ = "840c0f34c77bbbe0433e7691fe68f884"
parser_initialization__ = "upon instantiation" parser_initialization__ = "upon instantiation"
COMMENT__ = r'%.*' COMMENT__ = r'%.*'
WHITESPACE__ = r'[ \t]*(?:\n(?![ \t]*\n)[ \t]*)?' WHITESPACE__ = r'[ \t]*(?:\n(?![ \t]*\n)[ \t]*)?'
WSP_RE__ = mixin_comment(whitespace=WHITESPACE__, comment=COMMENT__) WSP_RE__ = mixin_comment(whitespace=WHITESPACE__, comment=COMMENT__)
wspL__ = ''
wspR__ = WSP_RE__
wsp__ = Whitespace(WSP_RE__) wsp__ = Whitespace(WSP_RE__)
EOF = RegExp('(?!.)') EOF = RegExp('(?!.)')
BACKSLASH = RegExp('[\\\\]') BACKSLASH = RegExp('[\\\\]')
......
...@@ -277,13 +277,11 @@ class XMLGrammar(Grammar): ...@@ -277,13 +277,11 @@ class XMLGrammar(Grammar):
extSubsetDecl = Forward() extSubsetDecl = Forward()
ignoreSectContents = Forward() ignoreSectContents = Forward()
markupdecl = Forward() markupdecl = Forward()
source_hash__ = "8bfb22526aa4f9b2b66e9aba5ffccf06" source_hash__ = "205ce13682b5d466a39069a1c1c6108b"
parser_initialization__ = "upon instantiation" parser_initialization__ = "upon instantiation"
COMMENT__ = r'' COMMENT__ = r''
WHITESPACE__ = r'\s*' WHITESPACE__ = r'\s*'
WSP_RE__ = mixin_comment(whitespace=WHITESPACE__, comment=COMMENT__) WSP_RE__ = mixin_comment(whitespace=WHITESPACE__, comment=COMMENT__)
wspL__ = ''
wspR__ = ''
wsp__ = Whitespace(WSP_RE__) wsp__ = Whitespace(WSP_RE__)
EOF = NegativeLookahead(RegExp('.')) EOF = NegativeLookahead(RegExp('.'))
S = RegExp('\\s+') S = RegExp('\\s+')
......
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