Ejemplo n.º 1
0
        internal static Keyword[] InitKeywords()
        {
            // you'll have to add the longer keywords first!

            Keyword[] keywords = new Keyword[26];
            Keyword keyword;
            // a
            keyword = new Keyword(Token.Activate, "activate");
            keyword = new Keyword(Token.Atomic, "atomic", keyword);
            keyword = new Keyword(Token.Assume, "assume", keyword);
            keyword = new Keyword(Token.Assert, "assert", keyword);
            keyword = new Keyword(Token.Accept, "accept", keyword);
            keyword = new Keyword(Token.Async, "async", keyword);
            keyword = new Keyword(Token.Array, "array", keyword);
            keywords['a' - 'a'] = keyword;
            // b
            keyword = new Keyword(Token.Byte, "byte");
            keyword = new Keyword(Token.Bool, "bool", keyword);
            keywords['b' - 'a'] = keyword;
            // c
            keyword = new Keyword(Token.Choose, "choose");
            keyword = new Keyword(Token.Class, "class", keyword);
            keyword = new Keyword(Token.Chan, "chan", keyword);
            keywords['c' - 'a'] = keyword;
            // d
            keyword = new Keyword(Token.Decimal, "decimal");
            keyword = new Keyword(Token.Double, "double", keyword);
            keywords['d' - 'a'] = keyword;
            // e
            keyword = new Keyword(Token.Event, "event", keyword);
            keyword = new Keyword(Token.Enum, "enum", keyword);
            keyword = new Keyword(Token.Else, "else", keyword);
            keyword = new Keyword(Token.End, "end", keyword);
            keywords['e' - 'a'] = keyword;
            // f
            keyword = new Keyword(Token.Foreach, "foreach");
            keyword = new Keyword(Token.Float, "float", keyword);
            keyword = new Keyword(Token.First, "first", keyword);
            keyword = new Keyword(Token.False, "false", keyword);
            keywords['f' - 'a'] = keyword;
            // g
            keyword = new Keyword(Token.Goto, "goto");
            keywords['g' - 'a'] = keyword;
            // i
            keyword = new Keyword(Token.InvokeShed, "invokescheduler");
            keyword = new Keyword(Token.InvokePlugin, "invokeplugin", keyword);
            keyword = new Keyword(Token.Interface, "interface", keyword);
            keyword = new Keyword(Token.Int, "int", 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");
            keywords['l' - 'a'] = keyword;
            // n
            keyword = new Keyword(Token.Null, "null");
            keyword = new Keyword(Token.New, "new", keyword);
            keywords['n' - 'a'] = keyword;
            // o
            keyword = new Keyword(Token.Object, "object");
            keyword = new Keyword(Token.Out, "out", keyword);
            keywords['o' - 'a'] = keyword;

            // r
            keyword = new Keyword(Token.Receive, "receive");
            keyword = new Keyword(Token.Return, "return", keyword);
            keyword = new Keyword(Token.Range, "range", keyword);
            keyword = new Keyword(Token.Raise, "raise", keyword);
            keywords['r' - 'a'] = keyword;

            // s
            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.Select, "select", keyword);
            keyword = new Keyword(Token.Short, "short", keyword);
            keyword = new Keyword(Token.SByte, "sbyte", keyword);
            keyword = new Keyword(Token.Send, "send", keyword);
            keyword = new Keyword(Token.Self, "self", keyword);
            keyword = new Keyword(Token.Set, "set", keyword);

            keywords['s' - 'a'] = keyword;
            // t
            keyword = new Keyword(Token.Timeout, "timeout");
            keyword = new Keyword(Token.Typeof, "typeof", keyword);
            keyword = new Keyword(Token.Trace, "trace", 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.UShort, "ushort");
            keyword = new Keyword(Token.ULong, "ulong", keyword);
            keyword = new Keyword(Token.UInt, "uint", keyword);
            keywords['u' - 'a'] = keyword;
            // v
            keyword = new Keyword(Token.Visible, "visible");
            keyword = new Keyword(Token.Void, "void", keyword);
            keywords['v' - 'a'] = keyword;
            // w
            keyword = new Keyword(Token.While, "while");
            keyword = new Keyword(Token.With, "with", keyword);
            keyword = new Keyword(Token.Wait, "wait", keyword);
            keywords['w' - 'a'] = keyword;
            // y
            keyword = new Keyword(Token.Yield, "yield");
            keywords['y' - 'a'] = keyword;

            return keywords;
        }
Ejemplo n.º 2
0
 private Keyword(Token token, string name, Keyword next)
 {
     this.name = name;
     this.next = next;
     this.token = token;
     this.length = this.name.Length;
 }