JetBrains / Grammar-Kit

Grammar files support & parser/PSI generation for IntelliJ IDEA
Other
715 stars 125 forks source link

Tell generator to use existing lexer and tokenTypes #355

Closed nadavhames closed 10 months ago

nadavhames commented 10 months ago

Is there a way to tell grammarkit that I already have an existing lexer implementation and TokenTypes defined? Ideally I want to point grammarkit to my Tokens class where I have all my existing TokenTypes defined so I can use them in the bnf to write my grammar. Meaning grammar kit would only need to generate ElementTypes for the nodes and the PsiElements etc.

gregsh commented 10 months ago

Use parserImports to add static imports for your constants, and turn off the generation of the Types class:

  generate=[elements="no" tokens="no"] // this attribute has a QuickDoc for all options (Ctrl-Q/Ctrl-J)
  parserImports=[
    "static com.sample.MyTokenTypes.*"
  ]