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

Re: C++: Anyone tried to hack up a Verilog grammar?

Expand Messages
  • clinton_olsen@yahoo.com
    ... Are you speaking of the flexLexer example in the distribution? I m not against using the ANTLR lexer, but I am also concerned about performance. With re2c
    Message 1 of 4 , Jun 11, 2001
    • 0 Attachment
      --- In antlr-interest@y..., Ric Klaren <klaren@c...> wrote:
      >
      > With a bit of luck you can adapt the antlr/flex example in C++ to
      > re2c. That way you don't have to make a new scanner. And if you're
      > used to more traditional scanners then the scanners from antlr take
      > some time to get the hang of.

      Are you speaking of the flexLexer example in the distribution?

      I'm not against using the ANTLR lexer, but I am also concerned about
      performance. With re2c I can track line/column information for any
      token I return to the parser. And this is just as fast as any
      flex-generated scanner that I've used (which can only tracks lines).
      I seem to recall some gripes about column information tracking being
      painful in ANTLR. Is this still the case?

      > Ian Kaplan got some nice C++ info's.
      >
      > http://www.bearcave.com/software/antlr/index.html

      He seemed to identify quite a few problems using ANTLR for his
      application. A lot of them refer to making custom ASTs to have ANTLR
      walk and memory allocation issues (C++ delete() deficiency?). How
      much of this has been fixed in your development version?

      Thanks,

      -Clint
    • Ric Klaren
      ... Yup. ... You d probably want to stick with re2c then. Or compare a ANTLR version to the re2c one to be on the sure side. ... Column info s are currently
      Message 2 of 4 , Jun 13, 2001
      • 0 Attachment
        On Tue, Jun 12, 2001 at 12:57:57AM -0000, clinton_olsen@... wrote:
        > > With a bit of luck you can adapt the antlr/flex example in C++ to
        > > re2c. That way you don't have to make a new scanner. And if you're
        > > used to more traditional scanners then the scanners from antlr take
        > > some time to get the hang of.
        >
        > Are you speaking of the flexLexer example in the distribution?

        Yup.

        > I'm not against using the ANTLR lexer, but I am also concerned about
        > performance.

        You'd probably want to stick with re2c then. Or compare a ANTLR version to
        the re2c one to be on the sure side.

        > I seem to recall some gripes about column information tracking being
        > painful in ANTLR. Is this still the case?

        Column info's are currently tracked per default.

        > He seemed to identify quite a few problems using ANTLR for his
        > application. A lot of them refer to making custom ASTs to have ANTLR walk
        > and memory allocation issues (C++ delete() deficiency?). How much of this
        > has been fixed in your development version?

        In C++ you have to subclass from the ANTLR AST class hierarchy. So you
        cannot have your own custom thing (well you can but you have to make sure
        that it's compatible with the codegenerator).

        Memory management is also forced upon you, the AST and token class use a
        reference counting mechanism. You are basicallly stuck with that. When
        doing tree transformation and building it's not that unconvenient to have
        reference counting, since keeping track of stuff you have to delete is a
        pain in that kind of code. Although you could do the same with a custom
        allocator and doing garbage collection after you got the tree (this is not
        present in ANTLR).

        The tree building syntax of antlr... well opinions differ. I think it's not
        that bad, although some oddities/bugs/missing warnings are present. As with
        anything antlr does reading the generated code is a good way to track
        things down.

        Ian's remarks about fragmenting rules I don't follow quite, you can indeed
        guide tree construction by changing your grammar but you can also do it by
        some tactically placed custom AST generation statements (and carry some
        bits of AST around in inherited/synthesized attributes). Or use another
        pass that rewrites the tree to something more convenient.

        To sum it up: it depends on what you try to do. In many cases the
        functionality ANTLR provides is quite suffcient. And in most cases you can
        do your own 'thing' if ANTLR's 'thing' isn't what you want.

        Cheers,

        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.