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

gh-127833: Reword and expand the Notation section#134443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
encukou wants to merge5 commits intopython:main
base:main
Choose a base branch
Loading
fromencukou:grammar-notation

Conversation

encukou
Copy link
Member

@encukouencukou commentedMay 21, 2025
edited by github-actionsbot
Loading

Prepare the docs for using the notation used in thepython.gram file. If we want to sync the two, the meta-syntax should be the same.

Also, remove the distinction between lexical and syntactic rules.
With f- and t-strings, the line between the two is blurry.


📚 Documentation preview 📚:https://cpython-previews--134443.org.readthedocs.build/

Prepare the docs for using the notation used in the `python.gram`file. If we want to sync the two, the meta-syntax should be the same.Also, remove the distinction between lexical and syntactic rules.With f- and t-strings, the line between the two is blurry.
Co-authored-by: Blaise Pabon <blaise@gmail.com>
@encukou
Copy link
MemberAuthor

@lysnikolaou, does this look correct to you?
Rendered docs:notation section,full grammar

Co-authored-by: Blaise Pabon <blaise@gmail.com>Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
@encukouencukou marked this pull request as ready for reviewMay 28, 2025 16:08
@lysnikolaou
Copy link
Member

I'll have a look at this tomorrow if that's okay.

encukou reacted with thumbs up emoji

Copy link
Member

@lysnikolaoulysnikolaou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks great in general! Left a few not-so-significant comments inline

* ``&e``: a positive lookahead (that is, ``e`` is required to match but
not consumed)
* ``!e``: a negative lookahead (that is, ``e`` is required *not* to match)
* ``~`` ("cut"): commit to the current alternative, even if it fails to parse
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
* ``~`` ("cut"): commit to the current alternative, even if it fails to parse
* ``~`` ("cut"): commit to the current alternative and fail the rule
even if this fails to parse

Comment on lines +132 to +136
* ``"a"..."z"``: Two literal characters separated by three dots mean a choice
of any single character in the given (inclusive) range of ASCII characters.
* ``<...>``: A phrase between angular brackets gives an informal description
of the matched symbol (for example, ``<any ASCII character except "\">``),
or an abbreviation that is defined in nearby text (for example, ``<Lu>``).
Copy link
Member

@lysnikolaoulysnikolaouMay 29, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should we be mentioning somewhere that these are not part of the actual Python grammar, but part of the notation to make it easier to describe specific constructs? Maybe as part of the first paragraph that says that this is a mixture of EBNF and PEG?

The definition to the right of the colon uses the following syntax elements:

* ``name``: A name refers to another rule.
Where possible, it is a link to the rule's definition.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What possibilities exist, other than referencing another rule?

*Syntactic* definitions then use these tokens, rather than source characters.

This documentation uses the same BNF grammar for both styles of definitions.
All uses of BNF in the next chapter (“Lexical Analysis”) are lexical definitions;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
All uses of BNF in the next chapter (“Lexical Analysis”) are lexical definitions;
All uses of BNF in the next chapter (:ref:`lexical`) are lexical definitions;

?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@cmarqucmarqucmarqu left review comments

@lysnikolaoulysnikolaoulysnikolaou left review comments

@willingcwillingcAwaiting requested review from willingcwillingc is a code owner

@AA-TurnerAA-TurnerAwaiting requested review from AA-TurnerAA-Turner is a code owner

Assignees
No one assigned
Labels
awaiting core reviewdocsDocumentation in the Doc dirskip news
Projects
Status: Todo
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@encukou@lysnikolaou@cmarqu

[8]ページ先頭

©2009-2025 Movatter.jp