diff options
Diffstat (limited to 'src/pre.l')
-rw-r--r-- | src/pre.l | 29 |
1 files changed, 25 insertions, 4 deletions
@@ -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>"/*" |