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

Advice requested: multiple passes vs. subclassing

Expand Messages
  • Richard Clark
    I have an architectural question re: parser reusability. I have a parser for Javascript / Actionscript and am deriving a couple of products from it -- a
    Message 1 of 1 , Jul 31, 2004
    • 0 Attachment
      I have an architectural question re: parser reusability.

      I have a parser for Javascript / Actionscript and am deriving a couple
      of products from it -- a Javadoc-style compiler and a Eclipse editor
      plugin with "lint" functionality.

      The parser generates a straightforward AST, and I've been using a tree
      parser on the result to recognize and rename ordinary function
      declarations into constructors and methods. However, when I want to do
      Javadoc, I may actually need to post-process with two tree parsers --
      one to rewrite some of the nodes, the other to assemble the Javadoc
      output.

      I've thought of a way to do this in one parser, but I don't want to
      modify the generic language parser as that kills reusability. So, I'm
      asking your advice: which of these would you do, given the choice:
      1) Alter the base parser for each application
      2) Subclass the base parser and roll the changes into the subclass
      3) Go ahead with a generic parser and apply transforms to the resulting
      trees?

      I'd appreciate hearing from the more experienced folks here :)

      Thanks,

      ...Richard
    Your message has been successfully submitted and would be delivered to recipients shortly.