summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2021-02-02 19:54:22 (GMT)
committerGitHub <noreply@github.com>2021-02-02 19:54:22 (GMT)
commit58fb156edda1a0e924a38bfed494bd06cb09c9a3 (patch)
tree6d09348120225209479d011aa83be95d488e3380 /Doc
parent802b645e81a72399a7ef47ef000d468c775dcd3e (diff)
downloadcpython-58fb156edda1a0e924a38bfed494bd06cb09c9a3.zip
cpython-58fb156edda1a0e924a38bfed494bd06cb09c9a3.tar.gz
cpython-58fb156edda1a0e924a38bfed494bd06cb09c9a3.tar.bz2
bpo-42997: Improve error message for missing : before suites (GH-24292)
* Add to the peg generator a new directive ('&&') that allows to expect a token and hard fail the parsing if the token is not found. This allows to quickly emmit syntax errors for missing tokens. * Use the new grammar element to hard-fail if the ':' is missing before suites.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/tools/extensions/peg_highlight.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Doc/tools/extensions/peg_highlight.py b/Doc/tools/extensions/peg_highlight.py
index 9a2acb7..4ade1bf 100644
--- a/Doc/tools/extensions/peg_highlight.py
+++ b/Doc/tools/extensions/peg_highlight.py
@@ -27,6 +27,12 @@ class PEGLexer(RegexLexer):
tokens = {
"ws": [(r"\n", Text), (r"\s+", Text), (r"#.*$", Comment.Singleline),],
"lookaheads": [
+ # Forced tokens
+ (r"(&&)(?=\w+\s?)", bygroups(None)),
+ (r"(&&)(?='.+'\s?)", bygroups(None)),
+ (r'(&&)(?=".+"\s?)', bygroups(None)),
+ (r"(&&)(?=\(.+\)\s?)", bygroups(None)),
+
(r"(?<=\|\s)(&\w+\s?)", bygroups(None)),
(r"(?<=\|\s)(&'.+'\s?)", bygroups(None)),
(r'(?<=\|\s)(&".+"\s?)', bygroups(None)),