Related articles |
---|
[3 earlier articles] |
Re: How to determine if a given line is a C/C++ comment nicola.musatti@gmail.com (Nicola Musatti) (2006-08-10) |
Re: How to determine if a given line is a C/C++ comment johnmillaway@yahoo.com (John Millaway) (2006-08-10) |
Re: How to determine if a given line is a C/C++ comment mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2006-08-12) |
Re: How to determine if a given line is a C/C++ comment listas@nicolasb.com.ar (Nico) (2006-08-12) |
Re: How to determine if a given line is a C/C++ comment gah@ugcs.caltech.edu (glen herrmannsfeldt) (2006-08-14) |
Re: How to determine if a given line is a C/C++ comment nicola.musatti@gmail.com (Nicola Musatti) (2006-08-18) |
Re: How to determine if a given line is a C/C++ comment zebedee@zebedee.net (zebedee) (2006-09-12) |
From: | zebedee <zebedee@zebedee.net> |
Newsgroups: | comp.compilers |
Date: | 12 Sep 2006 20:02:19 -0400 |
Organization: | Compilers Central |
References: | 06-08-042 06-08-054 |
Keywords: | C, lex |
Posted-Date: | 12 Sep 2006 20:02:19 EDT |
John Millaway wrote:
> We added a few common regexps to an appendix in the latest flex
> manual, including C99 strings and comments, only because we saw so
> many scanners doing it wrong.
[...]
> C99 String Literal
>
> `L?\"([^\"\\\n]|(\\['\"?\\abfnrtv])|(\\([0123456]{1,3}))|(\\x[[:xdigit:]]+)|(\\u([[:xdigit:]]{4}))|(\\U([[:xdigit:]]{8})))*\"'
>
> C99 Comment
> `("/*"([^*]|"*"[^/])*"*/")|("/"(\\\n)*"/"[^\n]*)'
>
> Note that in C99, a `//'-style comment may be split across lines,
> and, contrary to popular belief, does not include the trailing
> `\n' character.
>
These are only correct if you ignore trigraphs and escaped newlines. C
and C++ were not designed for quick and easy analysis.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.