I would love having even basic intellij plugin for nim. I started making one and currently i am at crossroads. On one hand some basic syntax highlighting could be provided with fake lexer. However to get more contextual info (say so IDE would understand where is typename in proc definition) i would have to do either horrible hack in lexer or make also parser. Neither sound appealing. One idea i have is that maybe we could somehow hook compiler up as backend to implement lexer/parser interfaces IDE wants. Here are interfaces:
public interface PsiParser {
@NotNull
ASTNode parse(IElementType t, PsiBuilder b);
}
public interface FlexLexer {
// Sets current state. Optional?
void yybegin(int newState);
// Returns current state. Optional?
int yystate();
// Last token start pos in text file
int getTokenStart();
// Last token end pos in text file
int getTokenEnd();
// Gets next element (or is it token?)
IElementType advance() throws IOException;
// Start parsing text in buffer.
void reset(CharSequence buffer, int start, int end, int initialState);
}
@Araq since you are the best man to ask maybe you could tell me if such approach is viable? If so maybe you could suggest some ways of doing this?
EDIT: Im thinking maybe lexer/parser as service (much like idetools now) could work. With simple RPC via stdin?