[llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l
Chris Lattner
lattner at cs.uiuc.edu
Wed Jul 30 14:40:01 PDT 2003
Changes in directory llvm/utils/TableGen:
FileLexer.l updated: 1.1 -> 1.2
---
Log message:
Directly support C style comments in tblgen, but allow them to actually nest
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileLexer.l
diff -u llvm/utils/TableGen/FileLexer.l:1.1 llvm/utils/TableGen/FileLexer.l:1.2
--- llvm/utils/TableGen/FileLexer.l:1.1 Sun Dec 1 19:23:04 2002
+++ llvm/utils/TableGen/FileLexer.l Wed Jul 30 14:39:36 2003
@@ -16,6 +16,7 @@
%option noreject
%option noyymore
+%x comment
%{
#include "Record.h"
@@ -29,6 +30,8 @@
return strtol(Str, 0, 0);
}
+static int CommentDepth = 0;
+
%}
Comment \/\/.*
@@ -63,4 +66,14 @@
[ \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(); }
+
%%
More information about the llvm-commits
mailing list