// after a token has been seen.
//
bool any_token_seen = false;
+
static Hashtable tokenValues;
private static Hashtable TokenValueName
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;
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++) {
col = 0;
any_token_seen |= tokens_seen;
tokens_seen = false;
+ comments_seen = false;
continue;
}
}
any_token_seen |= tokens_seen;
tokens_seen = false;
+ comments_seen = false;
continue;
} else if (d == '*'){
getChar ();
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);
}
if (d == '*' && peekChar () == '/'){
getChar ();
col++;
+ comments_seen = true;
break;
}
if (docAppend)
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;
col = 0;
any_token_seen |= tokens_seen;
tokens_seen = false;
+ comments_seen = false;
continue;
}
/* 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);
}
}
- 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;
//
// 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++) {
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));
}
//