Loading ...
Sorry, an error occurred while loading the content.

Re: [antlr-interest] Coctail vs ANTLR

Expand Messages
  • Ric Klaren
    Hi, Note: All the comments about Cocktail are about the *free* version (one of the 1992 ones) *not* the commercial one. ... Hmmm so they have a page again (it
    Message 1 of 5 , Oct 1, 2001
    • 0 Attachment
      Hi,

      Note: All the comments about Cocktail are about the *free* version (one of
      the 1992 ones) *not* the commercial one.

      On Sun, Sep 30, 2001 at 01:51:22PM +0300, Ruslan Zasukhin wrote:
      > Ric have mention Coctail parser generator toolbox.
      > I have found it: http://www.first.gmd.de/cocktail/

      Hmmm so they have a page again (it completely disappeared from the net (at
      least the gmd site) for a while). Even a slightly newer version than I
      used.

      The free version I used only supports C output natively. And older C++
      compilers could grok it as well. Lateron I hacked a version that generated
      classes and more real C++ output.

      > -- generated parsers include automatic error recovery, error messages, and
      > error repair

      This is something that could be ported to antlr btw. Although I didn't miss
      the extra recovery facilities much. Antlr's facilities are not that
      different. Also the speedup tricks may be portable to some extent.

      > So I wonder, if it is so good where its weak sides ?

      As Stdiobe pointed out the Modula2 <-> C translations make it a bit of a
      pain to get to work at times. Getting it bootstrapped without a modula2
      compiler is somewhat of a hassle. Furthermore you see the modula2 roots in
      everything of the thing (if that bothers you).

      > ANTLR fans, do you know about Coctail, have you try it? why you still
      > prefer ANTLR.

      I switched from Cocktail to ANTLR for the simple reason that support for
      antlr doesn't cost a lot of money. Furthermore there's no real C++ support
      in the free version (at least the 92xx versions) per default the output
      will not compile in a modern C++ compiler (some tweaking of defines
      (boolean/true/false etc.) in the support libraries is needed)
      Also there's no community of free cocktail users I'm aware of, and well for
      antlr.. well here we are =).

      Cocktail has much more powerfull tree building / transformation facilities.
      But they are harder to get the hang of (at least I had some trouble with
      it, but that was me years ago =) ).

      > I have hear already that ANTLR error support is best. But it looks Coctail
      > also has very strong error support. Or no ?

      Cocktail has slightly better automatic recovery, but slightly less flexible
      (if I recall right), much of what cocktail does you can do with antlr.

      The generated code from ell is pretty good, since they started as a C code
      generator they used a different solution for the exception usage hack in
      ANTLR.

      The free version does not do backtracking and is strict LL(1) That is a
      bother!

      To some extent you could use ell and lalr at the same time. lalr supports
      nice tracebacks of shift/reduce conflicts (*way* cool).

      Though ANTLR has no commercial support, although some ppl on the list do
      consulting/etc. with respect to that. Before buying I'd do some very good
      testing and evaluating.

      Cheers,

      Ric
      --
      -----+++++*****************************************************+++++++++-------
      ---- Ric Klaren ----- klaren@... ----- +31 53 4893722 ----
      -----+++++*****************************************************+++++++++-------
      Human beings, who are almost unique in having the ability to learn
      from the experience of others, are also remarkable for their apparent
      disinclination to do so. --- Douglas Adams, Last Chance to See
    • Ruslan Zasukhin
      ... I am not going buy Coctail yet :-) Well, I have read article of Terr 1800 words ... and now I better understand how work LL(k) and LR() parser. I must
      Message 2 of 5 , Oct 1, 2001
      • 0 Attachment
        on 10/1/01 16:26, Ric Klaren at klaren@... wrote:

        > The free version does not do backtracking and is strict LL(1) That is a
        > bother!
        >
        > To some extent you could use ell and lalr at the same time. lalr supports
        > nice tracebacks of shift/reduce conflicts (*way* cool).
        >
        > Though ANTLR has no commercial support, although some ppl on the list do
        > consulting/etc. with respect to that. Before buying I'd do some very good
        > testing and evaluating.

        I am not going buy Coctail yet :-)

        Well, I have read article of Terr "1800 words ..."
        and now I better understand how work LL(k) and LR() parser.
        I must say I prefer LL(k) way.

        Ric, you have point that author of Coctail have prove that LL(1) parser will
        be faster of LR. I totally agree. This is obvious in fact...if take in
        account that LR parser must meet input against EACH rule each time...

        It looks for me that better keep grammar and parser as LL(1),
        and avoid using of it as LL(2).

        Am I right that we always can use left factoring to modify some rules from
        LL(2) to LL(1) grammar ?

        ---------------
        May be only thing to really improve in ATLR, as you have mention -- scanner.
        FLEX is better.
        REX is even 4 times faster of FLEX.

        Ric, I wonder that you say that scanner is bad because is used the same
        codegenerator as in parser. I see in code generator that is used

        if(state == Lex)
        if(state == parser)
        if(state == treewalker)

        So having this we still can not get good scanner ?

        --
        Best regards,
        Ruslan Zasukhin

        -------------------------
        Paradigma.

        e-mail: ruslan@...
        web : http://www.paradigmasoft.com

        To subscribe to the Valentina mail list
        send a letter to valentina-on@...
      • Ric Klaren
        ... Mwoch LL(2) isn t bad.. predicates are bad every ( ) = ( ) introduces backtracking. And that is really expensive. With k=2 you can catch a lot. If you do
        Message 3 of 5 , Oct 1, 2001
        • 0 Attachment
          On Mon, Oct 01, 2001 at 07:43:11PM +0300, Ruslan Zasukhin wrote:
          > It looks for me that better keep grammar and parser as LL(1),
          > and avoid using of it as LL(2).

          Mwoch LL(2) isn't bad.. predicates are bad every ( ) => ( ) introduces
          backtracking. And that is really expensive. With k=2 you can catch a lot.
          If you do the factoring of your grammar religiously then you can circumvent
          also a lot of backtracking at the expense of readability of your grammar
          (in general).

          > Am I right that we always can use left factoring to modify some rules from
          > LL(2) to LL(1) grammar ?

          Guess so.

          > May be only thing to really improve in ATLR, as you have mention -- scanner.
          > FLEX is better.

          I don't have any hard figures but I suspect it is better. I even recall
          some posts in the past that said that flex was faster.

          > Ric, I wonder that you say that scanner is bad because is used the same
          > codegenerator as in parser. I see in code generator that is used
          >
          > if(state == Lex)
          > if(state == parser)
          > if(state == treewalker)
          >
          > So having this we still can not get good scanner ?

          We can have better codegen, but probably at the expense of some flexibility.
          Also the codegenerator becomes more and more draconian to look at. I'd
          prefer some rewriting...

          Ric
          --
          -----+++++*****************************************************+++++++++-------
          ---- Ric Klaren ----- klaren@... ----- +31 53 4893722 ----
          -----+++++*****************************************************+++++++++-------
          Why don't we just invite them to dinner and massacre them all when they're
          drunk? You heard the man. There's seven hundred thousand of them. Ah? ..
          So it'd have to be something simple with pasta, then.
          From: Interesting Times by Terry Pratchet
        Your message has been successfully submitted and would be delivered to recipients shortly.