// (C) 2001, 2002 Ximian, Inc (http://www.ximian.com)
// (C) 2004 Novell, Inc
//
-
-/*
- * TODO:
- * Make sure we accept the proper Unicode ranges, per the spec.
- * Report error 1032
-*/
+//
using System;
using System.Text;
bool handle_get_set = false;
bool handle_remove_add = false;
bool handle_assembly = false;
- bool handle_constraints = false;
+ bool handle_where = false;
bool handle_typeof = false;
+ bool lambda_arguments_parsing;
Location current_location;
Location current_comment_location = Location.Null;
- ArrayList escapedIdentifiers = new ArrayList ();
-
+ ArrayList escaped_identifiers = new ArrayList ();
+ public int parsing_block;
+ internal int query_parsing;
+
//
// XML documentation buffer. The save point is used to divide
// comments on types and comments on members.
//
// See comment on XmlCommentState enumeration.
//
- XmlCommentState xmlDocState = XmlCommentState.Allowed;
+ XmlCommentState xml_doc_state = XmlCommentState.Allowed;
//
// Whether tokens have been seen on this line
//
bool any_token_seen = false;
- static Hashtable tokenValues;
+ static Hashtable token_values;
+ static readonly char[] simple_whitespaces = new char[] { ' ', '\t' };
private static Hashtable TokenValueName
{
get {
- if (tokenValues == null)
- tokenValues = GetTokenValueNameHash ();
+ if (token_values == null)
+ token_values = GetTokenValueNameHash ();
- return tokenValues;
+ return token_values;
}
}
}
public bool PropertyParsing {
- get {
- return handle_get_set;
- }
-
- set {
- handle_get_set = value;
- }
+ get { return handle_get_set; }
+ set { handle_get_set = value; }
}
public bool AssemblyTargetParsing {
- get {
- return handle_assembly;
- }
-
- set {
- handle_assembly = value;
- }
+ get { return handle_assembly; }
+ set { handle_assembly = value; }
}
public bool EventParsing {
- get {
- return handle_remove_add;
- }
-
- set {
- handle_remove_add = value;
- }
+ get { return handle_remove_add; }
+ set { handle_remove_add = value; }
}
public bool ConstraintsParsing {
- get {
- return handle_constraints;
- }
-
- set {
- handle_constraints = value;
- }
+ get { return handle_where; }
+ set { handle_where = value; }
}
public bool TypeOfParsing {
- get {
- return handle_typeof;
- }
-
- set {
- handle_typeof = value;
- }
+ get { return handle_typeof; }
+ set { handle_typeof = value; }
}
-
+
public XmlCommentState doc_state {
- get { return xmlDocState; }
+ get { return xml_doc_state; }
set {
if (value == XmlCommentState.Allowed) {
check_incorrect_doc_comment ();
reset_doc_comment ();
}
- xmlDocState = value;
+ xml_doc_state = value;
}
}
public bool IsEscapedIdentifier (Location loc)
{
- foreach (LocatedToken lt in escapedIdentifiers)
+ foreach (LocatedToken lt in escaped_identifiers)
if (lt.Location.Equals (loc))
return true;
return false;
// Class variables
//
static CharArrayHashtable[] keywords;
- static Hashtable keywordStrings = new Hashtable ();
+ static Hashtable keyword_strings;
static NumberStyles styles;
static NumberFormatInfo csharp_format_info;
public int putback_char;
public int previous_col;
public Stack ifstack;
-#if GMCS_SOURCES
public int parsing_generic_less_than;
-#endif
+ public int current_token;
+
public Position (Tokenizer t)
{
position = t.reader.Position;
previous_col = t.previous_col;
if (t.ifstack != null && t.ifstack.Count != 0)
ifstack = (Stack)t.ifstack.Clone ();
-#if GMCS_SOURCES
parsing_generic_less_than = t.parsing_generic_less_than;
-#endif
+ current_token = t.current_token;
}
}
putback_char = p.putback_char;
previous_col = p.previous_col;
ifstack = p.ifstack;
+ parsing_generic_less_than = p.parsing_generic_less_than;
+ current_token = p.current_token;
}
// Do not reset the position, ignore it.
position_stack.Pop ();
}
- static void AddKeyword (string kw, int token) {
- keywordStrings.Add (kw, kw);
+ static void AddKeyword (string kw, int token)
+ {
+ keyword_strings.Add (kw, kw);
if (keywords [kw.Length] == null) {
keywords [kw.Length] = new CharArrayHashtable (kw.Length);
}
static void InitTokens ()
{
+ keyword_strings = new Hashtable ();
keywords = new CharArrayHashtable [64];
AddKeyword ("__arglist", Token.ARGLIST);
AddKeyword ("volatile", Token.VOLATILE);
AddKeyword ("while", Token.WHILE);
AddKeyword ("partial", Token.PARTIAL);
-#if GMCS_SOURCE
AddKeyword ("where", Token.WHERE);
-#endif
+
+ // LINQ keywords
+ AddKeyword ("from", Token.FROM);
+ AddKeyword ("join", Token.JOIN);
+ AddKeyword ("on", Token.ON);
+ AddKeyword ("equals", Token.EQUALS);
+ AddKeyword ("select", Token.SELECT);
+ AddKeyword ("group", Token.GROUP);
+ AddKeyword ("by", Token.BY);
+ AddKeyword ("let", Token.LET);
+ AddKeyword ("orderby", Token.ORDERBY);
+ AddKeyword ("ascending", Token.ASCENDING);
+ AddKeyword ("descending", Token.DESCENDING);
+ AddKeyword ("into", Token.INTO);
}
//
// Class initializer
//
static Tokenizer ()
+ {
+ Reset ();
+ }
+
+ public static void Reset ()
{
InitTokens ();
csharp_format_info = NumberFormatInfo.InvariantInfo;
styles = NumberStyles.Float;
-
+
string_builder = new System.Text.StringBuilder ();
}
int res = (int) o;
- if (handle_get_set == false && (res == Token.GET || res == Token.SET))
+ if (!handle_get_set && (res == Token.GET || res == Token.SET))
return -1;
- if (handle_remove_add == false && (res == Token.REMOVE || res == Token.ADD))
+ if (!handle_remove_add && (res == Token.REMOVE || res == Token.ADD))
return -1;
- if (handle_assembly == false && res == Token.ASSEMBLY)
+ if (!handle_assembly && res == Token.ASSEMBLY)
return -1;
-#if GMCS_SOURCE
- if (handle_constraints == false && res == Token.WHERE)
+
+ //
+ // A query expression is any expression that starts with `from identifier'
+ // followed by any token except ; , =
+ //
+ if (query_parsing == 0) {
+ if (res == Token.FROM && !lambda_arguments_parsing) {
+ PushPosition ();
+ // HACK: to disable generics micro-parser, because PushPosition does not
+ // store identifiers array
+ parsing_generic_less_than = 1;
+ switch (xtoken ()) {
+ case Token.IDENTIFIER:
+ case Token.INT:
+ case Token.BOOL:
+ case Token.BYTE:
+ case Token.CHAR:
+ case Token.DECIMAL:
+ case Token.FLOAT:
+ case Token.LONG:
+ case Token.OBJECT:
+ case Token.STRING:
+ case Token.UINT:
+ case Token.ULONG:
+ int next_token = xtoken ();
+ if (next_token == Token.SEMICOLON || next_token == Token.COMMA || next_token == Token.EQUALS)
+ goto default;
+
+ ++query_parsing;
+ if (RootContext.Version <= LanguageVersion.ISO_2)
+ Report.FeatureIsNotAvailable (Location, "query expressions");
+ break;
+ case Token.VOID:
+ Expression.Error_VoidInvalidInTheContext (Location);
+ break;
+ default:
+ PopPosition ();
+ // HACK: A token is not a keyword so we need to restore identifiers buffer
+ // which has been overwritten before we grabbed the identifier
+ id_builder [0] = 'f'; id_builder [1] = 'r'; id_builder [2] = 'o'; id_builder [3] = 'm';
+ return -1;
+ }
+ PopPosition ();
+ return res;
+ }
+
+ if (res > Token.QUERY_FIRST_TOKEN && res < Token.QUERY_LAST_TOKEN)
+ return -1;
+ }
+
+ if (res == Token.WHERE && !handle_where && query_parsing == 0)
return -1;
-#endif
- return res;
+ return res;
}
public Location Location {
static bool is_identifier_part_character (char c)
{
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (c >= '0' && c <= '9') || Char.IsLetter (c);
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (c >= '0' && c <= '9') ||
+ Char.IsLetter (c) || Char.GetUnicodeCategory (c) == UnicodeCategory.ConnectorPunctuation;
}
public static bool IsKeyword (string s)
{
- return keywordStrings [s] != null;
+ return keyword_strings [s] != null;
+ }
+
+ //
+ // Tests whether '(' is beggining of lambda parameters
+ //
+ bool IsLambdaOpenParens ()
+ {
+ int ntoken;
+ while ((ntoken = xtoken ()) != Token.EOF) {
+ switch (ntoken) {
+ case Token.CLOSE_PARENS:
+ return xtoken () == Token.ARROW;
+
+ case Token.STAR:
+ case Token.SEMICOLON:
+ case Token.OPEN_BRACE:
+ case Token.OPEN_PARENS:
+ case Token.LITERAL_STRING:
+ return false;
+ }
+ }
+
+ Error_TokenExpected (",' or `)");
+ return false;
}
public static bool IsValidIdentifier (string s)
return true;
}
-#if GMCS_SOURCE
- bool parse_generic_dimension (out int dimension)
- {
- dimension = 1;
-
- again:
- int the_token = token ();
- if (the_token == Token.OP_GENERICS_GT)
- return true;
- else if (the_token == Token.COMMA) {
- dimension++;
- goto again;
- }
-
- return false;
- }
-
bool parse_less_than ()
{
start:
return false;
}
- int parsing_generic_less_than = 0;
-
public void PutbackNullable ()
{
if (nullable_pos < 0)
else
nullable_pos = -1;
}
-#endif
+
+ bool parse_generic_dimension (out int dimension)
+ {
+ dimension = 1;
+
+ again:
+ int the_token = token ();
+ if (the_token == Token.OP_GENERICS_GT)
+ return true;
+ else if (the_token == Token.COMMA) {
+ dimension++;
+ goto again;
+ }
+
+ return false;
+ }
+
+ public int peek_token ()
+ {
+ int the_token;
+
+ PushPosition ();
+ the_token = token ();
+ PopPosition ();
+
+ return the_token;
+ }
+
+ int parsing_generic_less_than = 0;
+
int is_punct (char c, ref bool doread)
{
int d;
case ']':
return Token.CLOSE_BRACKET;
case '(':
+ if (!lambda_arguments_parsing) {
+ lambda_arguments_parsing = true;
+ PushPosition ();
+ bool lambda_start = IsLambdaOpenParens ();
+ PopPosition ();
+ lambda_arguments_parsing = false;
+ if (lambda_start) {
+ if (RootContext.Version <= LanguageVersion.ISO_2)
+ Report.FeatureIsNotAvailable (Location, "lambda expressions");
+
+ return Token.OPEN_PARENS_LAMBDA;
+ }
+ }
return Token.OPEN_PARENS;
case ')': {
if (deambiguate_close_parens == 0)
val = Location;
return Token.TILDE;
case '?':
+ d = peek_char ();
+ if (d == '?') {
+ get_char ();
+ return Token.OP_COALESCING;
+ }
return Token.INTERR;
}
-#if GMCS_SOURCE
+
if (c == '<') {
if (parsing_generic_less_than++ > 0)
return Token.OP_GENERICS_LT;
PopPosition ();
if (is_generic_lt) {
- parsing_generic_less_than++;
return Token.OP_GENERICS_LT;
} else
parsing_generic_less_than = 0;
- d = peekChar ();
+ d = peek_char ();
if (d == '<'){
- getChar ();
- d = peekChar ();
+ get_char ();
+ d = peek_char ();
if (d == '='){
doread = true;
return Token.OP_GENERICS_GT;
}
- d = peekChar ();
+ d = peek_char ();
if (d == '>'){
- getChar ();
- d = peekChar ();
+ get_char ();
+ d = peek_char ();
if (d == '='){
doread = true;
}
return Token.OP_GT;
}
-#endif
- d = peekChar ();
+
+ d = peek_char ();
if (c == '+'){
if (d == '+') {
doread = true;
return Token.OP_EQ;
}
+ if (d == '>'){
+ doread = true;
+ val = Location;
+ return Token.ARROW;
+ }
+
return Token.ASSIGN;
}
return Token.CARRET;
}
-#if !GMCS_SOURCE
- if (c == '<'){
- if (d == '<'){
- getChar ();
- d = peekChar ();
-
- if (d == '='){
- doread = true;
- return Token.OP_SHIFT_LEFT_ASSIGN;
- }
- return Token.OP_SHIFT_LEFT;
- } else if (d == '='){
- doread = true;
- return Token.OP_LE;
- }
- return Token.OP_LT;
- }
-
- if (c == '>'){
- if (d == '>'){
- getChar ();
- d = peekChar ();
-
- if (d == '='){
- doread = true;
- return Token.OP_SHIFT_RIGHT_ASSIGN;
- }
- return Token.OP_SHIFT_RIGHT;
- } else if (d == '='){
- doread = true;
- return Token.OP_GE;
- }
- return Token.OP_GT;
- }
-#endif
if (c == ':'){
if (d == ':'){
doread = true;
}
//
- // We use peekChar2, because decimal_digits needs to do a
+ // We use peek_char2, because decimal_digits needs to do a
// 2-character look-ahead (5.ToString for example).
//
- while ((d = peekChar2 ()) != -1){
+ while ((d = peek_char2 ()) != -1){
if (d >= '0' && d <= '9'){
if (number_pos == max_number_size)
Error_NumericConstantTooLong ();
number_builder [number_pos++] = (char) d;
- getChar ();
+ get_char ();
seen_digits = true;
} else
break;
if (is_unsigned)
scanning = false;
is_unsigned = true;
- getChar ();
+ get_char ();
break;
case 'l':
- if (!is_unsigned && (RootContext.WarningLevel >= 4)){
+ if (!is_unsigned){
//
// if we have not seen anything in between
// report this error
if (is_long)
scanning = false;
is_long = true;
- getChar ();
+ get_char ();
break;
case 'L':
if (is_long)
scanning = false;
is_long = true;
- getChar ();
+ get_char ();
break;
default:
scanning = false;
break;
}
- c = peekChar ();
+ c = peek_char ();
} while (scanning);
}
int d;
ulong ul;
- getChar ();
- while ((d = peekChar ()) != -1){
+ get_char ();
+ while ((d = peek_char ()) != -1){
if (is_hex (d)){
number_builder [number_pos++] = (char) d;
- getChar ();
+ get_char ();
} else
break;
}
return Token.LITERAL_INTEGER;
}
- return integer_type_suffix (ul, peekChar ());
+ return integer_type_suffix (ul, peek_char ());
}
//
if (c >= '0' && c <= '9'){
if (c == '0'){
- int peek = peekChar ();
+ int peek = peek_char ();
if (peek == 'x' || peek == 'X')
return handle_hex ();
}
decimal_digits (c);
- c = getChar ();
+ c = get_char ();
}
//
if (c == '.'){
if (decimal_digits ('.')){
is_real = true;
- c = getChar ();
+ c = get_char ();
} else {
putback ('.');
number_pos--;
if (number_pos == max_number_size)
Error_NumericConstantTooLong ();
number_builder [number_pos++] = 'e';
- c = getChar ();
+ c = get_char ();
if (c == '+'){
if (number_pos == max_number_size)
}
decimal_digits (c);
- c = getChar ();
+ c = get_char ();
}
type = real_type_suffix (c);
int c;
int top = count != -1 ? count : 4;
- getChar ();
+ get_char ();
error = false;
for (i = 0; i < top; i++){
- c = getChar ();
+ c = get_char ();
if (c >= '0' && c <= '9')
c = (int) c - (int) '0';
total = (total * 16) + c;
if (count == -1){
- int p = peekChar ();
+ int p = peek_char ();
if (p == -1)
break;
if (!is_hex ((char)p))
int d;
int v;
- d = peekChar ();
+ d = peek_char ();
if (c != '\\')
return c;
Report.Error (1009, Location, "Unrecognized escape sequence `\\{0}'", ((char)d).ToString ());
return d;
}
- getChar ();
+ get_char ();
return v;
}
- int getChar ()
+ int get_char ()
{
int x;
if (putback_char != -1) {
} else
x = reader.Read ();
if (x == '\n') {
- line++;
- ref_line++;
- previous_col = col;
- col = 0;
+ advance_line ();
}
else
col++;
return x;
}
- int peekChar ()
+ void advance_line ()
+ {
+ line++;
+ ref_line++;
+ previous_col = col;
+ col = 0;
+ }
+
+ int peek_char ()
{
if (putback_char != -1)
return putback_char;
return putback_char;
}
- int peekChar2 ()
+ int peek_char2 ()
{
if (putback_char != -1)
return putback_char;
public bool advance ()
{
- return peekChar () != -1;
+ return peek_char () != -1;
}
public Object Value {
case Token.TYPEOF:
case Token.UNCHECKED:
case Token.UNSAFE:
-#if GMCS_SOURCE
case Token.DEFAULT:
-#endif
//
// These can be part of a member access
{
current_token = xtoken ();
-#if GMCS_SOURCE
if (current_token != Token.DEFAULT)
return current_token;
current_token = Token.DEFAULT_COLON;
else
PopPosition();
-#endif
+
return current_token;
}
static_cmd_arg.Length = 0;
// skip over white space
- while ((c = getChar ()) != -1 && (c != '\n') && ((c == '\r') || (c == ' ') || (c == '\t')))
+ while ((c = get_char ()) != -1 && (c != '\n') && ((c == '\r') || (c == ' ') || (c == '\t')))
;
while ((c != -1) && (c != '\n') && (c != ' ') && (c != '\t') && (c != '\r')){
if (is_identifier_part_character ((char) c)){
static_cmd_arg.Append ((char) c);
- c = getChar ();
+ c = get_char ();
} else {
putback (c);
break;
}
// skip over white space
- while ((c = getChar ()) != -1 && (c != '\n') && ((c == '\r') || (c == ' ') || (c == '\t')))
+ while ((c = get_char ()) != -1 && (c != '\n') && ((c == '\r') || (c == ' ') || (c == '\t')))
;
if (c == '\n'){
static_cmd_arg.Length = 0;
static_cmd_arg.Append ((char) c);
- while ((c = getChar ()) != -1 && (c != '\n') && (c != '\r')){
+ while ((c = get_char ()) != -1 && (c != '\n') && (c != '\r')){
static_cmd_arg.Append ((char) c);
}
//
// Handles #define and #undef
//
- void PreProcessDefinition (bool is_define, string arg)
+ void PreProcessDefinition (bool is_define, string arg, bool caller_is_taking)
{
if (arg.Length == 0 || arg == "true" || arg == "false"){
Report.Error (1001, Location, "Missing identifer to pre-processor directive");
return;
}
- char[] whitespace = { ' ', '\t' };
- if (arg.IndexOfAny (whitespace) != -1){
+ if (arg.IndexOfAny (simple_whitespaces) != -1){
Error_EndLineExpected ();
return;
}
}
}
+ if (!caller_is_taking)
+ return;
+
if (is_define){
if (defines == null)
defines = new Hashtable ();
const string w_restore = "warning restore";
if (arg == w_disable) {
- Report.RegisterWarningRegion (Location).WarningDisable (line);
+ Report.RegisterWarningRegion (Location).WarningDisable (Location.Row);
return;
}
if (arg == w_restore) {
- Report.RegisterWarningRegion (Location).WarningEnable (line);
+ Report.RegisterWarningRegion (Location).WarningEnable (Location.Row);
return;
}
"Unexpected processor directive (" + extra + ")");
}
+ void Error_TokenExpected (string token)
+ {
+ Report.Error (1026, Location, "Expected `{0}'", token);
+ }
+
void Error_TokensSeen ()
{
Report.Error (1032, Location,
// Eat any trailing whitespaces and single-line comments
if (arg.IndexOf ("//") != -1)
arg = arg.Substring (0, arg.IndexOf ("//"));
- arg = arg.Trim (' ', '\t');
+ arg = arg.Trim (simple_whitespaces);
//
// The first group of pre-processing instructions is always processed
Error_UnexpectedDirective ("no #if for this #elif");
return true;
} else {
- int state = (int) ifstack.Peek ();
+ int state = (int) ifstack.Pop ();
if ((state & REGION) != 0) {
Report.Error (1038, Location, "#endregion directive expected");
return true;
}
- if ((state & TAKING) != 0)
+ if ((state & TAKING) != 0) {
+ ifstack.Push (0);
return false;
+ }
if (eval (arg) && ((state & PARENT_TAKING) != 0)){
- state = (int) ifstack.Pop ();
ifstack.Push (state | TAKING);
return true;
- } else
- return false;
+ }
+
+ ifstack.Push (state);
+ return false;
}
case "else":
Error_TokensSeen ();
return caller_is_taking;
}
- PreProcessDefinition (true, arg);
+ PreProcessDefinition (true, arg, caller_is_taking);
return caller_is_taking;
case "undef":
Error_TokensSeen ();
return caller_is_taking;
}
- PreProcessDefinition (false, arg);
+ PreProcessDefinition (false, arg, caller_is_taking);
return caller_is_taking;
}
case "pragma":
if (RootContext.Version == LanguageVersion.ISO_1) {
- Report.FeatureIsNotStandardized (Location, "#pragma");
+ Report.FeatureIsNotAvailable (Location, "#pragma");
return true;
}
{
int c;
string_builder.Length = 0;
-
- while ((c = getChar ()) != -1){
+
+ //
+ // No need to parse full string when parsing lambda arguments
+ //
+ if (lambda_arguments_parsing)
+ return Token.LITERAL_STRING;
+
+ while ((c = get_char ()) != -1){
if (c == '"'){
- if (quoted && peekChar () == '"'){
+ if (quoted && peek_char () == '"'){
string_builder.Append ((char) c);
- getChar ();
+ get_char ();
continue;
} else {
val = string_builder.ToString ();
}
if (res == Token.PARTIAL) {
+ if (parsing_block > 0) {
+ val = new LocatedToken (Location, "partial");
+ return Token.IDENTIFIER;
+ }
+
// Save current position and parse next token.
PushPosition ();
int next_token = token ();
bool ok = (next_token == Token.CLASS) ||
(next_token == Token.STRUCT) ||
- (next_token == Token.INTERFACE);
+ (next_token == Token.INTERFACE) ||
+ (next_token == Token.VOID);
PopPosition ();
- if (ok)
+ if (ok) {
+ if (next_token == Token.VOID) {
+ if (RootContext.Version <= LanguageVersion.ISO_2)
+ Report.FeatureIsNotAvailable (Location, "partial methods");
+ } else if (RootContext.Version == LanguageVersion.ISO_1)
+ Report.FeatureIsNotAvailable (Location, "partial types");
+
return res;
+ }
if (next_token < Token.LAST_KEYWORD)
- Report.Error (267, Location, "The `partial' modifier can be used only immediately before keyword `class', `struct', or `interface'");
+ Report.Error (267, Location, "The `partial' modifier can be used only immediately before `class', `struct', `interface', or `void' keyword");
val = new LocatedToken (Location, "partial");
return Token.IDENTIFIER;
current_location = new Location (ref_line, Col);
- while ((c = getChar ()) != -1) {
+ while ((c = get_char ()) != -1) {
loop:
if (is_identifier_part_character ((char) c)){
if (pos == max_id_size){
if (val != null) {
val = new LocatedToken (Location, (string) val);
if (quoted)
- escapedIdentifiers.Add (val);
+ escaped_identifiers.Add (val);
return Token.IDENTIFIER;
}
}
val = new LocatedToken (Location, (string) val);
if (quoted)
- escapedIdentifiers.Add (val);
+ escaped_identifiers.Add (val);
return Token.IDENTIFIER;
}
// Whether we have seen comments on the current line
bool comments_seen = false;
-
val = null;
- for (;(c = getChar ()) != -1;) {
- if (c == ' ' || c == '\t' || c == '\f' || c == '\v' || c == 0xa0)
+ for (;(c = get_char ()) != -1;) {
+ if (c == '\t'){
+ col = ((col + 8) / 8) * 8;
+ continue;
+ }
+
+ if (c == ' ' || c == '\f' || c == '\v' || c == 0xa0 || c == 0)
continue;
if (c == '\r') {
- if (peekChar () == '\n')
- getChar ();
+ if (peek_char () != '\n')
+ advance_line ();
+ else
+ get_char ();
any_token_seen |= tokens_seen;
tokens_seen = false;
// Handle double-slash comments.
if (c == '/'){
- int d = peekChar ();
+ int d = peek_char ();
if (d == '/'){
- getChar ();
- if (RootContext.Documentation != null && peekChar () == '/') {
- getChar ();
+ get_char ();
+ if (RootContext.Documentation != null && peek_char () == '/') {
+ get_char ();
// Don't allow ////.
- if ((d = peekChar ()) != '/') {
+ if ((d = peek_char ()) != '/') {
update_comment_location ();
if (doc_state == XmlCommentState.Allowed)
handle_one_line_xml_comment ();
warn_incorrect_doc_comment ();
}
}
- while ((d = getChar ()) != -1 && (d != '\n') && d != '\r')
- if (d == '\n'){
- }
+ while ((d = get_char ()) != -1 && (d != '\n') && d != '\r')
+ if (d == '\n'){
+ }
any_token_seen |= tokens_seen;
tokens_seen = false;
comments_seen = false;
continue;
} else if (d == '*'){
- getChar ();
+ get_char ();
bool docAppend = false;
- if (RootContext.Documentation != null && peekChar () == '*') {
- getChar ();
+ if (RootContext.Documentation != null && peek_char () == '*') {
+ get_char ();
update_comment_location ();
// But when it is /**/, just do nothing.
- if (peekChar () == '/') {
- getChar ();
+ if (peek_char () == '/') {
+ get_char ();
continue;
}
if (doc_state == XmlCommentState.Allowed)
Location start_location = Location;
- while ((d = getChar ()) != -1){
- if (d == '*' && peekChar () == '/'){
- getChar ();
+ while ((d = get_char ()) != -1){
+ if (d == '*' && peek_char () == '/'){
+ get_char ();
comments_seen = true;
break;
}
if ((t = is_punct ((char)c, ref doread)) != Token.ERROR){
tokens_seen = true;
if (doread){
- getChar ();
+ get_char ();
}
return t;
}
if (c == '.'){
tokens_seen = true;
- int peek = peekChar ();
+ int peek = peek_char ();
if (peek >= '0' && peek <= '9')
return is_number (c);
return Token.DOT;
continue;
bool directive_expected = false;
- while ((c = getChar ()) != -1) {
+ while ((c = get_char ()) != -1) {
if (col == 1) {
directive_expected = true;
} else if (!directive_expected) {
return consume_string (false);
if (c == '\''){
- c = getChar ();
+ c = get_char ();
tokens_seen = true;
if (c == '\''){
error_details = "Empty character literal";
return Token.ERROR;
val = new System.Char ();
val = (char) c;
- c = getChar ();
+ c = get_char ();
if (c != '\''){
error_details = "Too many characters in character literal";
Report.Error (1012, Location, error_details);
// Try to recover, read until newline or next "'"
- while ((c = getChar ()) != -1){
+ while ((c = get_char ()) != -1){
if (c == '\n'){
break;
}
}
if (c == '@') {
- c = getChar ();
+ c = get_char ();
if (c == '"') {
tokens_seen = true;
return consume_string (true);
private void handle_one_line_xml_comment ()
{
int c;
- while ((c = peekChar ()) == ' ')
- getChar (); // skip heading whitespaces.
- while ((c = peekChar ()) != -1 && c != '\n' && c != '\r') {
- xml_comment_buffer.Append ((char) getChar ());
+ while ((c = peek_char ()) == ' ')
+ get_char (); // skip heading whitespaces.
+ while ((c = peek_char ()) != -1 && c != '\n' && c != '\r') {
+ xml_comment_buffer.Append ((char) get_char ());
}
if (c == '\r' || c == '\n')
xml_comment_buffer.Append (Environment.NewLine);