• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Remove /* this is a comment line */ from a file

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 144
  • Views 19415
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Remove /* this is a comment line */ from a file

Charley Chen
Charley Chen over 14 years ago

Dear All,

I wnat to remove a file which each line has  /*  a bc  d */  .

I use infile & outfile command.

How to do it ?

 

Thank you,

Charley

 

  • Cancel
  • Charley Chen
    Charley Chen over 14 years ago

    /*  ..... */  is a comment , don't care what inside the /*  */.

    Just need to check whether has a /*   */ in each ine.

     

    Thank you,

    Charley

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 14 years ago

     Hi Charley,

    More details in the question might lead to a better answer, and maybe even a correct answer.  I'm just guessing here.
    This might not be the best approach, but here's a possible example:

    fp = infile("somefile")
      => port:"somefile"
    gets(line fp)
      => "/* this is a comment, ignore */"
    rexMatchp("/*[^*/]**/" line)
      => t   so ignore that line
    gets(line2 fp)
      => "thisShouldBeSKILL='syntax"
    rexMatchp("/*[^*/]**/" line2)
      => nil   do not ignore this line
    

    If using IC61x there are Perl compatible regular expression functions starting with the prefix pcre - these give the full capability of regular expressions and may be easier to work with than the "rex" prefix functions.

    Anyway, I hope this helps? 

    Regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Charley Chen
    Charley Chen over 14 years ago

    Hi Lawrence,

     I works. That's what I need.

    Could you explain why the pattern should be "/*[^*/]**/" ?

     

    Thank you very much,

    Charley

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 14 years ago
    Hi Charley,

    It's an attempt to limit the fact that wildcards match as much as possible - so if you had /* something */ */ the pattern will match up to the first */ . If your pattern was "/\\**\\*/" then it would match up to the second */ (which is not the extent of the comment).

    Note I escaped the * which are part of the comment - can't see Lawrence's post right now, but in the pattern you reference below that hasn't been done, so it would also match "/////blah blah /" which isn't right. It also wouldn't match "/* test * comment */" or "/* test./ comment */" because the [^*/] bit will prevent it matching either of the / or * characters within the comment. It also won't match multi-line comments.

    This could almost certainly be handled with the more advanced pattern matching available in the pcre functions, but if you're merely looking for the presence of a comment, it is probably sufficient to just search for "/\\*" - i.e. the start of the comment.

    Regards,

    Andrew
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Charley Chen
    Charley Chen over 14 years ago

    Hi Andrew,

    Thank you for explanation . It's very helpful.

    Charley

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • mbracht
    mbracht over 7 years ago in reply to Andrew Beckett

    Andrew, pcreCompile() takes an optional second argument to define all kinds of options - those options in turn need to be generated with pcreGenCompileOptBits(..)
    So to turn on non-greedy matching you need to go like that:

    (pcreCompile <whatever pattern> (pcreGenCompileOptBits ?ungreedy t))

    Max

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information