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
c29315c8
Commit
c29315c8
authored
Apr 26, 2019
by
di68kap
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Ergänzungen der Syntax für Bedeutungsangaben
parent
afda6166
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
7 deletions
+9
-7
DHParser/server.py
DHParser/server.py
+1
-1
DHParser/toolkit.py
DHParser/toolkit.py
+3
-1
test/test_ebnf.py
test/test_ebnf.py
+3
-3
test/test_parse.py
test/test_parse.py
+1
-1
test/test_toolkit.py
test/test_toolkit.py
+1
-1
No files found.
DHParser/server.py
View file @
c29315c8
...
...
@@ -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"
...
...
DHParser/toolkit.py
View file @
c29315c8
...
...
@@ -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
:
...
...
test/test_ebnf.py
View file @
c29315c8
...
...
@@ -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."
...
...
test/test_parse.py
View file @
c29315c8
...
...
@@ -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
...
...
test/test_toolkit.py
View file @
c29315c8
...
...
@@ -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
)
...
...
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