dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_grammar.y,1.37,1.38


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_grammar.y,1.37,1.38
Date: Wed, 20 Nov 2002 17:42:32 -0500

Update of /cvsroot/dotgnu-pnet/pnet/cscc/csharp
In directory subversions:/tmp/cvs-serv17871/cscc/csharp

Modified Files:
        cs_grammar.y 
Log Message:


Prevent an infinite error recovery loop if the programmer writes
"namespace XXX }" instead of "namespace { XXX }".


Index: cs_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_grammar.y,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -r1.37 -r1.38
*** cs_grammar.y        16 Nov 2002 09:44:14 -0000      1.37
--- cs_grammar.y        20 Nov 2002 22:42:29 -0000      1.38
***************
*** 927,931 ****
                                ResetState();
                        }
!       | OuterDeclarations             {
                                /* Check for empty input and finalize the parse 
*/
                                if(!HaveDecls)
--- 927,931 ----
                                ResetState();
                        }
!       | OuterDeclarationsRecoverable          {
                                /* Check for empty input and finalize the parse 
*/
                                if(!HaveDecls)
***************
*** 936,940 ****
                                ResetState();
                        }
!       | OuterDeclarations AttributeSections   {
                                /* A file that contains declarations and 
assembly attributes */
                                ResetState();
--- 936,940 ----
                                ResetState();
                        }
!       | OuterDeclarationsRecoverable AttributeSections        {
                                /* A file that contains declarations and 
assembly attributes */
                                ResetState();
***************
*** 1005,1008 ****
--- 1005,1032 ----
                                }
                                NestingLevel = 0;
+                       }
+       ;
+ 
+ OuterDeclarationsRecoverable
+       : OuterDeclarationRecoverable
+       | OuterDeclarationsRecoverable OuterDeclarationRecoverable
+       ;
+ 
+ OuterDeclarationRecoverable
+       : OuterDeclaration
+       | '}'                           {
+                               /* Recover from our educated guess that we were 
at the
+                                  end of a namespace scope in the error 
processing code
+                                  for '}' above.  If the programmer wrote 
"namespace XXX }"
+                                  instead of "namespace { XXX }", this code 
will stop the
+                                  error processing logic from looping 
indefinitely */
+                               if(CurrNamespace.len == 0)
+                               {
+                                       CCError(_("parse error at or near 
`}'"));
+                               }
+                               else
+                               {
+                                       CurrNamespace = ILInternString("", 0);
+                               }
                        }
        ;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]