Closed jfecher closed 1 week ago
Thought I could get away without a Value::into_tokens
method but the macros test is failing without it. I'll need to add it now
Alright, I managed without it by parsing the new UnquoteMarker
token as an expression.
Description
Problem*
Resolves https://github.com/noir-lang/noir/issues/5284
Summary*
Adds a new
Quoted
type which is the new default output of aquote { ... }
expression. In addition, aquote
expression now quotes an unparsed, raw vector of tokens terminated by the matching closing brace. This has a number of advantages:quote { ) ( }
are valid as long as they're grammatically valid by the time the macro is unquoted at its call site. The only restriction on the grammar of these is that they cannot have an unmatched}
since that would close thequote
expression itself. Matched{
and}
paris however, are fine:quote { look, a block: { foo } }
.Expr
,Type
, andTopLevelItem
types).The current plan is to keep the other macro types (
Expr
,Type
,TopLevelItem
, etc) as optional outputs ofquote
only if they're specified after the keyword, e.g.quote Type { Foo<A, B> }
. Since the new approach of using token streams by default is much more flexible, there's less of a need for these however.Additional Context
The formatting of quote expressions has also been fixed. This was a necessary change since these expressions hold token streams now instead of ASTs and thus can't be formatted the old way.
Edit: This does not fix the existing issue with formatting comptime blocks, only
quote
blocks which were similarly affected.Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.