Hi,
Im about to write a procedural macro plugin and i wanted to reuse the rusts Parser for easy Token consumption and error handling, also i wanted to add my own keywords, so i can consume them with the Parser. But im getting a compile error:
use syntax::parse::token::keywords::Keyword;
use syntax::parse::token;
use syntax::ast;
const KwNode: Keyword = Keyword {
ident: ast::Ident::with_empty_ctxt(token::intern("node")),
};
fn my_macro(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
-> Box<MacResult + 'static>
{
let p = cx.new_parser_from_tts(args);
// ...
}
error[E0451]: field `ident` of struct `syntax::parse::token::keywords::Keyword` is private
--> src/lib.rs:130:25
|
130 | const KwNode: Keyword = Keyword {
| ^
- Is there another way how i can define keywords?
- Are self-defined keywords even supported (in any way) by the Parser?
- Is there maybe a better way doing what i want?
- some kind of: Add an #[allow(ignore_field_privacy)] annotation - ideas (deprecated) - Rust Internals