bool handle_get_set = false;
bool handle_remove_add = false;
bool handle_where;
- bool handle_typeof = false;
bool lambda_arguments_parsing;
List<Location> escaped_identifiers;
int parsing_generic_less_than;
get { return handle_where; }
set { handle_where = value; }
}
-
- public bool TypeOfParsing {
- get { return handle_typeof; }
- set { handle_typeof = value; }
- }
public XmlCommentState doc_state {
get { return xml_doc_state; }
case Token.BYTE:
case Token.CHAR:
case Token.DECIMAL:
+ case Token.DOUBLE:
case Token.FLOAT:
case Token.LONG:
case Token.OBJECT:
if (c < 0x80)
return false;
- return Char.IsLetter (c) || Char.GetUnicodeCategory (c) == UnicodeCategory.ConnectorPunctuation;
+ return is_identifier_part_character_slow_part (c);
+ }
+
+ static bool is_identifier_part_character_slow_part (char c)
+ {
+ if (Char.IsLetter (c))
+ return true;
+
+ switch (Char.GetUnicodeCategory (c)) {
+ case UnicodeCategory.ConnectorPunctuation:
+
+ // combining-character: A Unicode character of classes Mn or Mc
+ case UnicodeCategory.NonSpacingMark:
+ case UnicodeCategory.SpacingCombiningMark:
+
+ // decimal-digit-character: A Unicode character of the class Nd
+ case UnicodeCategory.DecimalDigitNumber:
+ return true;
+ }
+
+ return false;
}
public static bool IsKeyword (string s)
return true;
}
- bool parse_less_than ()
+ bool parse_less_than (ref int genericDimension)
{
start:
int the_token = token ();
case Token.VOID:
break;
case Token.OP_GENERICS_GT:
+ genericDimension = 1;
+ return true;
case Token.IN:
case Token.OUT:
return true;
+ case Token.COMMA:
+ do {
+ ++genericDimension;
+ the_token = token ();
+ } while (the_token == Token.COMMA);
+ if (the_token == Token.OP_GENERICS_GT) {
+ ++genericDimension;
+ return true;
+ }
+
+ return false;
default:
return false;
}
else if (the_token == Token.INTERR_NULLABLE || the_token == Token.STAR)
goto again;
else if (the_token == Token.OP_GENERICS_LT) {
- if (!parse_less_than ())
+ if (!parse_less_than (ref genericDimension))
return false;
goto again;
} else if (the_token == Token.OPEN_BRACKET) {
return false;
}
- 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;
return Token.OP_COALESCING;
}
- switch (current_token) {
- case Token.CLOSE_PARENS:
- case Token.TRUE:
- case Token.FALSE:
- case Token.NULL:
- case Token.LITERAL:
- return Token.INTERR;
+ if (d == '.') {
+ return Token.INTERR_OPERATOR;
}
if (d != ' ') {
PushPosition ();
current_token = Token.NONE;
int next_token;
- switch (xtoken ()) {
+ int parens = 0;
+ int generics = 0;
+
+ var nt = xtoken ();
+ switch (nt) {
+ case Token.DOT:
+ case Token.OPEN_BRACKET_EXPR:
+ next_token = Token.INTERR_OPERATOR;
+ break;
case Token.LITERAL:
case Token.TRUE:
case Token.FALSE:
case Token.COLON:
next_token = Token.INTERR_NULLABLE;
break;
-
+
+ case Token.OPEN_PARENS:
+ case Token.OPEN_PARENS_CAST:
+ case Token.OPEN_PARENS_LAMBDA:
+ next_token = -1;
+ ++parens;
+ break;
+
+ case Token.OP_GENERICS_LT:
+ case Token.OP_GENERICS_LT_DECL:
+ case Token.GENERIC_DIMENSION:
+ next_token = -1;
+ ++generics;
+ break;
+
default:
next_token = -1;
break;
case Token.COMMA:
case Token.SEMICOLON:
case Token.OPEN_BRACE:
- case Token.CLOSE_PARENS:
case Token.IN:
next_token = Token.INTERR_NULLABLE;
break;
case Token.COLON:
next_token = Token.INTERR;
- break;
-
+ break;
+
+ case Token.OPEN_PARENS:
+ case Token.OPEN_PARENS_CAST:
+ case Token.OPEN_PARENS_LAMBDA:
+ ++parens;
+ goto default;
+
+ case Token.CLOSE_PARENS:
+ --parens;
+ goto default;
+
+ case Token.OP_GENERICS_LT:
+ case Token.OP_GENERICS_LT_DECL:
+ case Token.GENERIC_DIMENSION:
+ ++generics;
+ goto default;
+
default:
int ntoken;
int interrs = 1;
int colons = 0;
int braces = 0;
- int parens = 0;
+ int brackets = 0;
//
// All shorcuts failed, do it hard way
//
case Token.CLOSE_BRACE:
--braces;
continue;
+ case Token.OP_GENERICS_LT:
+ case Token.OP_GENERICS_LT_DECL:
+ case Token.GENERIC_DIMENSION:
+ ++generics;
+ continue;
+ case Token.OPEN_BRACKET:
+ case Token.OPEN_BRACKET_EXPR:
+ ++brackets;
+ continue;
+ case Token.CLOSE_BRACKET:
+ --brackets;
+ continue;
case Token.CLOSE_PARENS:
- if (parens > 0)
+ if (parens > 0) {
--parens;
- continue;
+ continue;
+ }
+
+ PopPosition ();
+ return Token.INTERR_NULLABLE;
+
+ case Token.OP_GENERICS_GT:
+ if (generics > 0) {
+ --generics;
+ continue;
+ }
+
+ PopPosition ();
+ return Token.INTERR_NULLABLE;
}
if (braces != 0)
if (parens != 0)
continue;
+
+ if (ntoken == Token.COMMA) {
+ if (generics != 0 || brackets != 0)
+ continue;
+
+ PopPosition ();
+ return Token.INTERR_NULLABLE;
+ }
if (ntoken == Token.COLON) {
if (++colons == interrs)
continue;
}
- } else if (Char.IsLetter ((char) c) || Char.GetUnicodeCategory ((char) c) == UnicodeCategory.ConnectorPunctuation) {
+ } else if (is_identifier_part_character_slow_part ((char) c)) {
id_builder [pos++] = (char) c;
continue;
}
int TokenizeLessThan ()
{
int d;
- if (handle_typeof) {
- PushPosition ();
- if (parse_generic_dimension (out d)) {
- val = d;
- DiscardPosition ();
- return Token.GENERIC_DIMENSION;
- }
- PopPosition ();
- }
// Save current position and parse next token.
PushPosition ();
- if (parse_less_than ()) {
+ int generic_dimension = 0;
+ if (parse_less_than (ref generic_dimension)) {
if (parsing_generic_declaration && (parsing_generic_declaration_doc || token () != Token.DOT)) {
d = Token.OP_GENERICS_LT_DECL;
} else {
+ if (generic_dimension > 0) {
+ val = generic_dimension;
+ DiscardPosition ();
+ return Token.GENERIC_DIMENSION;
+ }
+
d = Token.OP_GENERICS_LT;
}
PopPosition ();