Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#107 Wrong C99 comment in A.4.3

2.5.35
open
nobody
5
2012-08-02
2009-07-03
Ronan Keryell
No

The example shown in appendix "A.4.3 Quoted Constructs" about C99 Comment is wrong:
("/*"([^*]|"*"[^/])*"*/")|("/"(\\\n)*"/"[^\n]*)

I've tried it in our PIPS compile project ( http://freia.enstb.org/pips ) but it fails on some codes from the SPEC2006.
For example it does not match /***/

Here is the new regex I changed to have things working:
("/*"([^*]|("*"+[^/*]))*"*"+"/")|("//"("\\\n"|[^\n])*"\n"?)

Discussion

  • Thanks for the report. First of all, I agree that "/***/" should be matched, but isn't. I have to think a bit more about your solution.

    Your change to the "//"-style comments is wrong though:

    | /\ | / comment

    is a valid comment in C99 and - as mentioned in flex's documentation - does not include the trailing newline; cf. http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf, section 6.4.9. Maybe we should include a link to the standard :-).

     
    • assigned_to: nobody --> scfc_de
    • status: open --> open-accepted
     
  • Will Estes
    Will Estes
    2012-08-02

    • assigned_to: scfc_de --> nobody
    • status: open-accepted --> open