diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2020-05-26 23:15:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-26 23:15:52 (GMT) |
commit | 404b23b85b17c84e022779f31fc89cb0ed0d37e8 (patch) | |
tree | fea9aca0072a7f5f06a5af49b36b434185d7e76c /Parser | |
parent | 21fda91f8da96406e6a912f7c312424209c19bef (diff) | |
download | cpython-404b23b85b17c84e022779f31fc89cb0ed0d37e8.zip cpython-404b23b85b17c84e022779f31fc89cb0ed0d37e8.tar.gz cpython-404b23b85b17c84e022779f31fc89cb0ed0d37e8.tar.bz2 |
Fix lookahead of soft keywords in the PEG parser (GH-20436)
Automerge-Triggered-By: @gvanrossum
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/pegen/pegen.c | 9 | ||||
-rw-r--r-- | Parser/pegen/pegen.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Parser/pegen/pegen.c b/Parser/pegen/pegen.c index ee30c2c..a0285bc 100644 --- a/Parser/pegen/pegen.c +++ b/Parser/pegen/pegen.c @@ -719,6 +719,15 @@ _PyPegen_lookahead_with_name(int positive, expr_ty (func)(Parser *), Parser *p) } int +_PyPegen_lookahead_with_string(int positive, expr_ty (func)(Parser *, const char*), Parser *p, const char* arg) +{ + int mark = p->mark; + void *res = func(p, arg); + p->mark = mark; + return (res != NULL) == positive; +} + +int _PyPegen_lookahead_with_int(int positive, Token *(func)(Parser *, int), Parser *p, int arg) { int mark = p->mark; diff --git a/Parser/pegen/pegen.h b/Parser/pegen/pegen.h index 9507d99..64cf0ec 100644 --- a/Parser/pegen/pegen.h +++ b/Parser/pegen/pegen.h @@ -119,6 +119,7 @@ int _PyPegen_is_memoized(Parser *p, int type, void *pres); int _PyPegen_lookahead_with_name(int, expr_ty (func)(Parser *), Parser *); int _PyPegen_lookahead_with_int(int, Token *(func)(Parser *, int), Parser *, int); +int _PyPegen_lookahead_with_string(int , expr_ty (func)(Parser *, const char*), Parser *, const char*); int _PyPegen_lookahead(int, void *(func)(Parser *), Parser *); Token *_PyPegen_expect_token(Parser *p, int type); |