Unnamed repository; edit this file 'description' to name the repository.
Merge rust-analyzer/ungrammar#33
33: Add a `Meta` node representing attribute contents r=jonas-schievink a=jonas-schievink The main motivation of this change is to make attribute handling easier: `#[cfg_attr]` can expand to an arbitrary nested list of attributes, and we currently just format those with `#[{}]` and parse that, which loses the assigned `TokenId`s. The `TokenId`s will be needed later to uniquely identify attributes that come from `cfg_attr`. With this change, we can instead use `mbe::token_tree_to_syntax_node` to parse the tokens into a `FragmentKind::MetaItem`, which returns a `ast::Meta` node, and process that. Co-authored-by: Jonas Schievink <[email protected]>
bors[bot] 2021-06-11
parent c0938ac · parent 8f2eb62 · commit 4b2938c
-rw-r--r--lib/ungrammar/Cargo.toml2
-rw-r--r--lib/ungrammar/rust.ungram5
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/ungrammar/Cargo.toml b/lib/ungrammar/Cargo.toml
index e5c1d501a7..56dbc825fa 100644
--- a/lib/ungrammar/Cargo.toml
+++ b/lib/ungrammar/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "ungrammar"
description = "A DSL for describing concrete syntax trees"
-version = "1.13.0"
+version = "1.14.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/matklad/ungrammar"
authors = ["Aleksey Kladov <[email protected]>"]
diff --git a/lib/ungrammar/rust.ungram b/lib/ungrammar/rust.ungram
index 3ebe1cbd32..d08ae24905 100644
--- a/lib/ungrammar/rust.ungram
+++ b/lib/ungrammar/rust.ungram
@@ -298,7 +298,10 @@ Visibility =
'pub' ('(' 'in'? Path ')')?
Attr =
- '#' '!'? '[' Path ('=' Expr | TokenTree)? ']'
+ '#' '!'? '[' Meta ']'
+
+Meta =
+ Path ('=' Expr | TokenTree)?
//****************************//
// Statements and Expressions //