summaryrefslogtreecommitdiffstats
path: root/src/pre.l
diff options
context:
space:
mode:
Diffstat (limited to 'src/pre.l')
-rw-r--r--src/pre.l29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/pre.l b/src/pre.l
index 784c8b2..a5ceb83 100644
--- a/src/pre.l
+++ b/src/pre.l
@@ -131,7 +131,7 @@ static void setFileName(const char *name)
//printf("setFileName(%s) g_yyFileName=%s g_yyFileDef=%p\n",
// name,g_yyFileName.data(),g_yyFileDef);
if (g_yyFileDef && g_yyFileDef->isReference()) g_yyFileDef=0;
- g_insideCS = g_yyFileName.right(3)==".cs";
+ g_insideCS = getLanguageFromFileName(g_yyFileName)==SrcLangExt_CSharp;
}
static void incrLevel()
@@ -1365,6 +1365,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
%x Command
%x SkipCommand
%x SkipLine
+%x SkipString
%x CopyLine
%x CopyString
%x Include
@@ -1822,13 +1823,17 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
BEGIN(SkipLine);
}
<SkipCommand>.
-<SkipLine>[^/\n]+
+<SkipLine>[^'"/\n]+
+<SkipLine>{CHARLIT} { }
+<SkipLine>\" {
+ BEGIN(SkipString);
+ }
<SkipLine>.
-<SkipLine,SkipCommand,SkipCPPBlock>"//"[^\n]* {
+<SkipLine,SkipCommand,SkipCPPBlock,SkipString>"//"[^\n]* {
g_lastCPPContext=YY_START;
BEGIN(RemoveCPPComment);
}
-<SkipLine,SkipCommand,SkipCPPBlock>"/*"/[^\n]* {
+<SkipLine,SkipCommand,SkipCPPBlock,SkipString>"/*"/[^\n]* {
g_lastCContext=YY_START;
BEGIN(RemoveCComment);
}
@@ -1837,6 +1842,12 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
g_yyLineNr++;
BEGIN(SkipCPPBlock);
}
+<SkipString>[^"\\\n]+ { }
+<SkipString>\\. { }
+<SkipString>\" {
+ BEGIN(SkipLine);
+ }
+<SkipString>. { }
<IncludeID>{ID}{B}*/"(" {
g_nospaces=TRUE;
g_roundCount=0;
@@ -2104,6 +2115,16 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
g_defLitText+=yytext;
g_defText+=' ';
}
+<RemoveCComment>"*/"{B}*"#" { // see bug 594021 for a usecase for this rule
+ if (g_lastCContext==SkipCPPBlock)
+ {
+ BEGIN(SkipCommand);
+ }
+ else
+ {
+ REJECT;
+ }
+ }
<RemoveCComment>"*/" { BEGIN(g_lastCContext); }
<RemoveCComment>"//"
<RemoveCComment>"/*"