-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviews.m5sim.org/r/841/#review1492
-----------------------------------------------------------


I did some searching and these look promising, although I haven't tested them:
comment_re = re.compile(
    r'(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?',
    re.DOTALL | re.MULTILINE
)

or 

def comment_remover(text):
    def replacer(match):
        s = match.group(0)
        if s.startswith('/'):
            return ""
        else:
            return s
    pattern = re.compile(
        r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
        re.DOTALL | re.MULTILINE
    )
    return re.sub(pattern, replacer, text)


- Ali


On 2011-09-05 22:34:45, Gabe Black wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviews.m5sim.org/r/841/
> -----------------------------------------------------------
> 
> (Updated 2011-09-05 22:34:45)
> 
> 
> Review request for Default, Ali Saidi, Gabe Black, Steve Reinhardt, and 
> Nathan Binkert.
> 
> 
> Summary
> -------
> 
> ISA parser: Match /* */ and // style comments.
> 
> Comments should not be scanned for operands, and we should look for both /* */
> style and // style. The regular expression is still not quite right because it
> doesn't handle comments in strings, but it's closer.
> 
> 
> Diffs
> -----
> 
>   src/arch/isa_parser.py 1f95c9a0bb2f 
> 
> Diff: http://reviews.m5sim.org/r/841/diff
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Gabe
> 
>

_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to