My PSI tree is not hierarchical Follow
Hi
I've created JFlex lexer and parser via Grammar-Kit, but
PSI Viewer shows PSI tree as list not as tree (see screenshot below).
bnf grammar: importStatement ::= 'import' id ('.' id)* {pin=1}
generated parser code:
/* ********************************************************** */
// 'import' id ('.' id)*
public static boolean importStatement(PsiBuilder builder_, int level_) {
if (!recursion_guard_(builder_, level_, "importStatement")) return false;
boolean result_ = false;
boolean pinned_ = false;
final Marker marker_ = builder_.mark();
enterErrorRecordingSection(builder_, level_, _SECTION_GENERAL_);
result_ = consumeToken(builder_, "import");
pinned_ = result_; // pin = 1
result_ = result_ && report_error_(builder_, consumeToken(builder_, BOO_ID));
result_ = pinned_ && importStatement_2(builder_, level_ + 1) && result_;
if (result_ || pinned_) {
marker_.done(BOO_IMPORTSTATEMENT);
}
else {
marker_.rollbackTo();
}
result_ = exitErrorRecordingSection(builder_, result_, level_, pinned_, _SECTION_GENERAL_, null);
return result_ || pinned_;
}
What I'm doing wrong?
Please sign in to leave a comment.
Are you asking why there isn't an node for importStatement? Is that really your whole grammer? If that is the top level production wouldn't that be your file node?
I can't say that I am a grammar kit expert. Just a thought.
You can try the other PsiViewer plugin. It is more helpful sometimes than the default tool.
http://plugins.intellij.net/plugin/?idea&pluginId=227
If there's no "pin" then generated parser does rollback on first problem
in each method and in the end the default "parse" method just skips all
tokens to the end. So look for PsiErrorElements in PSI Viewer results.
Generated parser is pretty easy to debug: just add
"builder_.getTokenText()" to Watches.
Currently it is hard to tell more.
On 7/3/12 11:27 AM, Taras Beletskyy wrote:
>
>
>
>
>
>
>
>
--
Gregory Shrago
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop With Pleasure!"