help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pattern matching lines starting with double comment characters


From: goncholden
Subject: Re: Pattern matching lines starting with double comment characters
Date: Sat, 25 Feb 2023 14:19:29 +0000

------- Original Message -------
On Sunday, February 26th, 2023 at 2:06 AM, Greg Wooledge <greg@wooledge.org> 
wrote:


> On Sat, Feb 25, 2023 at 11:25:53AM +0000, goncholden via wrote:
> 
> > I want to match lines that start with double comment characters in source 
> > code files.
> > 
> > I am currently using
> > 
> > pn_ere = "^[[:space:]]*([#;!]+|@c|//)[[:space:]]+"
> > 
> > The pattern handles possible spaces at the beginning and end of lines.
> > 
> > But the pattern does not specify double comment characters
> > 
> > Case of ##
> > Case of ;;
> > Case of !!
> 
> 
> And after we help you with THIS, what's next? Triple? Quadruple?
> N-tuple? Another type of comment marker that you previously didn't tell
> us about, that you suddenly discovered the need to handle? Nested comment
> markers from multiple languages? Multi-line comments?

No, just to handle "Two".
 
> This project is completely insane. It's the definition of scope creep.

I can assure you it is completely genius.  But does get complicated. 
It is the reason that the individual parts seem strange as an actual task. 
 
> You CANNOT write a shell script that parses files containing EVERY TYPE
> OF COMMENT MARKER IN THE WORLD simultaneously. You CERTAINLY can't do
> it with a single regular expression.

Am only doing for some languages (c, fortran, shell, elisp).  But if others
want for other languages, then you are right, they would also need to make
additional expressions.
 
> Figure out what your ACTUAL NEEDS are, and then write your program to
> handle those.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]