Skip to content

Basic proc-macro identifier vs keyword disambiguation. #141

Open
@eddyb

Description

@eddyb

If the built-in proc-macro IDENT rule is computed after regular rules are added, it could depend on a user-defined rule, let's say KEYWORD, such that:

KEYWORD = "be" | "in" | "lambda" | "let";

would result in IDENT matching any proc-macro identifier except let and lambda.

That would make this grammar less ambiguous (e.g. for (lambda x x) y or let x be y in (x x)):

Expr
    = Var:IDENT
    | Paren:{"(" inner:Expr ")"}
    | Lambda:{"lambda" var:IDENT body:Expr}
    | LetIn:{"let" var:IDENT "be" init:Expr "in" body:Expr}
    | Call:{callee:Expr arg:Expr}
    ;

To recover the old behavior, one could add a IdentOrKw = IDENT | KEYWORD; rule.

While implementing this efficiently would be difficult at this time, proc-macro support isn't exactly fast either, as it has to work with a limited API.

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