To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.pbforthOpen lugnet.robotics.rcx.pbforth in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / pbFORTH / 225
224  |  226
Subject: 
RE: Whitespace and comment remover in perl
Newsgroups: 
lugnet.robotics.rcx.pbforth
Date: 
Wed, 15 Dec 1999 16:01:53 GMT
Viewed: 
1232 times
  
Carsten wrote:

Your statement of the LONGEST match may be correct for TCL but not for
perl!
look at the second regexp:
the '?' inside means expand to the smallest match ( this is a perl
specialty i think)
the only thing is, if you nest comments like

( comment ( comment on comment ) )

then the very last ')' will not be removed.

OOPS! I guess that those pesky regexps are not for the faint of heart. The
new Tcl standard also allows you to specify less greedy regexps.

The nesting of comments as you suggest is illegal FORTH anyways. It only
specifies that a close comment is the first ")" token which means it must
be surrounded by whitespace, so your non-greedy match is correct FORTH!!!

You are right, there are restrictions in this little script:
1. if you have a bracket comment spanning more than one line or when a
quoted area span more than one line,
   then the script must fail, because it works on a line by line basis.
2. duplicate whitespaces between words are not removed.

Brackets can't span more than one line. A CR terminates the comment.

Oh well, at least we're not really struggling with building a real compiler.

By the way, there is an XMODEM utility for the Palm, but no RCX serial port
uploader yet....

Cheers,

Ralph Hempel - P.Eng

--------------------------------------------------------
Check out pbFORTH for LEGO Mindstorms at:
<http://www.hempeldesigngroup.com/lego/pbFORTH>
--------------------------------------------------------
Reply to:      rhempel at bmts dot com
--------------------------------------------------------



Message has 1 Reply:
  Re: Whitespace and comment remover in perl
 
(...) :) (...) unfortunately i've broken my palm III by stepping on it. (25 years ago, 15-Dec-99, to lugnet.robotics.rcx.pbforth)

Message is in Reply To:
  Re: Whitespace and comment remover in perl
 
(...) Your statement of the LONGEST match may be correct for TCL but not for perl! look at the second regexp: the '?' inside means expand to the smallest match ( this is a perl specialty i think) the only thing is, if you nest comments like ( (...) (25 years ago, 15-Dec-99, to lugnet.robotics.rcx.pbforth)

5 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR