using System;
using System.Text;
using System.Collections.Generic;
-using System.IO;
using System.Globalization;
-using System.Reflection;
using System.Diagnostics;
namespace Mono.CSharp
escaped_identifiers.Add (loc);
}
- public bool IsEscapedIdentifier (Location loc)
+ public bool IsEscapedIdentifier (MemberName name)
{
- if (escaped_identifiers != null) {
- foreach (Location lt in escaped_identifiers)
- if (lt.Equals (loc))
- return true;
- }
-
- return false;
+ return escaped_identifiers != null && escaped_identifiers.Contains (name.Location);
}
//
static StringBuilder static_cmd_arg = new System.Text.StringBuilder ();
- //
- // Details about the error encoutered by the tokenizer
- //
- string error_details;
-
- public string error {
- get {
- return error_details;
- }
- }
-
public int Line {
get {
return ref_line;
AddKeyword ("while", Token.WHILE);
AddKeyword ("partial", Token.PARTIAL);
AddKeyword ("where", Token.WHERE);
+ AddKeyword ("async", Token.ASYNC);
// LINQ keywords
AddKeyword ("from", Token.FROM);
res = -1;
break;
+
+ case Token.ASYNC:
+ if (parsing_block > 0 || RootContext.Version != LanguageVersion.Future) {
+ res = -1;
+ break;
+ }
+ break;
}
return res;
case Token.IDENTIFIER:
switch (ptoken) {
case Token.DOT:
+ if (bracket_level == 0) {
+ is_type = false;
+ can_be_type = true;
+ }
+
+ continue;
case Token.OP_GENERICS_LT:
case Token.COMMA:
case Token.DOUBLE_COLON:
Report.RegisterWarningRegion (loc).WarningEnable (loc, code, Report);
}
}
- } while (code >= 0 && c != '\n');
+ } while (code >= 0 && c != '\n' && c != -1);
}
return;
int c;
string_builder.Length = 0;
- while ((c = get_char ()) != -1){
- if (c == '"'){
- if (quoted && peek_char () == '"'){
+ while (true){
+ c = get_char ();
+ if (c == '"') {
+ if (quoted && peek_char () == '"') {
string_builder.Append ((char) c);
get_char ();
continue;
- } else {
- val = new StringLiteral (string_builder.ToString (), Location);
- return Token.LITERAL;
}
+
+ val = new StringLiteral (string_builder.ToString (), Location);
+ return Token.LITERAL;
}
- if (c == '\n'){
+ if (c == '\n') {
if (!quoted)
Report.Error (1010, Location, "Newline in constant");
- }
-
- if (!quoted){
+ } else if (c == '\\' && !quoted) {
int surrogate;
c = escape (c, out surrogate);
if (c == -1)
string_builder.Append ((char) c);
c = surrogate;
}
+ } else if (c == -1) {
+ Report.Error (1039, Location, "Unterminated string literal");
+ return Token.EOF;
}
+
string_builder.Append ((char) c);
}
-
- Report.Error (1039, Location, "Unterminated string literal");
- return Token.EOF;
}
private int consume_identifier (int s)
}
} catch (IndexOutOfRangeException) {
Report.Error (645, Location, "Identifier too long (limit is 512 chars)");
- col += pos - 1;
- return Token.ERROR;
+ --pos;
+ col += pos;
}
col += pos - 1;
return consume_identifier (c);
}
- error_details = ((char)c).ToString ();
- return Token.ERROR;
+ Report.Error (1056, Location, "Unexpected character `{0}'", ((char) c).ToString ());
}
if (CompleteOnEOF){
int c = get_char ();
tokens_seen = true;
if (c == '\'') {
- error_details = "Empty character literal";
- Report.Error (1011, Location, error_details);
- return Token.ERROR;
+ val = new CharLiteral ((char) c, Location);
+ Report.Error (1011, Location, "Empty character literal");
+ return Token.LITERAL;
}
+
if (c == '\r' || c == '\n') {
Report.Error (1010, Location, "Newline in constant");
return Token.ERROR;
if (c == '\n' || c == '\'')
break;
}
- return Token.ERROR;
}
return Token.LITERAL;