Commit 65f54dcc authored by eckhart's avatar eckhart

- DHParser/ebnf.py,parse.py: defining comments as empty regex now also possible

parent acfce849
......@@ -664,7 +664,7 @@ class EBNFCompiler(Compiler):
value = node.content.strip("~")
if value[0] + value[-1] in {'""', "''"}:
value = escape_re(value[1:-1])
elif value[0] + value[-1] == '//':
elif value[0] + value[-1] == '//' and value != '//':
value = self._check_rx(node, value[1:-1])
return value
......
......@@ -503,8 +503,9 @@ def mixin_comment(whitespace: str, comment: str) -> str:
nesting comments is not possible. It also makes it much harder to
use directives inside comments (which isn't recommended, anyway).
"""
wspc = '(?:' + whitespace + '(?:' + comment + whitespace + ')*)'
return wspc
if comment:
return '(?:' + whitespace + '(?:' + comment + whitespace + ')*)'
return whitespace
class UnknownParserError(KeyError):
......
......@@ -57,10 +57,10 @@ class BibTeXGrammar(Grammar):
r"""Parser for a BibTeX source file.
"""
text = Forward()
source_hash__ = "d9a1a1b431a3185dab127be165a37719"
source_hash__ = "4e4011722001b0019b7b980a02559de1"
parser_initialization__ = ["upon instantiation"]
resume_rules__ = {}
COMMENT__ = r'(?i)'
COMMENT__ = r'(?i)%%.*\n'
WHITESPACE__ = r'\s*'
WSP_RE__ = mixin_comment(whitespace=WHITESPACE__, comment=COMMENT__)
wsp__ = Whitespace(WSP_RE__)
......
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