mirror of https://github.com/python/cpython
bpo-40334: Fix build errors and warnings in test_peg_generator (GH-19672)
This commit is contained in:
parent
ee40e4b856
commit
1df5a9e88c
|
@ -640,6 +640,16 @@ _PyPegen_is_memoized(Parser *p, int type, void *pres)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
_PyPegen_lookahead_with_name(int positive, expr_ty (func)(Parser *), Parser *p)
|
||||||
|
{
|
||||||
|
int mark = p->mark;
|
||||||
|
void *res = func(p);
|
||||||
|
p->mark = mark;
|
||||||
|
return (res != NULL) == positive;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_PyPegen_lookahead_with_string(int positive, void *(func)(Parser *, const char *), Parser *p,
|
_PyPegen_lookahead_with_string(int positive, void *(func)(Parser *, const char *), Parser *p,
|
||||||
const char *arg)
|
const char *arg)
|
||||||
|
@ -663,7 +673,7 @@ int
|
||||||
_PyPegen_lookahead(int positive, void *(func)(Parser *), Parser *p)
|
_PyPegen_lookahead(int positive, void *(func)(Parser *), Parser *p)
|
||||||
{
|
{
|
||||||
int mark = p->mark;
|
int mark = p->mark;
|
||||||
void *res = func(p);
|
void *res = (void*)func(p);
|
||||||
p->mark = mark;
|
p->mark = mark;
|
||||||
return (res != NULL) == positive;
|
return (res != NULL) == positive;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ int _PyPegen_insert_memo(Parser *p, int mark, int type, void *node);
|
||||||
int _PyPegen_update_memo(Parser *p, int mark, int type, void *node);
|
int _PyPegen_update_memo(Parser *p, int mark, int type, void *node);
|
||||||
int _PyPegen_is_memoized(Parser *p, int type, void *pres);
|
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_string(int, void *(func)(Parser *, const char *), Parser *, const char *);
|
int _PyPegen_lookahead_with_string(int, void *(func)(Parser *, const char *), Parser *, const char *);
|
||||||
int _PyPegen_lookahead_with_int(int, Token *(func)(Parser *, int), Parser *, int);
|
int _PyPegen_lookahead_with_int(int, Token *(func)(Parser *, int), Parser *, int);
|
||||||
int _PyPegen_lookahead(int, void *(func)(Parser *), Parser *);
|
int _PyPegen_lookahead(int, void *(func)(Parser *), Parser *);
|
||||||
|
|
|
@ -9,6 +9,7 @@ import distutils.log
|
||||||
from distutils.core import Distribution, Extension
|
from distutils.core import Distribution, Extension
|
||||||
from distutils.command.clean import clean # type: ignore
|
from distutils.command.clean import clean # type: ignore
|
||||||
from distutils.command.build_ext import build_ext # type: ignore
|
from distutils.command.build_ext import build_ext # type: ignore
|
||||||
|
from distutils.tests.support import fixup_build_ext
|
||||||
|
|
||||||
from pegen.c_generator import CParserGenerator
|
from pegen.c_generator import CParserGenerator
|
||||||
from pegen.grammar import Grammar
|
from pegen.grammar import Grammar
|
||||||
|
@ -69,6 +70,7 @@ def compile_c_extension(
|
||||||
]
|
]
|
||||||
dist = Distribution({"name": extension_name, "ext_modules": extension})
|
dist = Distribution({"name": extension_name, "ext_modules": extension})
|
||||||
cmd = build_ext(dist)
|
cmd = build_ext(dist)
|
||||||
|
fixup_build_ext(cmd)
|
||||||
cmd.inplace = True
|
cmd.inplace = True
|
||||||
if build_dir:
|
if build_dir:
|
||||||
cmd.build_temp = build_dir
|
cmd.build_temp = build_dir
|
||||||
|
|
|
@ -93,7 +93,9 @@ class CCallMakerVisitor(GrammarVisitor):
|
||||||
func, args = call.split("(", 1)
|
func, args = call.split("(", 1)
|
||||||
assert args[-1] == ")"
|
assert args[-1] == ")"
|
||||||
args = args[:-1]
|
args = args[:-1]
|
||||||
if not args.startswith("p,"):
|
if "name_token" in call:
|
||||||
|
return None, f"_PyPegen_lookahead_with_name({positive}, {func}, {args})"
|
||||||
|
elif not args.startswith("p,"):
|
||||||
return None, f"_PyPegen_lookahead({positive}, {func}, {args})"
|
return None, f"_PyPegen_lookahead({positive}, {func}, {args})"
|
||||||
elif args[2:].strip().isalnum():
|
elif args[2:].strip().isalnum():
|
||||||
return None, f"_PyPegen_lookahead_with_int({positive}, {func}, {args})"
|
return None, f"_PyPegen_lookahead_with_int({positive}, {func}, {args})"
|
||||||
|
|
Loading…
Reference in New Issue