Java parser: transcription finished

Jakob Petsovits jpetso at gmx.at
Fri Dec 2 12:20:09 UTC 2005


Am Friday 02 December 2005 11:50 schrieb Roberto Raggi:
> On Friday 02 December 2005 11:15, Jakob Petsovits wrote:
> > If for example LBRACE !(anything) RBRACE doesn't match {} and 'anything'
> > does under no circumstances start with RBRACE, then I assume it's a bug.
>
> hmm, if `anything' does not reduce the episilon (-> 0)  you need to write
>
>   LBRACE RBRACE | LBRACE !(anything) RBRACE
> -> ...
>
> or
>
>   LBRACE (!anything | 0) RBRACE
> -> ...

I still don't get it. In the 'kdevelop-pg syntax/semantics' reply, you said
> > (bla)+
> > is: !(bla)
> not really :-)  the bang operator means an optional sequence of "blah" so
> it's more like bla* than bla+.. kdevelop-pg doesn't have a + operator (but
> actually it is a good idea and i'm going to add it). If you want blah+ you
> need to write (blah !blah)

So what you're saying now is that !(...) is neither (...)* nor (...)+ but 
something in between. If you want (...)* then you have to write
( !(...) | 0 ), otherwise you get strange behaviour when used within
other rules.
Still, !(anything) on its own can indeed match an empty set of tokens (0).

I can of course adapt the grammar, it's just that I don't feel this is 
intuitive, and it will probably be a source of errors in future grammars.
You have to understand the implementation and that epsilon stuff
to foresee how it will work, I find that suboptimal.
/me goes off to finally google what epsilon means here.


> extend kdev-pg to support backtracking is pretty easy :-) but LL(k) is not
> trivial. I think your work is great!! I really want it in KDevelop. So I
> think it is time to me to implement backtracking in kdev-pg.

terrific!

cheers,
  Jakob




More information about the KDevelop-devel mailing list