Index: src/code.l
===================================================================
RCS file: /cvsroot/doxygen/src/code.l,v
retrieving revision 1.137
diff -u -5 -r1.137 code.l
--- src/code.l	4 Oct 2006 20:28:40 -0000	1.137
+++ src/code.l	23 Oct 2006 19:54:20 -0000
@@ -93,10 +93,12 @@
 
 static int	     g_bracketCount = 0;
 static int	     g_curlyCount   = 0;
 static int	     g_sharpCount   = 0;
 static bool          g_inFunctionTryBlock = FALSE;
+static bool          g_TemplCastInFuncCall = FALSE;
+static bool          g_inForEachExpression = FALSE;
 
 static int	     g_lastSpecialCContext;
 static int           g_lastStringContext;
 static int           g_lastSkipCppContext;
 static int           g_lastVerbStringContext;
@@ -1622,13 +1624,14 @@
 SCOPENAME "$"?(({ID}?{BN}*"::"{BN}*)*)((~{BN}*)?{ID})
 TEMPLIST "<"[^\"\}\{\(\)\/\n\>]*">"
 SCOPETNAME ((({ID}{TEMPLIST}?){BN}*"::"{BN}*)*)((~{BN}*)?{ID})
 SCOPEPREFIX ({ID}{TEMPLIST}?{BN}*"::"{BN}*)+
 KEYWORD_OBJC ("@public"|"@private"|"@protected"|"@class"|"@implementation"|"@interface"|"@end"|"@selector"|"@protocol")
-KEYWORD ("asm"|"auto"|"class"|"const"|"const_cast"|"delete"|"dynamic_cast"|"enum"|"explicit"|"extern"|"false"|"friend"|"inline"|"mutable"|"namespace"|"new"|"operator"|"private"|"protected"|"public"|"register"|"reinterpret_cast"|"sizeof"|"static"|"static_cast"|"struct"|"template"|"this"|"self"|"true"|"typedef"|"typeid"|"typename"|"union"|"using"|"virtual"|"volatile"|"abstract"|"final"|"import"|"synchronized"|"transient"|KEYWORD_OBJC)
-FLOWKW  ("break"|"case"|"catch"|"continue"|"default"|"do"|"else"|"for"|"goto"|"if"|"return"|"switch"|"throw"|"throws"|"try"|"while")
-TYPEKW  ("bool"|"char"|"double"|"float"|"int"|"long"|"short"|"signed"|"unsigned"|"void"|"wchar_t"|"boolean"|"id"|"SEL")
+KEYWORD ("add"|"asm"|"__assume"|"auto"|"class"|"const"|"delete"|"enum"|"explicit"|"extern"|"false"|"friend"|"gcnew"|"gcroot"|"get"|"inline"|"internal"|"mutable"|"namespace"|"new"|"nullptr"|"override"|"operator"|"pin_ptr"|"private"|"protected"|"public"|"raise"|"register"|"remove"|"self"|"set"|"sizeof"|"static"|"struct"|"__super"|"template"|"this"|"true"|"typedef"|"typeid"|"typename"|"union"|"using"|"virtual"|"volatile"|"abstract"|"final"|"import"|"synchronized"|"transient"|KEYWORD_OBJC)
+FLOWKW  ("break"|"case"|"catch"|"continue"|"default"|"do"|"else"|"finally"|"for"|"foreach"|"for each"|"goto"|"if"|"return"|"switch"|"throw"|"throws"|"try"|"while")
+TYPEKW  ("bool"|"char"|"double"|"float"|"int"|"long"|"object"|"short"|"signed"|"unsigned"|"void"|"wchar_t"|"size_t"|"boolean"|"id"|"SEL"|"string")
+CASTKW ("const_cast"|"dynamic_cast"|"reinterpret_cast"|"static_cast")
 CHARLIT   (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^' \\\n]{1,4}"'"))
 ARITHOP "+"|"-"|"/"|"*"|"%"|"--"|"++"
 ASSIGNOP "="|"*="|"/="|"%="|"+="|"-="|"<<="|">>="|"&="|"^="|"|="
 LOGICOP "=="|"!="|">"|"<"|">="|"<="|"&&"|"||"|"!"
 BITOP   "&"|"|"|"^"|"<<"|">>"|"~"
@@ -1648,14 +1651,16 @@
 %x      MemberCall2
 %x      SkipInits
 %x      ClassName
 %x      PackageName
 %x      ClassVar
+%x	CppCliTypeModifierFollowup
 %x      Bases
 %x      SkipSharp
 %x      ReadInclude
 %x      TemplDecl
+%x      TemplCast
 %x	CallEnd
 %x      ObjCMethod
 %x	ObjCParams
 %x	ObjCParamType
 %x      ObjCCall
@@ -1678,11 +1683,24 @@
   					  codifyLines(yytext);
 					  endFontClass();
   					  if (!g_insideTemplate) 
 					    BEGIN( ClassName ); 
 					}
-<Body>("class"|"struct"|"union"|"namespace")[ \t\n]+ { 
+<Body>(("public"|"private"){B}+)?("ref"|"value"|"interface"|"enum"){B}+("class"|"struct") {
+  					  if (g_insideTemplate) REJECT;
+  					  startFontClass("keyword");
+  					  codifyLines(yytext);
+					  endFontClass();
+					  BEGIN( ClassName ); 
+					}
+<Body>"property"|"event"/{BN}*			{ 
+  					  if (g_insideTemplate) REJECT;
+  					  startFontClass("keyword");
+  					  codifyLines(yytext);
+					  endFontClass();
+					}
+<Body>(KEYWORD_CPPCLI_DATATYPE|("partial"{B}+)?"class"|"struct"|"union"|"namespace"){B}+ { 
   					  startFontClass("keyword");
   					  codifyLines(yytext);
 					  endFontClass();
   					  if (!g_insideTemplate) 
 					    BEGIN( ClassName ); 
@@ -1920,16 +1938,21 @@
 <ClassName,ClassVar>";"			{ 
   					  g_code->codify(yytext);
 					  g_searchingForBody=FALSE; 
   					  BEGIN( Body ); 
 					}
-<ClassName,ClassVar>[*&]+       	{
+<ClassName,ClassVar>[*&^%]+       	{
   					  g_type=g_curClassName.copy();
   					  g_name.resize(0);
 					  g_code->codify(yytext);
 					  BEGIN( Body ); // variable of type struct *
 					}
+<ClassName>"__declspec"{B}*"("{B}*{ID}{B}*")"	{
+					  startFontClass("keyword");
+  					  g_code->codify(yytext);
+					  endFontClass();
+					}
 <ClassName>{ID}("::"{ID})*	        {
                                           g_curClassName=yytext;
 					  addType();
 					  generateClassOrGlobalLink(*g_code,yytext);
 					  BEGIN( ClassVar );
@@ -1950,23 +1973,30 @@
   					  codifyLines(yytext);
 					  endFontClass();
 					  g_curClassBases.clear();
   					  BEGIN( Bases ); 
 					}
+<ClassVar>("sealed"|"abstract")/{BN}*(":"|"{") {
+					  //fprintf(stderr,"***** C++/CLI modifier %s on g_curClassName=%s\n",yytext,g_curClassName.data());
+  					  startFontClass("keyword");
+  					  codifyLines(yytext);
+					  endFontClass();
+  					  BEGIN( CppCliTypeModifierFollowup ); 
+					}
 <ClassVar>{ID}				{
   					  g_type = g_curClassName.copy();
 					  g_name = yytext;
 					  g_theVarContext.addVariable(g_type,g_name);
 					  generateClassOrGlobalLink(*g_code,yytext);
   					}
-<ClassName,ClassVar>[ \t\n]*":"[ \t\n]*	{
+<ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*":"{B}*	{
   					  codifyLines(yytext);
 					  g_curClassBases.clear();
   					  BEGIN( Bases ); 
 					}
 <PackageName>[ \t]*";"				|
-<Bases,ClassName,ClassVar>[ \t]*"{"[ \t]*	{
+<Bases,ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*"{"{B}* {
                                           g_theVarContext.pushScope();
   					  g_code->codify(yytext);
 					  g_curlyCount++;
 					  g_inClass=TRUE;
 					  if (YY_START==ClassVar && g_curClassName.isEmpty())
@@ -2124,22 +2154,30 @@
   					  startFontClass("keyword");
   					  codifyLines(yytext);
 					  endFontClass();
   				          g_name.resize(0);g_type.resize(0);
   					}
+<FuncCall>"in"/{BN}*			{
+					  if (!g_inForEachExpression) REJECT;
+  					  startFontClass("keywordflow");
+  					  codifyLines(yytext);
+					  endFontClass();
+  				          g_name.resize(0);g_type.resize(0);
+					}
 <Body>{FLOWKW}/{BN}*"(" 			{
   					  startFontClass("keywordflow");
   					  codifyLines(yytext);
 					  endFontClass();
   				          g_name.resize(0);g_type.resize(0);
+					  g_inForEachExpression = (strcmp(yytext,"for each")==0 || strcmp(yytext, "foreach")==0);
 					  BEGIN(FuncCall);
   					}
 <Body>{FLOWKW}/([^a-z_A-Z0-9]) 		{
   					  startFontClass("keywordflow");
   					  codifyLines(yytext);
 					  endFontClass();
-					  if (g_inFunctionTryBlock && strcmp(yytext,"catch")==0)
+					  if (g_inFunctionTryBlock && (strcmp(yytext,"catch")==0 || strcmp(yytext,"finally")==0))
 					  {
 					    g_inFunctionTryBlock=FALSE;
 					  }
   					}
 <Body>{FLOWKW}/{B}* 			{
@@ -2185,11 +2223,45 @@
 					  if (g_sharpCount<=0)
 					  {
 					    BEGIN(Body);
 					  }
   					}
-<Body>{SCOPENAME}{B}*"<"[^\n\/\-\.\{\"\>]*">"("::"{ID})*/{B}* { // A<T> *pt;
+<TemplCast>">"				{
+  					  startFontClass("keyword");
+  					  codifyLines(yytext);
+					  endFontClass();
+					  if (g_TemplCastInFuncCall)
+					    BEGIN(FuncCall);
+					  else
+					    BEGIN(Body);
+  					}
+<TemplCast>{ID}("::"{ID})*		{
+					  generateClassOrGlobalLink(*g_code,yytext);
+					}
+<TemplCast>("const"|"volatile"){B}*	{
+  					  startFontClass("keyword");
+  					  codifyLines(yytext);
+					  endFontClass();
+					}
+<TemplCast>[*^]*			{
+  					  codifyLines(yytext);
+					}
+<Body>{CASTKW}"<"/[^\n\/\-\.\{\"\>]*">"{BN}*"(" { // static_cast<T>(
+  					  startFontClass("keyword");
+  					  codifyLines(yytext);
+					  endFontClass();
+					  g_TemplCastInFuncCall = FALSE;
+					  BEGIN(TemplCast);
+					}
+<FuncCall>{CASTKW}"<"/[^\n\/\-\.\{\"\>]*">"{BN}*"(" { // static_cast<T>(
+  					  startFontClass("keyword");
+  					  codifyLines(yytext);
+					  endFontClass();
+					  g_TemplCastInFuncCall = TRUE;
+					  BEGIN(TemplCast);
+					}
+<Body,TemplCast>{SCOPENAME}{B}*"<"[^\n\/\-\.\{\"\>]*">"("::"{ID})*/{B}* { // A<T> *pt;
 					  addType();
 					  generateClassOrGlobalLink(*g_code,yytext);
   					  g_name+=yytext; 
 					}
 <Body>{SCOPENAME}/{BN}*[;,)\]]		{ // "int var;" or "var, var2" or "debug(f) macro" 
@@ -2221,10 +2293,11 @@
 					}
 <FuncCall,Body,MemberCall,MemberCall2,SkipInits>\"	{
 					  startFontClass("stringliteral");
   					  g_code->codify(yytext);
   					  g_lastStringContext=YY_START;
+					  g_inForEachExpression = FALSE;
   					  BEGIN( SkipString );
   					}
 <SkipString>[^\"\\\r\n]*		{ 
   					  g_code->codify(yytext);
 					}
@@ -2523,11 +2596,11 @@
 					  g_parmName=yytext; 
   					  startFontClass("keyword");
   					  g_code->codify(yytext);
 					  endFontClass();
 					}
-<MemberCall2,FuncCall,OldStyleArgs>{TYPEKW}/([^a-z_A-Z0-9]) {
+<MemberCall2,FuncCall,OldStyleArgs,TemplCast>{TYPEKW}/([^a-z_A-Z0-9]) {
 					  addParmType();
 					  g_parmName=yytext; 
   					  startFontClass("keywordtype");
   					  g_code->codify(yytext);
 					  endFontClass();
@@ -2544,10 +2617,11 @@
 					  g_parmName=yytext; 
 					  generateClassOrGlobalLink(*g_code,yytext,!g_insideBody);
 					}
 <FuncCall>";"				{ // probably a cast, not a function call
   					  g_code->codify(yytext);
+					  g_inForEachExpression = FALSE;
 					  BEGIN( Body );
   					}
 <MemberCall2,FuncCall>,			{
   					  g_code->codify(yytext);
 					  g_theVarContext.addVariable(g_parmType,g_parmName);
@@ -2561,20 +2635,24 @@
 					  {
 					    g_theVarContext.pushScope();
 					  }
 					}
 <MemberCall2,FuncCall>{OPERATOR}        { // operator
-  					  if (strcmp(yytext,"*") && strcmp(yytext,"&")) // typically a pointer or reference
+  					  if (strcmp(yytext,"*") && 
+					      strcmp(yytext,"&") &&
+					      strcmp(yytext,"^") &&
+					      strcmp(yytext,"%")) // typically a pointer or reference
 					  {
-					    // not a * or &
+					    // not a * or &, or C++/CLI's ^ or %
 					    g_parmType.resize(0);g_parmName.resize(0);
 					  }
   					  g_code->codify(yytext);
   					}
 <MemberCall,MemberCall2,FuncCall>")"	{ 
 					  g_theVarContext.addVariable(g_parmType,g_parmName);
 					  g_theCallContext.popScope();
+					  g_inForEachExpression = FALSE;
 					  //g_theCallContext.setClass(0); // commented out, otherwise a()->b() does not work for b().
   					  g_code->codify(yytext);
   					  if (--g_bracketCount<=0) 
 					  {
 					    if (g_name.isEmpty())
@@ -2615,16 +2693,16 @@
 					  {
 					    g_bracketCount=0;
 					    BEGIN( SkipInits );
 					  }
   					}
-<CallEnd>("const"|"volatile")({BN}+("const"|"volatile"))*{BN}*/[;=] {
+<CallEnd>("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"sealed"|"override"))*/{BN}*(";"|"="|"throw"{BN}*"(") {
 					  startFontClass("keyword");
   					  codifyLines(yytext);
 					  endFontClass();
   					}
-<CallEnd,OldStyleArgs>("const"|"volatile")*({BN}+("const"|"volatile"))*{BN}*"{" {
+<CallEnd,OldStyleArgs>("const"|"volatile"|"sealed"|"override")*({BN}+("const"|"volatile"|"sealed"|"override"))*{BN}*"{" {
                                           if (g_insideBody)
 					  {
 					    g_theVarContext.pushScope();
 					  }
 					  g_theVarContext.addVariable(g_parmType,g_parmName);
