def p_simple_statement_list(s, ctx, first_statement = 0):
# Parse a series of simple statements on one line
# separated by semicolons.
- _LOG.debug('p_simple_statement_list(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_simple_statement_list(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
stat = p_simple_statement(s, first_statement = first_statement)
if s.sy == ';':
stats = [stat]
return stat
def p_compile_time_expr(s):
- _LOG.debug('p_compile_time_expr(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_compile_time_expr(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
old = s.compile_time_expr
s.compile_time_expr = 1
expr = p_testlist(s)
return expr
def p_DEF_statement(s):
- _LOG.debug('p_DEF_statement(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_DEF_statement(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
denv = s.compile_time_env
s.next() # 'DEF'
return Nodes.PassStatNode(pos)
def p_IF_statement(s, ctx):
- _LOG.debug('p_IF_statement(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_IF_statement(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
saved_eval = s.compile_time_eval
current_eval = saved_eval
return result
def p_statement(s, ctx, first_statement = 0):
- _LOG.debug('p_statement(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_statement(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
decorators = None
pos = s.position()
if s.sy == 'DEF':
def p_statement_list(s, ctx, first_statement = 0):
# Parse a series of statements separated by newlines.
- _LOG.debug('p_statement_list(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_statement_list(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
stats = []
while s.sy not in ('DEDENT', 'EOF'):
return Nodes.StatListNode(pos, stats = stats)
def p_suite(s, ctx = Ctx(), with_doc = 0, with_pseudo_doc = 0):
- _LOG.debug('p_suite(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_suite(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
s.expect(':')
doc = None
Returns: (positional_args, keyword_args)
"""
- _LOG.debug('p_positional_and_keyword_args(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_positional_and_keyword_args(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
positional_args = []
keyword_args = []
pos_idx = 0
def p_c_base_type(s, self_flag = 0, nonempty = 0, templates = None):
# If self_flag is true, this is the base type for the
# self argument of a C method of an extension type.
- _LOG.debug('p_c_base_type(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_base_type(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
if s.sy == '(':
return p_c_complex_base_type(s)
else:
return p_c_simple_base_type(s, self_flag, nonempty = nonempty, templates = templates)
def p_calling_convention(s):
- _LOG.debug('p_calling_convention(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_calling_convention(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
if s.sy == 'IDENT' and s.systring in calling_convention_words:
result = s.systring
s.next()
def p_c_complex_base_type(s):
# s.sy == '('
- _LOG.debug('p_c_complex_base_type(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_complex_base_type(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
s.next()
base_type = p_c_base_type(s)
base_type = base_type, declarator = declarator)
def p_c_simple_base_type(s, self_flag, nonempty, templates = None):
- _LOG.debug('p_c_simple_base_type(s=<s sy:%s systring:%s>, self_flag=%s, nonempty=%s)'
- % (s.sy, s.systring, self_flag, nonempty))
+ _LOG.debug('p_c_simple_base_type(s=<s sy:%s systring:%s>, self_flag=%s, nonempty=%s)' % (s.sy, s.systring, self_flag, nonempty))
is_basic = 0
signed = 1
longness = 0
def p_buffer_or_template(s, base_type_node, templates):
# s.sy == '['
- _LOG.debug('p_buffer_or_template(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_buffer_or_template(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
s.next()
# Note that buffer_positional_options_count=1, so the only positional argument is dtype.
def looking_at_name(s):
- _LOG.debug('looking_at_name(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('looking_at_name(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
return s.sy == 'IDENT' and not s.systring in calling_convention_words
def looking_at_expr(s):
- _LOG.debug('looking_at_expr(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('looking_at_expr(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
if s.systring in base_type_start_words:
return False
elif s.sy == 'IDENT':
return True
def looking_at_base_type(s):
- _LOG.debug('looking_at_base_type(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('looking_at_base_type(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
return s.sy == 'IDENT' and s.systring in base_type_start_words
def looking_at_dotted_name(s):
- _LOG.debug('looking_at_dotted_name(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('looking_at_dotted_name(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
if s.sy == 'IDENT':
name = s.systring
s.next()
basic_c_type_names + sign_and_longness_words + tuple(special_basic_c_types)
def p_sign_and_longness(s):
- _LOG.debug('p_sign_and_longness(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_sign_and_longness(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
signed = 1
longness = 0
while s.sy == 'IDENT' and s.systring in sign_and_longness_words:
return signed, longness
def p_opt_cname(s):
- _LOG.debug('p_opt_cname(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_opt_cname(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
literal = p_opt_string_literal(s, 'u')
if literal is not None:
cname = EncodedString(literal)
# the declarator must be nonempty. Otherwise we don't care.
# If cmethod_flag is true, then if this declarator declares
# a function, it's a C method of an extension type.
- _LOG.debug('p_c_declarator(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_declarator(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
if s.sy == '(':
s.next()
return result
def p_c_array_declarator(s, base):
- _LOG.debug('p_c_array_declarator(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_array_declarator(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
s.next() # '['
if s.sy != ']':
def p_c_func_declarator(s, pos, ctx, base, cmethod_flag):
# Opening paren has already been skipped
- _LOG.debug('p_c_func_declarator(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_func_declarator(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
args = p_c_arg_list(s, ctx, cmethod_flag = cmethod_flag,
nonempty_declarators = 0)
ellipsis = p_optional_ellipsis(s)
def p_c_simple_declarator(s, ctx, empty, is_type, cmethod_flag,
assignable, nonempty):
- _LOG.debug('p_c_simple_declarator(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_simple_declarator(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
calling_convention = p_calling_convention(s)
if s.sy == '*':
return result
def p_nogil(s):
- _LOG.debug('p_nogil(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_nogil(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
if s.sy == 'IDENT' and s.systring == 'nogil':
s.next()
return 1
return 0
def p_with_gil(s):
- _LOG.debug('p_with_gil(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_with_gil(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
if s.sy == 'with':
s.next()
s.expect_keyword('gil')
return 0
def p_exception_value_clause(s):
- _LOG.debug('p_exception_value_clause(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_exception_value_clause(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
exc_val = None
exc_check = 0
if s.sy == 'except':
nonempty_declarators = 0, kw_only = 0, annotated = 1):
# Comma-separated list of C argument declarations, possibly empty.
# May have a trailing comma.
- _LOG.debug('p_c_arg_list(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_arg_list(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
args = []
is_self_arg = cmethod_flag
while s.sy not in c_arg_list_terminators:
return args
def p_optional_ellipsis(s):
- _LOG.debug('p_optional_ellipsis(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_optional_ellipsis(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
if s.sy == '.':
expect_ellipsis(s)
return 1
def p_c_arg_decl(s, ctx, in_pyfunc, cmethod_flag = 0, nonempty = 0,
kw_only = 0, annotated = 1):
- _LOG.debug('p_c_arg_decl(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_arg_decl(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
not_none = or_none = 0
default = None
kw_only = kw_only)
def p_api(s):
- _LOG.debug('p_api(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_api(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
if s.sy == 'IDENT' and s.systring == 'api':
s.next()
return 1
return p_suite(s, ctx(cdef_flag = 1))
def p_cdef_extern_block(s, pos, ctx):
- _LOG.debug('p_cdef_extern_block(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_cdef_extern_block(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
if ctx.overridable:
error(pos, "cdef extern blocks cannot be declared cpdef")
include_file = None
def p_c_enum_definition(s, pos, ctx):
# s.sy == ident 'enum'
- _LOG.debug('p_c_enum_definition(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_enum_definition(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
s.next()
if s.sy == 'IDENT':
name = s.systring
in_pxd = ctx.level == 'module_pxd')
def p_c_enum_line(s, ctx, items):
- _LOG.debug('p_c_enum_line(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_enum_line(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
if s.sy != 'pass':
p_c_enum_item(s, ctx, items)
while s.sy == ',':
s.expect_newline("Syntax error in enum item list")
def p_c_enum_item(s, ctx, items):
- _LOG.debug('p_c_enum_item(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_enum_item(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
ctx = p_binding(s, ctx)
name = p_ident(s)
def p_c_struct_or_union_definition(s, pos, ctx):
- _LOG.debug('p_c_struct_or_union_definition(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_struct_or_union_definition(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
packed = False
if s.systring == 'packed':
packed = True
packed = packed)
def p_visibility(s, ctx):
- _LOG.debug('p_visibility(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_visibility(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
if s.sy == 'IDENT' and s.systring in ('extern', 'public', 'readonly'):
visibility = s.systring
return ctx
def p_c_modifiers(s):
- _LOG.debug('p_c_modifiers(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_modifiers(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
if s.sy == 'IDENT' and s.systring in ('inline',):
modifier = s.systring
s.next()
return []
def p_binding(s, ctx):
- _LOG.debug('p_binding(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_binding(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
new_ctx = ctx()
new_ctx.overridable = 0
if s.sy == 'cdef':
return new_ctx
def p_c_func_or_var_declaration(s, pos, ctx, decorators=None):
- _LOG.debug('p_c_func_or_var_declaration(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_func_or_var_declaration(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
cmethod_flag = ctx.level in ('c_class', 'c_class_pxd')
modifiers = p_c_modifiers(s)
base_type = p_c_base_type(s, nonempty = 1, templates = ctx.templates)
return result
def p_ctypedef_statement(s, pos, ctx):
- _LOG.debug('p_ctypedef_statement(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_ctypedef_statement(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
if s.sy == 'class':
return p_c_class_definition(s, pos, ctx)
elif s.sy == 'IDENT' and s.systring in ('packed', 'struct', 'union', 'enum'):
in_pxd = ctx.level == 'module_pxd')
def p_decorators(s):
- _LOG.debug('p_decorators(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_decorators(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
decorators = []
while s.sy == 'DECORATOR':
pos = s.position()
def p_def_statement(s, decorators=None):
# s.sy == 'def'
- _LOG.debug('p_def_statement(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_def_statement(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
s.next()
name = EncodedString( p_ident(s) )
return_type_annotation = return_type_annotation)
def p_varargslist(s, terminator=')', annotated=1):
- _LOG.debug('p_varargslist(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_varargslist(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
args = p_c_arg_list(s, in_pyfunc = 1, nonempty_declarators = 1,
annotated = annotated)
star_arg = None
return (args, star_arg, starstar_arg)
def p_py_arg_decl(s, annotated = 1):
- _LOG.debug('p_py_arg_decl(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_py_arg_decl(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
name = p_ident(s)
annotation = None
def p_class_statement(s, decorators):
# s.sy == 'class'
- _LOG.debug('p_class_statement(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_class_statement(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
s.next()
class_name = EncodedString( p_ident(s) )
body = body)
def p_c_class_options(s):
- _LOG.debug('p_c_class_options(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_c_class_options(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
objstruct_name = None
typeobj_name = None
s.expect('[')
return objstruct_name, typeobj_name
def p_property_decl(s):
- _LOG.debug('p_property_decl(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_property_decl(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
pos = s.position()
s.next() # 'property'
name = p_ident(s)
return Nodes.PropertyNode(pos, name = name, doc = doc, body = body)
def p_doc_string(s):
- _LOG.debug('p_doc_string(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_doc_string(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
if s.sy == 'BEGIN_STRING':
pos = s.position()
kind, bytes_result, unicode_result = p_cat_string_literal(s)
return None
def p_code(s, level=None):
- _LOG.debug('p_code(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_code(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
body = p_statement_list(s, Ctx(level = level), first_statement = 1)
if s.sy != 'EOF':
s.error("Syntax error in statement [%s,%s]" % (
COMPILER_DIRECTIVE_COMMENT_RE = re.compile(r"^#\s*cython:\s*((\w|[.])+\s*=.*)$")
def p_compiler_directive_comments(s):
- _LOG.debug('p_compiler_directive_comments(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_compiler_directive_comments(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
result = {}
while s.sy == 'commentline':
m = COMPILER_DIRECTIVE_COMMENT_RE.match(s.systring)
return result
def p_module(s, pxd, full_module_name):
- _LOG.debug('p_module(<s sy:%s systring:%s>, pxd=%s, full_module_name=%s)'
- % (s.sy, s.systring, pxd, full_module_name))
+ _LOG.debug('p_module(<s sy:%s systring:%s>, pxd=%s, full_module_name=%s)' % (s.sy, s.systring, pxd, full_module_name))
pos = s.position()
directive_comments = p_compiler_directive_comments(s)
def p_cpp_class_definition(s, pos, ctx):
# s.sy == 'cppclass'
- _LOG.debug('p_cpp_class_definition(s=<s sy:%s systring:%s>)'
- % (s.sy, s.systring))
+ _LOG.debug('p_cpp_class_definition(s=<s sy:%s systring:%s>)' % (s.sy, s.systring))
s.next()
module_path = []
class_name = p_ident(s)