[antlr-interest] syntax predicate strange behavior
    Ilia Kantor 
    ilia at obnovlenie.ru
       
    Tue May  1 04:52:34 PDT 2007
    
    
  
>  >command_arguments:	
>  >	command_argument (SEMI command_argument)*;
>  >
>  >command_argument  :
>  >        (WS? WORD WS? MINUS GT) => WS? WORD WS? MINUS GT
>  >e=exprs_no_semi |
>  >        exprs_no_semi ;
> 
> Hmm.  Given that this one appears equivalent to this:
> 
> command_argument:
>    (WS? WORD WS? MINUS GT)? exprs_no_semi;
> 
> ... what's in exprs_no_semi?  Does it contain WORDs?  If so, that 
> could be the source of the ambiguity.
Yes, exprs_no_semi can contain WORDs, but still no idea why it gives DFA.NoViableAlt error and
works just fine in backtrack mode.. 
> 
> (Out of curiosity, is there any particular reason why you're not 
> merging 'MINUS GT' into a single 'ARROW' token or something?  Or 
> why you're treating whitespace as significant instead of simply 
> marking it as hidden and forgetting about it?)
The language I'm working on, merges commands into text, like
blabla ~DoThat{ arg1 -> myarg  } and -> gotcha.
First arrow is keyworded argument, second arrow is just plain text.
WS is important in text, but should be cut in arguments.
That's also the reason of using MINUS + GT, I let the parser to join them if needed into "arrow".
arrow: MINUS GT;
This rule was left out in my example to make stuff easier to read.
    
    
More information about the antlr-interest
mailing list