Skip to content

PathPattern vs IdentifierPattern #605

Closed

Description

@MemPage

How to differ between IdentifierPattern and PathPattern when they can be just IDENTIFIER?

Pattern can be either IdentifierPattern or PathPattern.

Rules applied:

Pattern: IdentifierPattern
Pattern->IdentifierPattern

IdentifierPattern: ref? mut? IDENTIFIER (@ Pattern ) ?
IdentifierPattern->IDENTIFIER

And for the PathPattern

PathPattern: PathInExpression
PathPattern->PathInExpression

PathInExpression: ::? PathExprSegment (:: PathExprSegment)*
PathInExpression->PathExprSegment

PathExprSegment:PathIdentSegment (:: GenericArgs)?
PathExprSegment->PathIdentSegment

PathIdentSegment:IDENTIFIER
PathIdentSegment->IDENTIFIER

Not sure if there is a BIGGER rule to solve this out, or just we don't care at the parsing stage, but how to decide is this IDENTIFIER a IdentifierPattern or PathPattern?

Activity

  1. ehuss commented on May 3, 2019

    @ehuss
    Contributor

    I don't think you can disambiguate with pure parsing (see PatKind), it has to be done with name resolution. I think this particular disambiguation is done here, though I am not very familiar with rustc.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-grammarArea: Syntax and parsingA-patternsArea: Patterns

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions