How to write a language.psi.SimpleTypes? Follow
Answered
The "Grammar and Parser" of the "Custom Language Support Tutorial" says "Note that the SimpleTypes
class in the elementTypeHolderClass
attribute above specifies the name of a class that gets generated from the grammar; it doesn't exist at this point".
But the "Lexer and Parser Definition" starts using SimpleTypes class after generating a Lexer class by Simple.flex file with JFlex Generator. And does't describe how to write the SimpleTypes
class before or after.
How do I write a org.intellij.sdk.language.psi.SimpleTypes?
Please sign in to leave a comment.
You do not write that class yourself. As you already cited it is generated from the grammar (Simple.bnf).
After proceding as described in section https://plugins.jetbrains.com/docs/intellij/grammar-and-parser.html#generate-a-parser you should find the file below the src/main/gen source directory. This directory has to be added to the project's sourceSets, as described in section https://plugins.jetbrains.com/docs/intellij/lexer-and-parser-definition.html#required-project-configuration-change
After generating the src/main/gen directory contains the org/intellij/sdk/language directory wich contains a single file - SimpleLexer.java.
It started from some strings:
I don't see where the SimpleTypes class is. The src/main/gen/.../language contains only one file. And it is not a SimpleTypes.java, it is the only SimpleLexer.java wich use the SimpleTypes class.
This is not the expected result, it should really match the output shown on the screenshot here https://plugins.jetbrains.com/docs/intellij/grammar-and-parser.html#generate-a-parser
If it still doesn't work, please post the exact `bnf` file contents you're using as well as used IDE version. Are you using latest GrammarKit plugin version?
I am very sorry, It's my fault! I did't press Generate Parser Code on step #3.