Define own keyword in procedural macro plugins



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/
130 | const KwNode: Keyword = Keyword {
    |                         ^
  1. Is there another way how i can define keywords?
  2. Are self-defined keywords even supported (in any way) by the Parser?
  3. Is there maybe a better way doing what i want?
  4. some kind of:



there are contextual_keyword and all the expect(Token::Ident(foo)) functions.

edit: Nope, expect(Token::Ident(foo)) isn’t working as it is doing a simple equal check, which is failing because of different SyntaxContext.