Using perl to parse verilog

Discussion in 'Perl Misc' started by wolfpack307@yahoo.com, Nov 27, 2006.

  1. Guest

    Hi all,

    I am trying to use perl to parse a verilog file.

    In trying to parse block comments, I am using am doing

    while ($verilog=~s/(.*)\/\*.*(.*)/$1$2/) {}

    This code does work for code that looks like this

    /* comments
    comments
    comments */

    However, if an codes look like the following (which is syntactically
    correct in verilog), the script just hangs.

    /* comments
    /* comments
    comments */

    Would appreciate some advice.
    Thanks in advance.

    shuteng
     
    , Nov 27, 2006
    #1
    1. Advertising

  2. Guest

    typo error
    while ($verilog=~s/(.*)\/\*.*\*\/(.*)/$1$2/s) {}

    wrote:
    > Hi all,
    >
    > I am trying to use perl to parse a verilog file.
    >
    > In trying to parse block comments, I am using am doing
    >
    > while ($verilog=~s/(.*)\/\*.*(.*)/$1$2/) {}
    >
    > This code does work for code that looks like this
    >
    > /* comments
    > comments
    > comments */
    >
    > However, if an codes look like the following (which is syntactically
    > correct in verilog), the script just hangs.
    >
    > /* comments
    > /* comments
    > comments */
    >
    > Would appreciate some advice.
    > Thanks in advance.
    >
    > shuteng
     
    , Nov 27, 2006
    #2
    1. Advertising

  3. J. Gleixner Guest

    wrote:

    >> I am trying to use perl to parse a verilog file.
    >>
    >> In trying to parse block comments, I am using am doing

    [...]
    >> Would appreciate some advice.


    Check the FAQ.

    perldoc -q "How do I use a regular expression to strip C style comments
    from a file"
     
    J. Gleixner, Nov 27, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. adhithi

    Perl and VHDL/Verilog

    adhithi, May 22, 2004, in forum: Perl
    Replies:
    0
    Views:
    500
    adhithi
    May 22, 2004
  2. Replies:
    19
    Views:
    1,133
    Daniel Vallstrom
    Mar 15, 2005
  3. 7stud --

    optparse: parse v. parse! ??

    7stud --, Feb 20, 2008, in forum: Ruby
    Replies:
    3
    Views:
    189
    7stud --
    Feb 20, 2008
  4. Fei
    Replies:
    1
    Views:
    235
  5. Shenli

    Call Perl in Verilog or SV?

    Shenli, Jan 11, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    184
Loading...

Share This Page