Different results on live preview and running ide

Answered

I have no idea what went wrong but I’m getting different results on live preview and on the actual running idea. 

I'm trying to recover the parser once the user type only a dot in a dot qualification, like 'a.b.c'. More precisely, I'm trying to recover the parser when user type something like 'a.b.' (with only a dot - no expression yet after it). So putting a pin(".*")='DOT' on postfix_expr gives me exactly what I wanted, but once I run the ide I get different results! (see screenshots). On preview it seems to work but on the ide it doesn't. Am I doing something weird by setting this pin  on postfix_expr? I couldn't get it work otherwise, and in any case, something is weird if it shows different results. Then when playing with pin and recoverWhile and restarting the ide for every little change would make it a hell. Any ideas?

Here is my grammar:

{
...
extends("postfix_inc|postfix_struct_member|postfix_index|primary_expr")=postfix_expr
...
}

...

postfix_expr
    ::= postfix_index
    |   postfix_struct_member
    |   postfix_inc
    |   primary_expr
    {   pin(".*")='DOT'    }

postfix_inc
    ::= postfix_expr (INC_OP|DEC_OP)

postfix_struct_member
    ::= postfix_expr (DOT variable_identifier)+

postfix_index
    ::= postfix_expr LEFT_BRACKET integer_expression RIGHT_BRACKET

primary_expr
    ::= variable_identifier
    |   FLOATCONSTANT
    |   INTCONSTANT
    |   UINTCONSTANT
|   BOOLCONSTANT
|   STRING_LITERAL
    |   DOUBLECONSTANT

...

Here is the code on live preview (recovery successful): 

And the code on the actual ide (recovery unsuccessful):

0
2 comments

Hi Walt,

Do you have an additional custom lexer for your language? Live Preview uses the lexer based on the tokens section in the BNF file. It may cause the differences between Live Preview and actual IDE. See also: https://github.com/JetBrains/Grammar-Kit/issues/44

If this is not the case, please provide us with more information (complete code and file to reproduce the issue would be great).

0

Yes I do and that was probably the reason. It's now fixed. Was just contra productive to work on something where it's actually something different. Thanks anyway. Can be closed...

0

Please sign in to leave a comment.