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

Not able to preserve formatting while saving the file

Expand Messages
  • swift_turtle_male
    Guys, Basically I have made a program, which will analyze the java code and suggest optimizations using the antlr tree structure. Now I wanted to expand the
    Message 1 of 3 , Jun 1, 2004
      Guys,
      Basically I have made a program, which will analyze the java code and
      suggest optimizations using the antlr tree structure. Now I wanted to
      expand the capabilities of automatically optimizing the existing java
      code, by changing the tree structure. Now Im able to make the
      modifications and save the file, but then I have got a major issue,
      wherein Im not able to preserve the original formatting of the java
      code. Can anyone help me with that ?

      Regards,
      Chunduru Anil Kumar
    • Terence Parr
      Hi :) Please see the article on TokenStreamRewriteEngine at the antlr site. :) Terence ... -- Professor Comp. Sci., University of San Francisco Creator, ANTLR
      Message 2 of 3 , Jun 1, 2004
        Hi :) Please see the article on TokenStreamRewriteEngine at the antlr
        site. :)

        Terence

        On Jun 1, 2004, at 3:33 AM, swift_turtle_male wrote:

        > Guys,
        > Basically I have made a program, which will analyze the java code and
        > suggest optimizations using the antlr tree structure. Now I wanted to
        > expand the capabilities of automatically optimizing the existing java
        > code, by changing the tree structure. Now Im able to make the
        > modifications and save the file, but then I have got a major issue,
        > wherein Im not able to preserve the original formatting of the java
        > code. Can anyone help me with that ?
        --
        Professor Comp. Sci., University of San Francisco
        Creator, ANTLR Parser Generator, http://www.antlr.org
        Cofounder, http://www.jguru.com
        Cofounder, http://www.knowspam.net enjoy email again!
        Cofounder, http://www.peerscope.com pure link sharing
      • Monty Zukowski
        This is not the easiest thing to do. Ter s answer using the TokenStreamRewriteEngine assumes no trees, just a parser pass. There is another article on
        Message 3 of 3 , Jun 1, 2004
          This is not the easiest thing to do. Ter's answer using the
          TokenStreamRewriteEngine assumes no trees, just a parser pass. There
          is another article on preserving whitespace on antlr.org using hidden
          token streams and attaching to the tokens.

          In the C grammar I think I recorded the column and line info and would
          add in the indentation and lines as needed when I was emitting a token
          that wasn't at the current position.

          Monty

          On Jun 1, 2004, at 3:33 AM, swift_turtle_male wrote:

          > Guys,
          > Basically I have made a program, which will analyze the java code and
          > suggest optimizations using the antlr tree structure. Now I wanted to
          > expand the capabilities of automatically optimizing the existing java
          > code, by changing the tree structure. Now Im able to make the
          > modifications and save the file, but then I have got a major issue,
          > wherein Im not able to preserve the original formatting of the java
          > code. Can anyone help me with that ?
          >
          > Regards,
          > Chunduru Anil Kumar
          >
          Monty Zukowski

          ANTLR & Java Consultant -- http://www.codetransform.com
          ANSI C/GCC transformation toolkit --
          http://www.codetransform.com/gcc.html
          Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html
        Your message has been successfully submitted and would be delivered to recipients shortly.