Remove debugging comment
[mono.git] / mcs / mcs / cs-tokenizer.cs
index a9e2b78e05d54f9afd50b9d6975823fea625ac3c..11437dd414884d14c1dce261bfff642f88040ffb 100644 (file)
@@ -64,6 +64,7 @@ namespace Mono.CSharp
                // after a token has been seen.
                //
                bool any_token_seen = false;
+
                static Hashtable tokenValues;
 
                private static Hashtable TokenValueName
@@ -1467,7 +1468,7 @@ namespace Mono.CSharp
                                if (s [0] == '&'){
                                        if (len > 2 && s [1] == '&'){
                                                s = s.Substring (2);
-                                               return (va & pp_eq (ref s));
+                                               return (va & pp_and (ref s));
                                        } else {
                                                Error_InvalidDirective ();
                                                return false;
@@ -1877,6 +1878,9 @@ namespace Mono.CSharp
                        bool doread = false;
                        int c;
 
+                       // Whether we have seen comments on the current line
+                       bool comments_seen = false;
+                       
                        val = null;
                        // optimization: eliminate col and implement #directive semantic correctly.
                        for (;(c = getChar ()) != -1; col++) {
@@ -1900,6 +1904,7 @@ namespace Mono.CSharp
                                        col = 0;
                                        any_token_seen |= tokens_seen;
                                        tokens_seen = false;
+                                       comments_seen = false;
                                        continue;
                                }
 
@@ -1928,6 +1933,7 @@ namespace Mono.CSharp
                                                }
                                                any_token_seen |= tokens_seen;
                                                tokens_seen = false;
+                                               comments_seen = false;
                                                continue;
                                        } else if (d == '*'){
                                                getChar ();
@@ -1945,9 +1951,9 @@ namespace Mono.CSharp
                                                                warn_incorrect_doc_comment ();
                                                }
 
-                                               int currentCommentStart = 0;
+                                               int current_comment_start = 0;
                                                if (docAppend) {
-                                                       currentCommentStart = xml_comment_buffer.Length;
+                                                       current_comment_start = xml_comment_buffer.Length;
                                                        xml_comment_buffer.Append (Environment.NewLine);
                                                }
 
@@ -1955,6 +1961,7 @@ namespace Mono.CSharp
                                                        if (d == '*' && peekChar () == '/'){
                                                                getChar ();
                                                                col++;
+                                                               comments_seen = true;
                                                                break;
                                                        }
                                                        if (docAppend)
@@ -1966,10 +1973,15 @@ namespace Mono.CSharp
                                                                col = 0;
                                                                any_token_seen |= tokens_seen;
                                                                tokens_seen = false;
+                                                               // 
+                                                               // Reset 'comments_seen' just to be consistent.
+                                                               // It doesn't matter either way, here.
+                                                               //
+                                                               comments_seen = false;
                                                        }
                                                }
                                                if (docAppend)
-                                                       update_formatted_doc_comment (currentCommentStart);
+                                                       update_formatted_doc_comment (current_comment_start);
                                                continue;
                                        }
                                        goto is_punct_label;
@@ -1998,6 +2010,7 @@ namespace Mono.CSharp
                                        col = 0;
                                        any_token_seen |= tokens_seen;
                                        tokens_seen = false;
+                                       comments_seen = false;
                                        continue;
                                }
 
@@ -2017,9 +2030,18 @@ namespace Mono.CSharp
                                /* For now, ignore pre-processor commands */
                                // FIXME: In C# the '#' is not limited to appear
                                // on the first column.
-                               if (c == '#' && !tokens_seen){
+                               if (c == '#'{
                                        bool cont = true;
                                        
+                                       if (tokens_seen || comments_seen) {
+                                               error_details = "Preprocessor directives must appear as the first non-whitespace " +
+                                                       "character on a line.";
+
+                                               Report.Error (1040, Location, error_details);
+
+                                               return Token.ERROR;
+                                       }
+                                       
                                start_again:
                                        
                                        cont = handle_preprocessing_directive (cont);
@@ -2101,15 +2123,6 @@ namespace Mono.CSharp
                                        }
                                }
 
-                               if (c == '#') {
-                                       error_details = "Preprocessor directives must appear as the first non-whitespace " +
-                                               "character on a line.";
-
-                                       Report.Error (1040, Location, error_details);
-
-                                       return Token.ERROR;
-                               }
-
                                error_details = ((char)c).ToString ();
                                
                                return Token.ERROR;
@@ -2137,12 +2150,13 @@ namespace Mono.CSharp
                //
                // Remove heading "*" in Javadoc-like xml documentation.
                //
-               private void update_formatted_doc_comment (int currentCommentStart)
+               private void update_formatted_doc_comment (int current_comment_start)
                {
-                       int length = xml_comment_buffer.Length - currentCommentStart;
+                       int length = xml_comment_buffer.Length - current_comment_start;
                        string [] lines = xml_comment_buffer.ToString (
-                               currentCommentStart,
+                               current_comment_start,
                                length).Replace ("\r", "").Split ('\n');
+                       
                        // The first line starts with /**, thus it is not target
                        // for the format check.
                        for (int i = 1; i < lines.Length; i++) {
@@ -2153,18 +2167,15 @@ namespace Mono.CSharp
                                        if (i < lines.Length - 1)
                                                return;
                                        head = s;
-                               }
-                               else
+                               } else
                                        head = s.Substring (0, idx);
                                foreach (char c in head)
                                        if (c != ' ')
                                                return;
                                lines [i] = s.Substring (idx + 1);
                        }
-                       xml_comment_buffer.Remove (currentCommentStart, length);
-                       xml_comment_buffer.Insert (
-                               currentCommentStart,
-                               String.Join (Environment.NewLine, lines));
+                       xml_comment_buffer.Remove (current_comment_start, length);
+                       xml_comment_buffer.Insert (current_comment_start, String.Join (Environment.NewLine, lines));
                }
 
                //