Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Avoid accidental clashes between names in grammar and infrastructure #125

Closed
python/cpython
#19987
@gvanrossum

Description

@gvanrossum

(Fromwe-like-parsers/pegen#84.)

Items in an alternative may be named, and the names may be referenced in actions. But there are some "forbidden" names. E.g. don't name an itemp, because (when generating C code) every rule parsing function has an argument namedp. There are other possible name clashes too:res andmark are always local variables.And there are many helper functions, with names likeis_memoized orsingleton_seq. And of course anything that's a C reserved word (e.g.if) cannot be used either. Also there are systematic generated names like*_var,*_type and*_rule.

It's easy to renamep,mark andres in the generated code to start with an underscore (by convention, rule names don't start with_, and maybe we should make this a hard requirement). I'm not sure we need to worry about the others, though we may have to warn about them in the docs.

When generating Python code there are other possible clashes, e.g.self,mark andcut. We can handle these the same way. (There are a few others that seem less important, likeast and of course Python builtins and keywords.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp