Skip to content

macro parser should back out of failed nonterminal parsing #3232

Description

@paulstansifer

Currently, the following macro argument grammar will not successfully parse anything, complaining of a "local ambiguity":

 $( $t:ty )* #

The problem is that if it were to use the Rust parser to try to parse a type and fail, the whole task would be killed. This is easy to fix after that problem is resolved. There are two options:

  1. Break parsing into a separate task, and see whether it survives. However, parse.rs requires a parse_sess, which is mutable state, and can't be shared. So the second option is probably more doable:
  2. Allow the parser to safely return instead of killing the task. This works much like the Error monad. Ordinarily, this would require a lot of tedious wrapping and unwrapping, but we have a macro system! It should be relatively easy to make a notation like Haskell's do, and the parser would be able to stay in the standard imperative style.

Activity

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-parserArea: The lexing & parsing of Rust source code to an ASTA-syntaxextArea: Syntax extensionsP-lowLow priority

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions