X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fcs-tokenizer.cs;h=8e107f2682e622ed90c76506c896f3f1b8160d58;hb=739c1b4b78d643395d7558ebd5ee986c49084ef2;hp=825fac6b08e31d1861f9c540685116ce6aa7b831;hpb=bfa189fd30d58effe1f97ced12e8ac734a167d39;p=mono.git
diff --git a/mcs/mcs/cs-tokenizer.cs b/mcs/mcs/cs-tokenizer.cs
index 825fac6b08e..8e107f2682e 100644
--- a/mcs/mcs/cs-tokenizer.cs
+++ b/mcs/mcs/cs-tokenizer.cs
@@ -5,10 +5,10 @@
// Author: Miguel de Icaza (miguel@gnu.org)
// Marek Safar (marek.safar@seznam.cz)
//
-// Licensed under the terms of the GNU GPL
+// Dual licensed under the terms of the MIT X11 or GNU GPL
//
-// (C) 2001, 2002 Ximian, Inc (http://www.ximian.com)
-// (C) 2004 Novell, Inc
+// Copyright 2001, 2002 Ximian, Inc (http://www.ximian.com)
+// Copyright 2004-2008 Novell, Inc
//
//
@@ -29,7 +29,8 @@ namespace Mono.CSharp
{
SeekableStreamReader reader;
SourceFile ref_name;
- SourceFile file_name;
+ CompilationUnit file_name;
+ bool hidden = false;
int ref_line = 1;
int line = 1;
int col = 0;
@@ -38,23 +39,15 @@ namespace Mono.CSharp
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 handle_var = false;
+ bool lambda_arguments_parsing;
Location current_location;
Location current_comment_location = Location.Null;
ArrayList escaped_identifiers = new ArrayList ();
-
-#if GMCS_SOURCE
- bool query_parsing;
-#endif
+ public int parsing_block;
+ internal int query_parsing;
- static bool IsLinqEnabled {
- get {
- return RootContext.Version == LanguageVersion.LINQ;
- }
- }
-
//
// XML documentation buffer. The save point is used to divide
// comments on types and comments on members.
@@ -131,65 +124,30 @@ namespace Mono.CSharp
}
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 bool VarParsing {
- get {
- return handle_var;
- }
-
- set {
- handle_var = value;
- }
- }
-
public XmlCommentState doc_state {
get { return xml_doc_state; }
set {
@@ -281,8 +239,10 @@ namespace Mono.CSharp
Stack position_stack = new Stack (2);
class Position {
public int position;
+ public int line;
public int ref_line;
public int col;
+ public bool hidden;
public int putback_char;
public int previous_col;
public Stack ifstack;
@@ -292,8 +252,10 @@ namespace Mono.CSharp
public Position (Tokenizer t)
{
position = t.reader.Position;
+ line = t.line;
ref_line = t.ref_line;
col = t.col;
+ hidden = t.hidden;
putback_char = t.putback_char;
previous_col = t.previous_col;
if (t.ifstack != null && t.ifstack.Count != 0)
@@ -314,7 +276,9 @@ namespace Mono.CSharp
reader.Position = p.position;
ref_line = p.ref_line;
+ line = p.line;
col = p.col;
+ hidden = p.hidden;
putback_char = p.putback_char;
previous_col = p.previous_col;
ifstack = p.ifstack;
@@ -426,15 +390,9 @@ namespace Mono.CSharp
AddKeyword ("volatile", Token.VOLATILE);
AddKeyword ("while", Token.WHILE);
AddKeyword ("partial", Token.PARTIAL);
-#if GMCS_SOURCE
AddKeyword ("where", Token.WHERE);
- AddKeyword ("var", Token.VAR);
-#endif
- }
-#if GMCS_SOURCE
- public static void InitializeLinqKeywords ()
- {
+ // LINQ keywords
AddKeyword ("from", Token.FROM);
AddKeyword ("join", Token.JOIN);
AddKeyword ("on", Token.ON);
@@ -448,7 +406,6 @@ namespace Mono.CSharp
AddKeyword ("descending", Token.DESCENDING);
AddKeyword ("into", Token.INTO);
}
-#endif
//
// Class initializer
@@ -483,34 +440,66 @@ namespace Mono.CSharp
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 (IsLinqEnabled) {
- if (res == Token.FROM &&
- (current_token == Token.ASSIGN || current_token == Token.OPEN_BRACKET ||
- current_token == Token.RETURN || current_token == Token.IN)) {
- query_parsing = true;
+
+ //
+ // 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 (!query_parsing && res > Token.QUERY_FIRST_TOKEN && res < Token.QUERY_LAST_TOKEN)
+ if (res > Token.QUERY_FIRST_TOKEN && res < Token.QUERY_LAST_TOKEN)
return -1;
-
- return res;
}
- if (!handle_constraints && res == Token.WHERE)
+ if (res == Token.WHERE && !handle_where && query_parsing == 0)
return -1;
- if (res == Token.VAR && (RootContext.Version < LanguageVersion.LINQ || !handle_var || peek_token() != Token.IDENTIFIER))
- return -1;
-#endif
- return res;
+ return res;
}
public Location Location {
@@ -527,7 +516,7 @@ namespace Mono.CSharp
defines [def] = true;
}
- public Tokenizer (SeekableStreamReader input, SourceFile file, ArrayList defs)
+ public Tokenizer (SeekableStreamReader input, CompilationUnit file, ArrayList defs)
{
this.ref_name = file;
this.file_name = file;
@@ -547,7 +536,7 @@ namespace Mono.CSharp
// FIXME: This could be `Location.Push' but we have to
// find out why the MS compiler allows this
//
- Mono.CSharp.Location.Push (file);
+ Mono.CSharp.Location.Push (file, file);
}
static bool is_identifier_start_character (char c)
@@ -566,6 +555,30 @@ namespace Mono.CSharp
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)
{
if (s == null || s.Length == 0)
@@ -640,7 +653,6 @@ namespace Mono.CSharp
return false;
}
-#if GMCS_SOURCE
public void PutbackNullable ()
{
if (nullable_pos < 0)
@@ -669,12 +681,6 @@ namespace Mono.CSharp
nullable_pos = -1;
}
- public bool QueryParsing {
- set {
- query_parsing = value;
- }
- }
-
bool parse_generic_dimension (out int dimension)
{
dimension = 1;
@@ -689,8 +695,7 @@ namespace Mono.CSharp
}
return false;
- }
-#endif
+ }
public int peek_token ()
{
@@ -702,142 +707,7 @@ namespace Mono.CSharp
return the_token;
}
-
- bool parse_namespace_or_typename (int next)
- {
- if (next == -1)
- next = peek_token ();
- while (next == Token.IDENTIFIER){
- token ();
- again:
- next = peek_token ();
- if (next == Token.DOT || next == Token.DOUBLE_COLON){
- token ();
- next = peek_token ();
- continue;
- }
- if (next == Token.OP_GENERICS_LT){
- token ();
- if (!parse_less_than ())
- return false;
- goto again;
- }
- return true;
- }
-
- return false;
- }
-
- bool is_simple_type (int token)
- {
- return (token == Token.BOOL ||
- token == Token.DECIMAL ||
- token == Token.SBYTE ||
- token == Token.BYTE ||
- token == Token.SHORT ||
- token == Token.USHORT ||
- token == Token.INT ||
- token == Token.UINT ||
- token == Token.LONG ||
- token == Token.ULONG ||
- token == Token.CHAR ||
- token == Token.FLOAT ||
- token == Token.DOUBLE);
- }
-
- bool is_builtin_reference_type (int token)
- {
- return (token == Token.OBJECT || token == Token.STRING);
- }
-
- bool parse_opt_rank (int next)
- {
- while (true){
- if (next != Token.OPEN_BRACKET)
- return true;
-
- token ();
- while (true){
- next = token ();
- if (next == Token.CLOSE_BRACKET){
- next = peek_token ();
- break;
- }
- if (next == Token.COMMA)
- continue;
- return false;
- }
- }
- }
-
- bool parse_type ()
- {
- int next = peek_token ();
-
- if (is_simple_type (next)){
- token ();
- next = peek_token ();
- if (next == Token.INTERR)
- token ();
- return parse_opt_rank (peek_token ());
- }
- if (parse_namespace_or_typename (next)){
- next = peek_token ();
- if (next == Token.INTERR)
- token ();
- return parse_opt_rank (peek_token ());
- } else if (is_builtin_reference_type (next)){
- token ();
- return parse_opt_rank (peek_token ());
- }
-
- return false;
- }
-
- //
- // Invoked after '(' has been seen and tries to parse:
- // type identifier [, type identifier]*
- //
- // if this is the case, instead of returning an
- // OPEN_PARENS token we return a special token that
- // triggers lambda parsing.
- //
- // This is needed because we can not introduce the
- // explicitly_typed_lambda_parameter_list after a '(' in the
- // grammar without introducing reduce/reduce conflicts.
- //
- // We need to parse a type and if it is followed by an
- // identifier, we know it has to be parsed as a lambda
- // expression.
- //
- // the type expression can be prefixed with `ref' or `out'
- //
- public bool parse_lambda_parameters ()
- {
- while (true){
- int next = peek_token ();
-
- if (next == Token.REF || next == Token.OUT)
- token ();
-
- if (parse_type ()){
- next = peek_token ();
- if (next == Token.IDENTIFIER){
- token ();
- next = peek_token ();
- if (next == Token.COMMA){
- token ();
- continue;
- }
- if (next == Token.CLOSE_PARENS)
- return true;
- }
- }
- return false;
- }
- }
-
int parsing_generic_less_than = 0;
int is_punct (char c, ref bool doread)
@@ -862,17 +732,20 @@ namespace Mono.CSharp
case ']':
return Token.CLOSE_BRACKET;
case '(':
- if (IsLinqEnabled){
+ if (!lambda_arguments_parsing) {
+ lambda_arguments_parsing = true;
PushPosition ();
- bool have_lambda_parameter = parse_lambda_parameters ();
+ bool lambda_start = IsLambdaOpenParens ();
PopPosition ();
-
- if (have_lambda_parameter)
+ lambda_arguments_parsing = false;
+ if (lambda_start) {
+ if (RootContext.Version <= LanguageVersion.ISO_2)
+ Report.FeatureIsNotAvailable (Location, "lambda expressions");
+
return Token.OPEN_PARENS_LAMBDA;
- else
- return Token.OPEN_PARENS;
- } else
- return Token.OPEN_PARENS;
+ }
+ }
+ return Token.OPEN_PARENS;
case ')': {
if (deambiguate_close_parens == 0)
return Token.CLOSE_PARENS;
@@ -904,16 +777,14 @@ namespace Mono.CSharp
val = Location;
return Token.TILDE;
case '?':
-#if GMCS_SOURCE
d = peek_char ();
if (d == '?') {
get_char ();
return Token.OP_COALESCING;
}
-#endif
return Token.INTERR;
}
-#if GMCS_SOURCE
+
if (c == '<') {
if (parsing_generic_less_than++ > 0)
return Token.OP_GENERICS_LT;
@@ -976,7 +847,7 @@ namespace Mono.CSharp
}
return Token.OP_GT;
}
-#endif
+
d = peek_char ();
if (c == '+'){
@@ -1029,6 +900,7 @@ namespace Mono.CSharp
val = Location;
return Token.ARROW;
}
+
return Token.ASSIGN;
}
@@ -1088,41 +960,6 @@ namespace Mono.CSharp
return Token.CARRET;
}
-#if !GMCS_SOURCE
- if (c == '<'){
- if (d == '<'){
- get_char ();
- d = peek_char ();
-
- 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 == '>'){
- get_char ();
- d = peek_char ();
-
- 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;
@@ -1141,8 +978,10 @@ namespace Mono.CSharp
{
putback (')');
- // When any binary operation is used we are sure it is not a cast
- if (expression is Binary)
+ // When any binary operation, a conditional is used we are sure it is not a cast
+ // maybe more.
+
+ if (expression is Binary || expression is Conditional)
return;
deambiguate_close_parens++;
@@ -1181,7 +1020,7 @@ namespace Mono.CSharp
{
return (e >= '0' && e <= '9') || (e >= 'A' && e <= 'F') || (e >= 'a' && e <= 'f');
}
-
+
static int real_type_suffix (int c)
{
int t;
@@ -1219,7 +1058,7 @@ namespace Mono.CSharp
break;
case 'l':
- if (!is_unsigned && (RootContext.WarningLevel >= 4)){
+ if (!is_unsigned){
//
// if we have not seen anything in between
// report this error
@@ -1579,16 +1418,21 @@ namespace Mono.CSharp
} else
x = reader.Read ();
if (x == '\n') {
- line++;
- ref_line++;
- previous_col = col;
- col = 0;
+ advance_line ();
}
else
col++;
return x;
}
+ void advance_line ()
+ {
+ line++;
+ ref_line++;
+ previous_col = col;
+ col = 0;
+ }
+
int peek_char ()
{
if (putback_char != -1)
@@ -1666,9 +1510,7 @@ namespace Mono.CSharp
case Token.TYPEOF:
case Token.UNCHECKED:
case Token.UNSAFE:
-#if GMCS_SOURCE
case Token.DEFAULT:
-#endif
//
// These can be part of a member access
@@ -1682,6 +1524,8 @@ namespace Mono.CSharp
case Token.DOUBLE:
case Token.FLOAT:
case Token.CHAR:
+ case Token.BYTE:
+ case Token.DECIMAL:
return true;
default:
@@ -1693,7 +1537,6 @@ namespace Mono.CSharp
{
current_token = xtoken ();
-#if GMCS_SOURCE
if (current_token != Token.DEFAULT)
return current_token;
@@ -1707,7 +1550,7 @@ namespace Mono.CSharp
current_token = Token.DEFAULT_COLON;
else
PopPosition();
-#endif
+
return current_token;
}
@@ -1775,12 +1618,11 @@ namespace Mono.CSharp
if (arg == "default"){
ref_line = line;
ref_name = file_name;
- Location.Push (ref_name);
+ hidden = false;
+ Location.Push (file_name, ref_name);
return true;
} else if (arg == "hidden"){
- //
- // We ignore #line hidden
- //
+ hidden = true;
return true;
}
@@ -1795,11 +1637,12 @@ namespace Mono.CSharp
string name = arg.Substring (pos). Trim (quotes);
ref_name = Location.LookupFile (name);
- file_name.HasLineDirective = true;
- ref_name.HasLineDirective = true;
- Location.Push (ref_name);
+ file_name.AddFile (ref_name);
+ hidden = false;
+ Location.Push (file_name, ref_name);
} else {
ref_line = System.Int32.Parse (arg);
+ hidden = false;
}
} catch {
return false;
@@ -1848,6 +1691,126 @@ namespace Mono.CSharp
}
}
+ byte read_hex (string arg, int pos, out bool error)
+ {
+ error = false;
+
+ int total;
+ char c = arg [pos];
+
+ if ((c >= '0') && (c <= '9'))
+ total = (int) c - (int) '0';
+ else if ((c >= 'A') && (c <= 'F'))
+ total = (int) c - (int) 'A' + 10;
+ else if ((c >= 'a') && (c <= 'f'))
+ total = (int) c - (int) 'a' + 10;
+ else {
+ error = true;
+ return 0;
+ }
+
+ total *= 16;
+ c = arg [pos+1];
+
+ if ((c >= '0') && (c <= '9'))
+ total += (int) c - (int) '0';
+ else if ((c >= 'A') && (c <= 'F'))
+ total += (int) c - (int) 'A' + 10;
+ else if ((c >= 'a') && (c <= 'f'))
+ total += (int) c - (int) 'a' + 10;
+ else {
+ error = true;
+ return 0;
+ }
+
+ return (byte) total;
+ }
+
+ ///
+ /// Handles #pragma checksum
+ ///
+ bool PreProcessPragmaChecksum (string arg)
+ {
+ if ((arg [0] != ' ') && (arg [0] != '\t'))
+ return false;
+
+ arg = arg.Trim (simple_whitespaces);
+ if ((arg.Length < 2) || (arg [0] != '"'))
+ return false;
+
+ StringBuilder file_sb = new StringBuilder ();
+
+ int pos = 1;
+ char ch;
+ while ((ch = arg [pos++]) != '"') {
+ if (pos >= arg.Length)
+ return false;
+
+ if (ch == '\\') {
+ if (pos+1 >= arg.Length)
+ return false;
+ ch = arg [pos++];
+ }
+
+ file_sb.Append (ch);
+ }
+
+ if ((pos+2 >= arg.Length) || ((arg [pos] != ' ') && (arg [pos] != '\t')))
+ return false;
+
+ arg = arg.Substring (pos).Trim (simple_whitespaces);
+ if ((arg.Length < 42) || (arg [0] != '"') || (arg [1] != '{') ||
+ (arg [10] != '-') || (arg [15] != '-') || (arg [20] != '-') ||
+ (arg [25] != '-') || (arg [38] != '}') || (arg [39] != '"'))
+ return false;
+
+ bool error;
+ byte[] guid_bytes = new byte [16];
+
+ for (int i = 0; i < 4; i++) {
+ guid_bytes [i] = read_hex (arg, 2+2*i, out error);
+ if (error)
+ return false;
+ }
+ for (int i = 0; i < 2; i++) {
+ guid_bytes [i+4] = read_hex (arg, 11+2*i, out error);
+ if (error)
+ return false;
+ guid_bytes [i+6] = read_hex (arg, 16+2*i, out error);
+ if (error)
+ return false;
+ guid_bytes [i+8] = read_hex (arg, 21+2*i, out error);
+ if (error)
+ return false;
+ }
+
+ for (int i = 0; i < 6; i++) {
+ guid_bytes [i+10] = read_hex (arg, 26+2*i, out error);
+ if (error)
+ return false;
+ }
+
+ arg = arg.Substring (40).Trim (simple_whitespaces);
+ if ((arg.Length < 34) || (arg [0] != '"') || (arg [33] != '"'))
+ return false;
+
+ byte[] checksum_bytes = new byte [16];
+ for (int i = 0; i < 16; i++) {
+ checksum_bytes [i] = read_hex (arg, 1+2*i, out error);
+ if (error)
+ return false;
+ }
+
+ arg = arg.Substring (34).Trim (simple_whitespaces);
+ if (arg.Length > 0)
+ return false;
+
+ SourceFile file = Location.LookupFile (file_sb.ToString ());
+ file.SetChecksum (guid_bytes, checksum_bytes);
+ ref_name.AutoGenerated = true;
+ return true;
+ }
+
///
/// Handles #pragma directive
///
@@ -1856,14 +1819,15 @@ namespace Mono.CSharp
const string warning = "warning";
const string w_disable = "warning disable";
const string w_restore = "warning restore";
+ const string checksum = "checksum";
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;
}
@@ -1892,6 +1856,12 @@ namespace Mono.CSharp
return;
}
+ if (arg.StartsWith (checksum)) {
+ if (!PreProcessPragmaChecksum (arg.Substring (checksum.Length)))
+ Warning_InvalidPragmaChecksum ();
+ return;
+ }
+
Report.Warning (1633, 1, Location, "Unrecognized #pragma directive");
}
@@ -2093,6 +2063,11 @@ namespace Mono.CSharp
"Unexpected processor directive (" + extra + ")");
}
+ void Error_TokenExpected (string token)
+ {
+ Report.Error (1026, Location, "Expected `{0}'", token);
+ }
+
void Error_TokensSeen ()
{
Report.Error (1032, Location,
@@ -2110,6 +2085,13 @@ namespace Mono.CSharp
Report.Error (1025, Location, "Single-line comment or end-of-line expected");
}
+ void Warning_InvalidPragmaChecksum ()
+ {
+ Report.Warning (1695, 1, Location,
+ "Invalid #pragma checksum syntax; should be " +
+ "#pragma checksum \"filename\" " +
+ "\"{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}\" \"XXXX...\"");
+ }
//
// if true, then the code continues processing the code
// if false, the code stays in a loop until another directive is
@@ -2294,7 +2276,7 @@ namespace Mono.CSharp
case "pragma":
if (RootContext.Version == LanguageVersion.ISO_1) {
- Report.FeatureIsNotISO1 (Location, "#pragma");
+ Report.FeatureIsNotAvailable (Location, "#pragma");
return true;
}
@@ -2318,7 +2300,13 @@ namespace Mono.CSharp
{
int c;
string_builder.Length = 0;
-
+
+ //
+ // 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 && peek_char () == '"'){
@@ -2362,25 +2350,34 @@ namespace Mono.CSharp
}
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 (RootContext.Version == LanguageVersion.ISO_1)
- Report.FeatureIsNotISO1 (Location, "partial types");
+ 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;
@@ -2396,7 +2393,7 @@ namespace Mono.CSharp
id_builder [0] = (char) s;
- current_location = new Location (ref_line, Col);
+ current_location = new Location (ref_line, hidden ? -1 : Col);
while ((c = get_char ()) != -1) {
loop:
@@ -2488,7 +2485,9 @@ namespace Mono.CSharp
continue;
if (c == '\r') {
- if (peek_char () == '\n')
+ if (peek_char () != '\n')
+ advance_line ();
+ else
get_char ();
any_token_seen |= tokens_seen;
@@ -2582,7 +2581,7 @@ namespace Mono.CSharp
}
is_punct_label:
- current_location = new Location (ref_line, Col);
+ current_location = new Location (ref_line, hidden ? -1 : Col);
if ((t = is_punct ((char)c, ref doread)) != Token.ERROR){
tokens_seen = true;
if (doread){
@@ -2765,7 +2764,7 @@ namespace Mono.CSharp
if (current_comment_location.IsNull) {
// "-2" is for heading "//" or "/*"
current_comment_location =
- new Location (ref_line, col - 2);
+ new Location (ref_line, hidden ? -1 : col - 2);
}
}
@@ -2817,7 +2816,7 @@ namespace Mono.CSharp
public void cleanup ()
{
if (ifstack != null && ifstack.Count >= 1) {
- current_location = new Location (ref_line, Col);
+ current_location = new Location (ref_line, hidden ? -1 : Col);
int state = (int) ifstack.Pop ();
if ((state & REGION) != 0)
Report.Error (1038, Location, "#endregion directive expected");