public static Keyword InitExtendedKeywords() { // This is a linked list of keywords starting with __ // In the list, the keywords are sorted first by length, and then lexicographically. // So the constructor invocations must occur in the opposite order. Keyword keyword; // __ keyword = new Keyword(Token.RefValue, "__refvalue"); keyword = new Keyword(Token.RefType, "__reftype", keyword); keyword = new Keyword(Token.MakeRef, "__makeref", keyword); keyword = new Keyword(Token.ArgList, "__arglist", keyword); return keyword; }
private Keyword(Token token, string name, bool specSharp, Keyword next) //^ requires name.Length > 0; { this.name = name; this.next = next; this.token = token; this.length = name.Length; this.specSharp = specSharp; }
internal static Keyword/*?*/[] InitKeywords() { // There is a linked list for each letter. // In each list, the keywords are sorted first by length, and then lexicographically. // So the constructor invocations must occur in the opposite order. Keyword/*?*/[] keywords = new Keyword/*?*/[26]; Keyword keyword; // a keyword = new Keyword(Token.Abstract, "abstract"); keyword = new Keyword(Token.Acquire, "acquire", true, keyword); keyword = new Keyword(Token.Assume, "assume", true, keyword); keyword = new Keyword(Token.Assert, "assert", true, keyword); keyword = new Keyword(Token.Alias, "alias", keyword); keyword = new Keyword(Token.Add, "add", keyword); keyword = new Keyword(Token.As, "as", keyword); keywords['a' - 'a'] = keyword; // b keyword = new Keyword(Token.Break, "break"); keyword = new Keyword(Token.Byte, "byte", keyword); keyword = new Keyword(Token.Bool, "bool", keyword); keyword = new Keyword(Token.Base, "base", keyword); keywords['b' - 'a'] = keyword; // c keyword = new Keyword(Token.Continue, "continue"); keyword = new Keyword(Token.Checked, "checked", keyword); keyword = new Keyword(Token.Count, "count", true, keyword); keyword = new Keyword(Token.Const, "const", keyword); keyword = new Keyword(Token.Class, "class", keyword); keyword = new Keyword(Token.Catch, "catch", keyword); keyword = new Keyword(Token.Char, "char", keyword); keyword = new Keyword(Token.Case, "case", keyword); keywords['c' - 'a'] = keyword; // d keyword = new Keyword(Token.Delegate, "delegate"); keyword = new Keyword(Token.Default, "default", keyword); keyword = new Keyword(Token.Decimal, "decimal", keyword); keyword = new Keyword(Token.Double, "double", keyword); keyword = new Keyword(Token.Do, "do", keyword); keywords['d' - 'a'] = keyword; // e keyword = new Keyword(Token.ElementsSeen, "elements_seen", true); keyword = new Keyword(Token.Explicit, "explicit", keyword); keyword = new Keyword(Token.Ensures, "ensures", true, keyword); keyword = new Keyword(Token.Extern, "extern", keyword); keyword = new Keyword(Token.Expose, "expose", true, keyword); keyword = new Keyword(Token.Exists, "exists", true, keyword); keyword = new Keyword(Token.Event, "event", keyword); keyword = new Keyword(Token.Enum, "enum", keyword); keyword = new Keyword(Token.Else, "else", keyword); keywords['e' - 'a'] = keyword; // f keyword = new Keyword(Token.Foreach, "foreach"); keyword = new Keyword(Token.Finally, "finally", keyword); keyword = new Keyword(Token.Forall, "forall", true, keyword); keyword = new Keyword(Token.Float, "float", keyword); keyword = new Keyword(Token.Fixed, "fixed", keyword); keyword = new Keyword(Token.False, "false", keyword); keyword = new Keyword(Token.For, "for", keyword); keywords['f' - 'a'] = keyword; // g keyword = new Keyword(Token.Goto, "goto"); keyword = new Keyword(Token.Get, "get", keyword); keywords['g' - 'a'] = keyword; // i keyword = new Keyword(Token.Invariant, "invariant", true); keyword = new Keyword(Token.Interface, "interface", keyword); keyword = new Keyword(Token.Internal, "internal", keyword); keyword = new Keyword(Token.Implicit, "implicit", keyword); keyword = new Keyword(Token.Int, "int", keyword); keyword = new Keyword(Token.Is, "is", keyword); keyword = new Keyword(Token.In, "in", keyword); keyword = new Keyword(Token.If, "if", keyword); keywords['i' - 'a'] = keyword; //l keyword = new Keyword(Token.Long, "long"); keyword = new Keyword(Token.Lock, "lock", keyword); keywords['l' - 'a'] = keyword; // n keyword = new Keyword(Token.Namespace, "namespace"); keyword = new Keyword(Token.Null, "null", keyword); keyword = new Keyword(Token.New, "new", keyword); keywords['n' - 'a'] = keyword; // m keyword = new Keyword(Token.Modifies, "modifies", true); keywords['m' - 'a'] = keyword; // o keyword = new Keyword(Token.Otherwise, "otherwise"); keyword = new Keyword(Token.Override, "override", keyword); keyword = new Keyword(Token.Operator, "operator", keyword); keyword = new Keyword(Token.Object, "object", keyword); keyword = new Keyword(Token.Out, "out", keyword); keyword = new Keyword(Token.Old, "old", true, keyword); keywords['o' - 'a'] = keyword; // p keyword = new Keyword(Token.Protected, "protected"); keyword = new Keyword(Token.Private, "private", keyword); keyword = new Keyword(Token.Partial, "partial", keyword); keyword = new Keyword(Token.Public, "public", keyword); keyword = new Keyword(Token.Params, "params", keyword); keywords['p' - 'a'] = keyword; // r keyword = new Keyword(Token.Requires, "requires", true); keyword = new Keyword(Token.Readonly, "readonly", keyword); keyword = new Keyword(Token.Return, "return", keyword); keyword = new Keyword(Token.Remove, "remove", keyword); keyword = new Keyword(Token.Read, "read", true, keyword); keyword = new Keyword(Token.Ref, "ref", keyword); keywords['r' - 'a'] = keyword; // s keyword = new Keyword(Token.Stackalloc, "stackalloc"); keyword = new Keyword(Token.Switch, "switch", keyword); keyword = new Keyword(Token.Struct, "struct", keyword); keyword = new Keyword(Token.String, "string", keyword); keyword = new Keyword(Token.Static, "static", keyword); keyword = new Keyword(Token.Sizeof, "sizeof", keyword); keyword = new Keyword(Token.Sealed, "sealed", keyword); keyword = new Keyword(Token.Short, "short", keyword); keyword = new Keyword(Token.Sbyte, "sbyte", keyword); keyword = new Keyword(Token.Set, "set", keyword); keywords['s' - 'a'] = keyword; // t keyword = new Keyword(Token.Typeof, "typeof"); keyword = new Keyword(Token.Throws, "throws", true, keyword); keyword = new Keyword(Token.Throw, "throw", keyword); keyword = new Keyword(Token.True, "true", keyword); keyword = new Keyword(Token.This, "this", keyword); keyword = new Keyword(Token.Try, "try", keyword); keywords['t' - 'a'] = keyword; // u keyword = new Keyword(Token.Unchecked, "unchecked"); keyword = new Keyword(Token.Ushort, "ushort", keyword); keyword = new Keyword(Token.Unsafe, "unsafe", keyword); keyword = new Keyword(Token.Unique, "unique", keyword); keyword = new Keyword(Token.Using, "using", keyword); keyword = new Keyword(Token.Ulong, "ulong", keyword); keyword = new Keyword(Token.Uint, "uint", keyword); keywords['u' - 'a'] = keyword; // v keyword = new Keyword(Token.Volatile, "volatile"); keyword = new Keyword(Token.Virtual, "virtual", keyword); keyword = new Keyword(Token.Value, "value", keyword); keyword = new Keyword(Token.Void, "void", keyword); keyword = new Keyword(Token.Var, "var", true, keyword); keywords['v' - 'a'] = keyword; // w keyword = new Keyword(Token.Write, "write"); keyword = new Keyword(Token.While, "while", keyword); keyword = new Keyword(Token.Where, "where", keyword); keywords['w' - 'a'] = keyword; // y keyword = new Keyword(Token.Yield, "yield"); keywords['y' - 'a'] = keyword; return keywords; }
private Keyword(Token token, string name, Keyword next) //^ requires name.Length > 0; { this.name = name; this.next = next; this.token = token; this.length = name.Length; }