private JSKeyword(JSToken token, string name, JSKeyword next) { this.name = name; this.next = next; this.token = token; this.length = this.name.Length; }
internal JSToken GetKeyword(Context token, int length) { for (JSKeyword next = this; next != null; next = next.next) { if (length == next.length) { int num = 1; for (int i = token.startPos + 1; num < length; i++) { char ch = next.name[num]; char ch2 = token.source_string[i]; if (ch != ch2) { if (ch2 < ch) { return(JSToken.Identifier); } next = next.next; continue; } num++; } return(next.token); } if (length < next.length) { return(JSToken.Identifier); } } return(JSToken.Identifier); }
private JSToken ScanKeyword(JSKeyword keyword){ for(;;){ char c = GetChar(this.currentPos); if ('a' <= c && c <= 'z'){ this.currentPos++; continue; }else{ if (IsIdentifierPartChar(c)){ ScanIdentifier(); return JSToken.Identifier; } break; } } return keyword.GetKeyword(this.currentToken, this.currentPos - this.currentToken.startPos); }
internal static JSKeyword[] InitKeywords() { JSKeyword[] keywordArray = new JSKeyword[0x1a]; JSKeyword next = new JSKeyword(JSToken.Abstract, "abstract"); next = new JSKeyword(JSToken.Assert, "assert", next); keywordArray[0] = next; next = new JSKeyword(JSToken.Boolean, "boolean"); next = new JSKeyword(JSToken.Break, "break", next); next = new JSKeyword(JSToken.Byte, "byte", next); keywordArray[1] = next; next = new JSKeyword(JSToken.Continue, "continue"); next = new JSKeyword(JSToken.Const, "const", next); next = new JSKeyword(JSToken.Class, "class", next); next = new JSKeyword(JSToken.Catch, "catch", next); next = new JSKeyword(JSToken.Char, "char", next); next = new JSKeyword(JSToken.Case, "case", next); keywordArray[2] = next; next = new JSKeyword(JSToken.Debugger, "debugger"); next = new JSKeyword(JSToken.Default, "default", next); next = new JSKeyword(JSToken.Double, "double", next); next = new JSKeyword(JSToken.Delete, "delete", next); next = new JSKeyword(JSToken.Do, "do", next); keywordArray[3] = next; next = new JSKeyword(JSToken.Extends, "extends"); next = new JSKeyword(JSToken.Export, "export", next); next = new JSKeyword(JSToken.Ensure, "ensure", next); next = new JSKeyword(JSToken.Event, "event", next); next = new JSKeyword(JSToken.Enum, "enum", next); next = new JSKeyword(JSToken.Else, "else", next); keywordArray[4] = next; next = new JSKeyword(JSToken.Function, "function"); next = new JSKeyword(JSToken.Finally, "finally", next); next = new JSKeyword(JSToken.Float, "float", next); next = new JSKeyword(JSToken.Final, "final", next); next = new JSKeyword(JSToken.False, "false", next); next = new JSKeyword(JSToken.For, "for", next); keywordArray[5] = next; next = new JSKeyword(JSToken.Goto, "goto"); next = new JSKeyword(JSToken.Get, "get", next); keywordArray[6] = next; next = new JSKeyword(JSToken.Instanceof, "instanceof"); next = new JSKeyword(JSToken.Implements, "implements", next); next = new JSKeyword(JSToken.Invariant, "invariant", next); next = new JSKeyword(JSToken.Interface, "interface", next); next = new JSKeyword(JSToken.Internal, "internal", next); next = new JSKeyword(JSToken.Import, "import", next); next = new JSKeyword(JSToken.Int, "int", next); next = new JSKeyword(JSToken.In, "in", next); next = new JSKeyword(JSToken.If, "if", next); keywordArray[8] = next; next = new JSKeyword(JSToken.Long, "long"); keywordArray[11] = next; next = new JSKeyword(JSToken.Namespace, "namespace"); next = new JSKeyword(JSToken.Native, "native", next); next = new JSKeyword(JSToken.Null, "null", next); next = new JSKeyword(JSToken.New, "new", next); keywordArray[13] = next; next = new JSKeyword(JSToken.Protected, "protected"); next = new JSKeyword(JSToken.Private, "private", next); next = new JSKeyword(JSToken.Package, "package", next); next = new JSKeyword(JSToken.Public, "public", next); keywordArray[15] = next; next = new JSKeyword(JSToken.Require, "require"); next = new JSKeyword(JSToken.Return, "return", next); keywordArray[0x11] = next; next = new JSKeyword(JSToken.Synchronized, "synchronized"); next = new JSKeyword(JSToken.Switch, "switch", next); next = new JSKeyword(JSToken.Static, "static", next); next = new JSKeyword(JSToken.Super, "super", next); next = new JSKeyword(JSToken.Short, "short", next); next = new JSKeyword(JSToken.Set, "set", next); keywordArray[0x12] = next; next = new JSKeyword(JSToken.Transient, "transient"); next = new JSKeyword(JSToken.Typeof, "typeof", next); next = new JSKeyword(JSToken.Throws, "throws", next); next = new JSKeyword(JSToken.Throw, "throw", next); next = new JSKeyword(JSToken.True, "true", next); next = new JSKeyword(JSToken.This, "this", next); next = new JSKeyword(JSToken.Try, "try", next); keywordArray[0x13] = next; next = new JSKeyword(JSToken.Volatile, "volatile"); next = new JSKeyword(JSToken.Void, "void", next); next = new JSKeyword(JSToken.Var, "var", next); keywordArray[0x15] = next; next = new JSKeyword(JSToken.Use, "use"); keywordArray[20] = next; next = new JSKeyword(JSToken.While, "while"); next = new JSKeyword(JSToken.With, "with", next); keywordArray[0x16] = next; return keywordArray; }
internal JSToken GetKeyword(Context token, int length) { for (JSKeyword next = this; next != null; next = next.next) { if (length == next.length) { int num = 1; for (int i = token.startPos + 1; num < length; i++) { char ch = next.name[num]; char ch2 = token.source_string[i]; if (ch != ch2) { if (ch2 < ch) { return JSToken.Identifier; } next = next.next; continue; } num++; } return next.token; } if (length < next.length) { return JSToken.Identifier; } } return JSToken.Identifier; }
private JSToken ScanKeyword(JSKeyword keyword) { char ch; while (true) { ch = this.GetChar(this.currentPos); if (('a' > ch) || (ch > 'z')) { break; } this.currentPos++; } if (this.IsIdentifierPartChar(ch)) { this.ScanIdentifier(); return JSToken.Identifier; } return keyword.GetKeyword(this.currentToken, this.currentPos - this.currentToken.startPos); }
internal static JSKeyword[] InitKeywords() { JSKeyword[] keywordArray = new JSKeyword[0x1a]; JSKeyword next = new JSKeyword(JSToken.Abstract, "abstract"); next = new JSKeyword(JSToken.Assert, "assert", next); keywordArray[0] = next; next = new JSKeyword(JSToken.Boolean, "boolean"); next = new JSKeyword(JSToken.Break, "break", next); next = new JSKeyword(JSToken.Byte, "byte", next); keywordArray[1] = next; next = new JSKeyword(JSToken.Continue, "continue"); next = new JSKeyword(JSToken.Const, "const", next); next = new JSKeyword(JSToken.Class, "class", next); next = new JSKeyword(JSToken.Catch, "catch", next); next = new JSKeyword(JSToken.Char, "char", next); next = new JSKeyword(JSToken.Case, "case", next); keywordArray[2] = next; next = new JSKeyword(JSToken.Debugger, "debugger"); next = new JSKeyword(JSToken.Default, "default", next); next = new JSKeyword(JSToken.Double, "double", next); next = new JSKeyword(JSToken.Delete, "delete", next); next = new JSKeyword(JSToken.Do, "do", next); keywordArray[3] = next; next = new JSKeyword(JSToken.Extends, "extends"); next = new JSKeyword(JSToken.Export, "export", next); next = new JSKeyword(JSToken.Ensure, "ensure", next); next = new JSKeyword(JSToken.Event, "event", next); next = new JSKeyword(JSToken.Enum, "enum", next); next = new JSKeyword(JSToken.Else, "else", next); keywordArray[4] = next; next = new JSKeyword(JSToken.Function, "function"); next = new JSKeyword(JSToken.Finally, "finally", next); next = new JSKeyword(JSToken.Float, "float", next); next = new JSKeyword(JSToken.Final, "final", next); next = new JSKeyword(JSToken.False, "false", next); next = new JSKeyword(JSToken.For, "for", next); keywordArray[5] = next; next = new JSKeyword(JSToken.Goto, "goto"); next = new JSKeyword(JSToken.Get, "get", next); keywordArray[6] = next; next = new JSKeyword(JSToken.Instanceof, "instanceof"); next = new JSKeyword(JSToken.Implements, "implements", next); next = new JSKeyword(JSToken.Invariant, "invariant", next); next = new JSKeyword(JSToken.Interface, "interface", next); next = new JSKeyword(JSToken.Internal, "internal", next); next = new JSKeyword(JSToken.Import, "import", next); next = new JSKeyword(JSToken.Int, "int", next); next = new JSKeyword(JSToken.In, "in", next); next = new JSKeyword(JSToken.If, "if", next); keywordArray[8] = next; next = new JSKeyword(JSToken.Long, "long"); keywordArray[11] = next; next = new JSKeyword(JSToken.Namespace, "namespace"); next = new JSKeyword(JSToken.Native, "native", next); next = new JSKeyword(JSToken.Null, "null", next); next = new JSKeyword(JSToken.New, "new", next); keywordArray[13] = next; next = new JSKeyword(JSToken.Protected, "protected"); next = new JSKeyword(JSToken.Private, "private", next); next = new JSKeyword(JSToken.Package, "package", next); next = new JSKeyword(JSToken.Public, "public", next); keywordArray[15] = next; next = new JSKeyword(JSToken.Require, "require"); next = new JSKeyword(JSToken.Return, "return", next); keywordArray[0x11] = next; next = new JSKeyword(JSToken.Synchronized, "synchronized"); next = new JSKeyword(JSToken.Switch, "switch", next); next = new JSKeyword(JSToken.Static, "static", next); next = new JSKeyword(JSToken.Super, "super", next); next = new JSKeyword(JSToken.Short, "short", next); next = new JSKeyword(JSToken.Set, "set", next); keywordArray[0x12] = next; next = new JSKeyword(JSToken.Transient, "transient"); next = new JSKeyword(JSToken.Typeof, "typeof", next); next = new JSKeyword(JSToken.Throws, "throws", next); next = new JSKeyword(JSToken.Throw, "throw", next); next = new JSKeyword(JSToken.True, "true", next); next = new JSKeyword(JSToken.This, "this", next); next = new JSKeyword(JSToken.Try, "try", next); keywordArray[0x13] = next; next = new JSKeyword(JSToken.Volatile, "volatile"); next = new JSKeyword(JSToken.Void, "void", next); next = new JSKeyword(JSToken.Var, "var", next); keywordArray[0x15] = next; next = new JSKeyword(JSToken.Use, "use"); keywordArray[20] = next; next = new JSKeyword(JSToken.While, "while"); next = new JSKeyword(JSToken.With, "with", next); keywordArray[0x16] = next; return(keywordArray); }