How to write a language.psi.SimpleTypes?


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?

Comment actions Permalink

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 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

Comment actions Permalink

After generating the src/main/gen directory contains the org/intellij/sdk/language directory wich contains a single file -

It started from some strings:

package org.intellij.sdk.language;

import com.intellij.lexer.FlexLexer;
import com.intellij.psi.tree.IElementType;
import com.intellij.sdk.language.psi.SimpleTypes;
import com.intellij.psi.TokenType;

class SimpleLexer implements FlexLexer {...

I don't see where the SimpleTypes class is. The src/main/gen/.../language contains only one file. And it is not a, it is the only wich use the SimpleTypes class.

Comment actions Permalink

This is not the expected result, it should really match the output shown on the screenshot here

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?

Comment actions Permalink

I am very sorry, It's my fault! I did't press Generate Parser Code on step #3.


Please sign in to leave a comment.