Re: comment removal.

new topic     » goto parent     » topic index » view thread      » older message » newer message

CChris wrote:
> 
> [snipped]
> 
> > > 
> > > Origionaly I had to remove "//" comments from hundreds and thousands of
> > > lines
> > > of sourcecode, and that piece of code did the trick.
> > > 
> > > I thought about adding command line and prompt support and checking for
> > > various
> > > other cases but there was no need to do that at the time.
> > > 
> > > The code snippet did it's job and then got filed away, and probably never
> > > to
> > > be used again by me.
> > > 
> > > Anyone is welcome to modify or complete the code for there needs. If you
> > > do,
> > > I ask that you please share it with others.
> > 
> > Ok...
> > After removing the quotes around INPUT and OUTPUT, since they cause a bad
> >  file number (-1) to be reported, I fed a
> >  file containing
> > 
> > }}}
<eucode>
> > sequence s
> > s="this line has -- inside it"
> > </eucode>
{{{

> >  to the code in the original post.
> > 
> > The output file had:
> > }}}
<eucode>
> > sequence s
> > s="this line has 
> > </eucode>
{{{

> > , which I expected from reading the code.
> > 
> > file 1 compiles correctly, file 2 bombs out. This is not expected when
> >  changing/adding/removing comments.
> > 
> > I remember having trouble writing an uncomment function for my enhanced
> >  version of Visual Euphoria (Joe aka spent_memory). I'll dig up the code 
> > and post it. It is definitively longer, but does the job. This is because 
> > not only you have to take care of (multiple) string(s) inside any given
> > line,
> >  but locating where they start/end is made trickier if escaped double quotes
> >  are there as well.
> > 
> > There are two options basically:
> > 1/locate and mask the strings which are not inside a comment, then use
> >  match(COMMENT,line) and truncate original line;
> > 2/ work as scanner.e does, using a flag to detect whether it is inside a
> >  string or not, plowing along the line and truncating it when COMMENT is
> >  found outside a string. 
> > I never investigated which approach is faster.
> > 
> > Next exercise: also auto uncomment /*...*/ embedded C comments smile
> > 
> > CChris
> 

Submitted a comment remover. Hopefully, it copes with all cases, and tries
 to be smart and not to generate too many blank lines. Look to nocoment.e.

CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu