Skip to content

Full Grammar specification lists invalid syntax #118235

Closed
@encukou

Description

@encukou

The Full Grammar specification lists these production rules:

 type_param:  
     | NAME [type_param_bound]
     | '*' NAME ':' expression
     | '*' NAME 
     | '**' NAME ':' expression 
     | '**' NAME 
 
 for_if_clause:
     | 'async' 'for' star_targets 'in' ~ disjunction ('if' disjunction )* 
     | 'for' star_targets 'in' ~ disjunction ('if' disjunction )* 
     | 'async'? 'for' (bitwise_or (',' bitwise_or)* [',']) !'in' 

 starred_expression:
     | '*' expression 
     | '*' 

However, some of the alternatives are actually invalid syntax: in the grammar file we can find that they're handled by raising a syntax error. For example:

for_if_clause[comprehension_ty]:
    [...]
    | 'async'? 'for' (bitwise_or (',' bitwise_or)* [',']) !'in' {
        RAISE_SYNTAX_ERROR("'in' expected after for-loop variables") }

These should be hidden in the same way as other invalid rules.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions