diff options
-rw-r--r-- | support/tools/TableGen/FileLexer.l | 13 | ||||
-rw-r--r-- | utils/TableGen/FileLexer.l | 13 |
2 files changed, 26 insertions, 0 deletions
diff --git a/support/tools/TableGen/FileLexer.l b/support/tools/TableGen/FileLexer.l index c7e4346c0f..7289ca0bbb 100644 --- a/support/tools/TableGen/FileLexer.l +++ b/support/tools/TableGen/FileLexer.l @@ -16,6 +16,7 @@ %option noreject %option noyymore +%x comment %{ #include "Record.h" @@ -29,6 +30,8 @@ static int ParseInt(const char *Str) { return strtol(Str, 0, 0); } +static int CommentDepth = 0; + %} Comment \/\/.* @@ -63,4 +66,14 @@ in { return IN; } [ \t\n]+ { /* Ignore whitespace */ } . { return Filetext[0]; } + + +"/*" { BEGIN(comment); CommentDepth++; } +<comment>[^*/]* /* eat anything that's not a '*' or '/' */ +<comment>"*"+[^*/]* /* eat up '*'s not followed by '/'s */ +<comment>"/*" { ++CommentDepth; } +<comment>"/"+[^*]* /* eat up /'s not followed by *'s */ +<comment>"*"+"/" { if (!--CommentDepth) { BEGIN(INITIAL); } } +<comment><<EOF>> { fprintf(stderr, "Unterminated comment!\n"); abort(); } + %% diff --git a/utils/TableGen/FileLexer.l b/utils/TableGen/FileLexer.l index c7e4346c0f..7289ca0bbb 100644 --- a/utils/TableGen/FileLexer.l +++ b/utils/TableGen/FileLexer.l @@ -16,6 +16,7 @@ %option noreject %option noyymore +%x comment %{ #include "Record.h" @@ -29,6 +30,8 @@ static int ParseInt(const char *Str) { return strtol(Str, 0, 0); } +static int CommentDepth = 0; + %} Comment \/\/.* @@ -63,4 +66,14 @@ in { return IN; } [ \t\n]+ { /* Ignore whitespace */ } . { return Filetext[0]; } + + +"/*" { BEGIN(comment); CommentDepth++; } +<comment>[^*/]* /* eat anything that's not a '*' or '/' */ +<comment>"*"+[^*/]* /* eat up '*'s not followed by '/'s */ +<comment>"/*" { ++CommentDepth; } +<comment>"/"+[^*]* /* eat up /'s not followed by *'s */ +<comment>"*"+"/" { if (!--CommentDepth) { BEGIN(INITIAL); } } +<comment><<EOF>> { fprintf(stderr, "Unterminated comment!\n"); abort(); } + %% |