Notice: If you are member of any public project or group, please make sure that your GitLab username is not the same as the LRZ identifier/Kennung (see https://gitlab.lrz.de/profile/account). Please change your username if necessary. For more information see the section "Public projects / Öffentliche Projekte" at https://doku.lrz.de/display/PUBLIC/GitLab . Thank you!

Commit c29315c8 authored by di68kap's avatar di68kap

- Ergänzungen der Syntax für Bedeutungsangaben

parent afda6166
......@@ -77,7 +77,7 @@ JSON_Type = Union[Dict, Sequence, str, int, None]
RE_IS_JSONRPC = b'\s*{' # b'\s*(?:{|\[|"|\d|true|false|null)'
RE_GREP_URL = b'GET ([^ \n]+) HTTP'
RE_FUNCTION_CALL = b'\s*(\w+)\(([^)\n]*)\)'
RE_FUNCTION_CALL = b'\s*(\w+)\(([^)]*)\)$'
SERVER_ERROR = "COMPILER-SERVER-ERROR"
......
......@@ -249,6 +249,8 @@ def isgenerictype(t):
#
#######################################################################
RX_FILEPATH = re.compile(r'[^ \t][^\n\t?*]+(?<![ \t])') # r'[\w/:. \\]+'
def load_if_file(text_or_file) -> str:
"""
......@@ -264,7 +266,7 @@ def load_if_file(text_or_file) -> str:
content = f.read()
return content
except FileNotFoundError:
if re.fullmatch(r'[\w/:. \\]+', text_or_file):
if RX_FILEPATH.fullmatch(text_or_file):
raise FileNotFoundError('Not a valid file: ' + text_or_file + '!\n(Add "\\n" '
'to distinguish source data from a file name.)')
else:
......
......@@ -185,7 +185,7 @@ class TestParserNameOverwriteBug:
assert not has_errors(messages), str(messages)
def test_single_mandatory_bug(self):
lang = """series = § /B/"""
lang = """series = § /B/\n"""
result, messages, ast = compile_ebnf(lang)
assert result.find('Required') < 0
parser = grammar_provider(lang)()
......@@ -415,8 +415,8 @@ class TestFlowControlOperators:
"""Tests whether failures to comply with the required operator '§'
are correctly reported as such.
"""
lang1 = r"nonsense == /\w+/~ # wrong_equal_sign"
lang2 = "nonsense = [^{}%]+ # someone forgot the '/'-delimiters for regular expressions"
lang1 = r"nonsense == /\w+/~ # wrong_equal_sign "
lang2 = "nonsense = [^{}%]+ # someone forgot the '/'-delimiters for regular expressions\n"
try:
parser_class = grammar_provider(lang1)
assert False, "Compilation error expected."
......
......@@ -662,7 +662,7 @@ class TestErrorReporting:
class TestBorderlineCases:
def test_not_matching(self):
minilang = """parser = /X/"""
minilang = """parser = /X/\n"""
gr = grammar_provider(minilang)()
cst = gr('X', 'parser')
assert not cst.error_flag
......
......@@ -38,7 +38,7 @@ class TestLoggingAndLoading:
self.filename = os.path.join("test", self.tmpname, "test.py") if os.path.isdir('test') \
else os.path.join(self.tmpname, "test.py")
self.dirname = os.path.dirname(self.filename)
self.code1 = "x = 46"
self.code1 = "x = 46\n"
self.code2 = "def f():\n return 46"
if not os.path.exists(self.dirname):
os.mkdir(self.dirname)
......
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