bool handle_assembly = false;
bool handle_constraints = false;
bool handle_typeof = false;
- bool linq;
+ bool query_parsing;
Location current_location;
Location current_comment_location = Location.Null;
ArrayList escapedIdentifiers = new ArrayList ();
+ static bool linq;
+
//
// XML documentation buffer. The save point is used to divide
// comments on types and comments on members.
}
}
+ public static bool LinqEnabled {
+ set {
+ linq = value;
+ }
+ }
+
public bool TypeOfParsing {
get {
return handle_typeof;
}
}
+ public bool QueryParsing {
+ set {
+ query_parsing = value;
+ }
+ }
+
public XmlCommentState doc_state {
get { return xmlDocState; }
set {
// Class variables
//
static CharArrayHashtable[] keywords;
- static Hashtable keywordStrings = new Hashtable ();
+ static Hashtable keywordStrings;
static NumberStyles styles;
static NumberFormatInfo csharp_format_info;
position_stack.Pop ();
}
- static void AddKeyword (string kw, int token) {
+ static void AddKeyword (string kw, int token)
+ {
keywordStrings.Add (kw, kw);
if (keywords [kw.Length] == null) {
keywords [kw.Length] = new CharArrayHashtable (kw.Length);
static void InitTokens ()
{
+ keywordStrings = new Hashtable ();
keywords = new CharArrayHashtable [64];
AddKeyword ("__arglist", Token.ARGLIST);
AddKeyword ("partial", Token.PARTIAL);
#if GMCS_SOURCE
AddKeyword ("where", Token.WHERE);
+
+ if (linq) {
+ 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);
+ }
#endif
}
// Class initializer
//
static Tokenizer ()
+ {
+ Reset ();
+ }
+
+ public static void Reset ()
{
InitTokens ();
csharp_format_info = NumberFormatInfo.InvariantInfo;
styles = NumberStyles.Float;
-
+
string_builder = new System.Text.StringBuilder ();
}
if (handle_assembly == false && res == Token.ASSEMBLY)
return -1;
#if GMCS_SOURCE
- if (handle_constraints == false && res == Token.WHERE)
+ if (linq) {
+ if (res == Token.FROM &&
+ (current_token == Token.ASSIGN || current_token == Token.OPEN_BRACKET ||
+ current_token == Token.RETURN || current_token == Token.IN)) {
+ query_parsing = true;
+ return res;
+ }
+
+ if (!query_parsing && res > Token.QUERY_FIRST_TOKEN && res < Token.QUERY_LAST_TOKEN)
+ return -1;
+
+ return res;
+ }
+
+ if (!handle_constraints && res == Token.WHERE)
return -1;
#endif
return res;
{
this.ref_name = file;
this.file_name = file;
- linq = RootContext.Version == LanguageVersion.LINQ;
reader = input;
putback_char = -1;
continue;
}
- if (c == ' ' || c == '\t' || c == '\f' || c == '\v' || c == 0xa0)
+ if (c == ' ' || c == '\f' || c == '\v' || c == 0xa0 || c == 0)
continue;
if (c == '\r') {