Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Source code comment line remove...

kevingpokevingpo Posts: 23Member

Does anyone know of a script or tool to remove comments from two types of files:

1. ASP file with embedded Javascript & HTML
2. XSL file with embedded Javascript & HTML

So basically it's removal of


// Javascript style comments
/* Javascript style comments */
' VBScript (ASP) style comments



A good script/tool would be one that strips all source code of comments. Then another script/tool that reapplies the comments. So that means storing the comments and line numbers in another file possibly.

Comments

  • CyGuyCyGuy Posts: 312Member
    Why not write one?????
    here are the basics:

    main loop that repeats UNTIL EOF (end of file) or file size is reached.
    a loop inside main loop that repeats UNTIL EOL (end of line) with a line counter.

    within that you should have conditions with loops to read characters into a string.

    example - if (doc.charAt(position,position + 1) == '/') && (doc.charAt(position + 1,position + 2) == '/') { do { readString( 'doubleSlash', position + 3 ); } while (!EOL) }

    Of course the doc string is the source, and you can change the if to a case and read the character before it, additionally you will need to make conditions for the <> and /**/ remarks, which would be loops too, unless you use the pattern matching features in JavaScript.

    :
    : A good script/tool would be one that strips all source code of comments. Then another script/tool that reapplies the comments. So that means storing the comments and line numbers in another file possibly.
    :

    A script is a programm / a tool is an application. you could have routines to take apart / put together / verify and qualify any source
    [green]WHAT you;see_is_what=you.get;[/green]
    -Russ aka DangeRuss

  • anthrax11anthrax11 Posts: 511Member
    : Why not write one?????
    : here are the basics:
    :
    : main loop that repeats UNTIL EOF (end of file) or file size is reached.
    : a loop inside main loop that repeats UNTIL EOL (end of line) with a line counter.
    :
    : within that you should have conditions with loops to read characters into a string.
    :
    : example - if (doc.charAt(position,position + 1) == '/') && (doc.charAt(position + 1,position + 2) == '/') { do { readString( 'doubleSlash', position + 3 ); } while (!EOL) }
    :
    : Of course the doc string is the source, and you can change the if to a case and read the character before it, additionally you will need to make conditions for the <> and /**/ remarks, which would be loops too, unless you use the pattern matching features in JavaScript.


    [blue]As a matter of fact, I've been working on it since this post was initially posted. But I've ran into some bugs, so I'll need some time to get it done:
    www.hot.ee/anthrax11/comments.zip
    [/blue]
Sign In or Register to comment.