Microsoft.JScript.JSKeyword.GetKeyword C# (CSharp) Method

GetKeyword() private method

private GetKeyword ( Context token, int length ) : JSToken
token Context
length int
return JSToken
      internal JSToken GetKeyword(Context token, int length){
        JSKeyword keyword = this;

      nextToken:
        while (null != keyword){
          if (length == keyword.length){
            // we know the first char has to match
            for (int i = 1, j = token.startPos + 1; i < length; i++, j++){
              char ch1 = keyword.name[i];
              char ch2 = token.source_string[j];
              if (ch1 == ch2)
                continue;
              else if (ch2 < ch1)
                return JSToken.Identifier;
              else{
                keyword = keyword.next;
                goto nextToken;
              }
            }
            return keyword.token;
          }else if (length < keyword.length)
            return JSToken.Identifier;

          keyword = keyword.next;
        }
        return JSToken.Identifier;
      }

Usage Example

 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);
 }
All Usage Examples Of Microsoft.JScript.JSKeyword::GetKeyword