Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
badw-it
DHParser
Commits
65b7b32c
Commit
65b7b32c
authored
Mar 17, 2021
by
eckhart
Browse files
ebnf.py: documentation extended
parent
93e08a51
Changes
2
Hide whitespace changes
Inline
Side-by-side
DHParser/ebnf.py
View file @
65b7b32c
...
...
@@ -512,7 +512,7 @@ consist of sequences of sentences which consist of sequences
of main clauses and subordinate clauses which consist of sequences
of words::
>>> text_gr = '@disposable = /_
\\\\
w+/
\\
n'
\
>>> text_gr = '@
disposable = /_
\\\\
w+/
\\
n'
\
'document = S* paragraph (PBR paragraph)* S* _EOF
\\
n'
\
' _EOF = /$/
\\
n'
\
'paragraph = sentence (S sentence)*
\\
n'
\
...
...
@@ -554,7 +554,7 @@ Two typical design patterns for significant whitespace are noteworthy, here:
(Again, for soon to be dropped insignificant whitespace, another convention
can be more advisable.)
Let's j
s
ut try our grammar on an example::
Let's ju
s
t try our grammar on an example::
>>> text_example =
\
'I want to say, in all seriousness, that a great deal of harm is being
\\
n'
\
...
...
@@ -601,11 +601,10 @@ if you receive data from a different source, you'll appreciate not having to
do this - and so will other people, receiving your data. Think about it! However,
dropping the whitespace will yield more consice data.
Adding Comments
Coding Comments
^^^^^^^^^^^^^^^
Allowing comments in domain-specific languages
A common problem with whitespace is that it tends to pollute
...
...
@@ -2045,7 +2044,7 @@ class EBNFCompiler(Compiler):
def gen_search_rule(self, nd: Node) -> ReprType:
"""Generates a search rule, which can be either a string for simple
string search or a regular expression from the nodes content. Returns
string search or a regular expression from the node
'
s content. Returns
an empty string in case the node is neither regexp nor literal.
"""
if nd.tag_name == 'regexp':
...
...
DHParser/parse.py
View file @
65b7b32c
...
...
@@ -807,17 +807,17 @@ def mixin_nonempty(whitespace: str) -> str:
If `whitespace` does not match the empty string '', anyway,
then it will be returned unaltered.
WARNING: `non
_
empty
_ws
` does not work regular expressions the matched
WARNING: `
minin_
nonempty` does not work
for
regular expressions the matched
strings of which can be followed by a symbol that can also occur at
the start of the regular expression.
In particular, it does not work for fixed size regular expressions,
that is
t
/ / or / / or /\t/ won't work, but / */ or /\s*/ or /\s+/
do work. There is no test for this. Fixed
size
s
regular expressions
run through `non
_
empty
_ws
` will not match at any more if they are applied
that is / / or / / or /\t/ won't work, but / */ or /\s*/ or /\s+/
do work. There is no test for this. Fixed
-
size regular expressions
run through `
mixin_
nonempty` will not match at any more if they are applied
to the beginning or the middle of a sequence of whitespaces!
In order to be safe, you whitespace regular expressions should follow
In order to be safe, you
r
whitespace regular expressions should follow
the rule: "Whitespace cannot be followed by whitespace" or "Either
grab it all or leave it all".
...
...
Write
Preview
Supports
Markdown
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