From 22ce4672811cc5e2718e7b2f2260e68d1e2737a5 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sat, 12 Oct 2013 23:02:43 +0200 Subject: Bug 709526 - C++ parsing problem with operators <<, <, >, >> inside templates --- src/defargs.l | 29 +++++++++++++++++++++++++++++ src/scanner.l | 7 +++++++ 2 files changed, 36 insertions(+) diff --git a/src/defargs.l b/src/defargs.l index fa945f6..6d6136a 100644 --- a/src/defargs.l +++ b/src/defargs.l @@ -212,6 +212,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" else // yytext=='<' { g_argSharpCount=0; + g_argRoundCount=0; BEGIN( CopyArgSharp ); } } @@ -239,6 +240,26 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" if (g_argRoundCount>0) g_argRoundCount--; else BEGIN( g_readArgContext ); } +"<<" { + if (g_argRoundCount>0) + { + *g_copyArgValue += yytext; + } + else + { + REJECT; + } + } +">>" { + if (g_argRoundCount>0) + { + *g_copyArgValue += yytext; + } + else + { + REJECT; + } + } "<" { g_argSharpCount++; *g_copyArgValue += *yytext; @@ -248,6 +269,14 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" if (g_argSharpCount>0) g_argSharpCount--; else BEGIN( g_readArgContext ); } +"(" { + g_argRoundCount++; + *g_copyArgValue += *yytext; + } +")" { + g_argRoundCount--; + *g_copyArgValue += *yytext; + } "{" { g_argCurlyCount++; *g_copyArgValue += *yytext; diff --git a/src/scanner.l b/src/scanner.l index 113ef03..66ea314 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -4437,6 +4437,13 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) else BEGIN( lastCopyArgContext ); } +"(" { + *copyArgString+=*yytext; + fullArgString+=*yytext; + argRoundCount=0; + lastCopyArgContext = YY_START; + BEGIN( CopyArgRound ); + } "<" { argSharpCount++; //printf("argSharpCount++=%d copy\n",argSharpCount); -- cgit v0.12