mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Directly support C style comments in tblgen, but allow them to actually nest
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7429 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
61972242f3
commit
d33b8db415
@ -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(); }
|
||||
|
||||
%%
|
||||
|
@ -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(); }
|
||||
|
||||
%%
|
||||
|
Loading…
Reference in New Issue
Block a user