Location current_comment_location = Location.Null;
ArrayList escaped_identifiers = new ArrayList ();
public int parsing_block;
-
-#if GMCS_SOURCE
internal int query_parsing;
-#endif
- 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.
AddKeyword ("volatile", Token.VOLATILE);
AddKeyword ("while", Token.WHILE);
AddKeyword ("partial", Token.PARTIAL);
-#if GMCS_SOURCE
AddKeyword ("where", Token.WHERE);
// LINQ keywords
AddKeyword ("ascending", Token.ASCENDING);
AddKeyword ("descending", Token.DESCENDING);
AddKeyword ("into", Token.INTO);
-#endif
}
//
return -1;
if (!handle_assembly && res == Token.ASSEMBLY)
return -1;
-#if GMCS_SOURCE
+
//
// A query expression is any expression that starts with `from identifier'
// followed by any token except ; , =
if (res == Token.WHERE && !handle_where && query_parsing == 0)
return -1;
-#endif
- return res;
+ return res;
}
public Location Location {
case Token.STAR:
case Token.SEMICOLON:
+ case Token.OPEN_BRACE:
case Token.OPEN_PARENS:
+ case Token.LITERAL_STRING:
return false;
}
}
- Error_TokenExpected (")");
+ Error_TokenExpected (",' or `)");
return false;
}
return false;
}
-#if GMCS_SOURCE
public void PutbackNullable ()
{
if (nullable_pos < 0)
}
return false;
- }
-#endif
+ }
public int peek_token ()
{
case ']':
return Token.CLOSE_BRACKET;
case '(':
- if (IsLinqEnabled && !lambda_arguments_parsing) {
+ if (!lambda_arguments_parsing) {
lambda_arguments_parsing = true;
PushPosition ();
bool lambda_start = IsLambdaOpenParens ();
PopPosition ();
lambda_arguments_parsing = false;
- if (lambda_start)
+ if (lambda_start) {
+ if (RootContext.Version <= LanguageVersion.ISO_2)
+ Report.FeatureIsNotAvailable (Location, "lambda expressions");
+
return Token.OPEN_PARENS_LAMBDA;
+ }
}
return Token.OPEN_PARENS;
case ')': {
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;
}
return Token.OP_GT;
}
-#endif
+
d = peek_char ();
if (c == '+'){
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;
} 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)
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;
}
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;
}
void Error_TokenExpected (string token)
{
- Report.Error (1026, Location, "Expecting `{0}'", token);
+ Report.Error (1026, Location, "Expected `{0}'", token);
}
void Error_TokensSeen ()
{
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 () == '"'){
PopPosition ();
if (ok) {
- if (RootContext.Version == LanguageVersion.ISO_2 && next_token == Token.VOID) {
- Report.FeatureIsNotAvailable (Location, "partial methods");
+ 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");
continue;
if (c == '\r') {
- if (peek_char () == '\n')
+ if (peek_char () != '\n')
+ advance_line ();
+ else
get_char ();
any_token_seen |= tokens_seen;