Commit 65b7b32c authored by eckhart's avatar eckhart
Browse files

ebnf.py: documentation extended

parent 93e08a51
......@@ -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 jsut try our grammar on an example::
Let's just 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':
......
......@@ -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 ist / / or / / or /\t/ won't work, but / */ or /\s*/ or /\s+/
do work. There is no test for this. Fixed sizes 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, your whitespace regular expressions should follow
the rule: "Whitespace cannot be followed by whitespace" or "Either
grab it all or leave it all".
......
Supports Markdown
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