[Mono-bugs] [Bug 35169][Min] New - #else in tokenizer
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
5 Dec 2002 21:43:50 -0000
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by f_azi@hotmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=35169
--- shadow/35169 Thu Dec 5 16:43:50 2002
+++ shadow/35169.tmp.30028 Thu Dec 5 16:43:50 2002
@@ -0,0 +1,89 @@
+Bug#: 35169
+Product: Mono/MCS
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Minor
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: f_azi@hotmail.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: #else in tokenizer
+
+Please fill in this template when reporting a bug, unless you know what
+you are doing.
+Description of Problem:
+Using hte snapshot of Dec 04/02.
+Problems parsing code with stacked #if, #else, #endif directives.
+
+
+Steps to reproduce the problem:
+The following code will reproduce the problem:
+#if FLAG_FALSE
+ namespace ns1
+#else
+ #if FLAG_FALSE
+ #if FLAG_FALSE
+ namespace ns2
+ #else
+ namespace ns3
+ #endif
+ #else
+ #if FLAG_TRUE
+ namespace ns4
+ #else
+ namespace ns5
+ #endif
+ #endif
+#endif
+{
+ public class TheClass
+ {
+ public TheClass()
+ {
+ }
+ }
+}
+
+The problem is on the procesing of the #else. In the current code the
+status on the stack is not updated when processing the 'else' so
+the 'if''s status is keept in the stack. Then the son's of the else have
+the wrong parent information on the stack.
+One way of solving the issue is as follow:
+
+case "else":
+ if (ifstack == null || ifstack.Count == 0){
+ Report.Error (1028, Location,"Unexpected processor directive (no
+#if for this #else)");
+ return true;
+ } else {
+ int state = (int) ifstack.Peek ();
+
+ if ((state & ELSE_SEEN) != 0){
+ Error_UnexpectedDirective ("#else within #else");
+ return true;
+ }
+
+ ifstack.Pop ();
+
+ bool bRet;
+ if ((state & TAKEN_BEFORE) == 0){
+ bRet = ((state & PARENT_TAKING) != 0);
+ } else
+ bRet = false;
+
+ if (bRet)
+ state |= TAKING;
+ else
+ state &= ~TAKING;
+
+ ifstack.Push (state | ELSE_SEEN);
+
+ return bRet;
+ }