Skip to content

Commit 0ee885c

Browse files
Merge #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 <jonasschievink@gmail.com>
2 parents 9f24a24 + b344c9a commit 0ee885c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "ungrammar"
33
description = "A DSL for describing concrete syntax trees"
4-
version = "1.13.0"
4+
version = "1.14.0"
55
license = "MIT OR Apache-2.0"
66
repository = "https://github.com/matklad/ungrammar"
77
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]

rust.ungram

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,10 @@ Visibility =
298298
'pub' ('(' 'in'? Path ')')?
299299

300300
Attr =
301-
'#' '!'? '[' Path ('=' Expr | TokenTree)? ']'
301+
'#' '!'? '[' Meta ']'
302+
303+
Meta =
304+
Path ('=' Expr | TokenTree)?
302305

303306
//****************************//
304307
// Statements and Expressions //

0 commit comments

Comments
 (0)