当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript StringWrapper.charCodeAt方法代码示例

本文整理汇总了TypeScript中angular2/src/facade/lang.StringWrapper.charCodeAt方法的典型用法代码示例。如果您正苦于以下问题:TypeScript StringWrapper.charCodeAt方法的具体用法?TypeScript StringWrapper.charCodeAt怎么用?TypeScript StringWrapper.charCodeAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/src/facade/lang.StringWrapper的用法示例。


在下文中一共展示了StringWrapper.charCodeAt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: scanComplexOperator

 scanComplexOperator(start:int, code:int, one:string, two:string):Token {
   assert(this.peek == StringWrapper.charCodeAt(one, 0));
   this.advance();
   var str:string = one;
   if (this.peek == code) {
     this.advance();
     str += two;
   }
   assert(SetWrapper.has(OPERATORS, str));
   return newOperatorToken(start, str);
 }
开发者ID:tavwizard,项目名称:angular,代码行数:11,代码来源:lexer.ts

示例2: scanComplexOperator

 /**
  * Tokenize a 2/3 char long operator
  *
  * @param start start index in the expression
  * @param one first symbol (always part of the operator)
  * @param twoCode code point for the second symbol
  * @param two second symbol (part of the operator when the second code point matches)
  * @param threeCode code point for the third symbol
  * @param three third symbol (part of the operator when provided and matches source expression)
  * @returns {Token}
  */
 scanComplexOperator(start: number, one: string, twoCode: number, two: string, threeCode?: number,
                     three?: string): Token {
   assert(this.peek == StringWrapper.charCodeAt(one, 0));
   this.advance();
   var str: string = one;
   if (this.peek == twoCode) {
     this.advance();
     str += two;
   }
   if (isPresent(threeCode) && this.peek == threeCode) {
     this.advance();
     str += three;
   }
   assert(SetWrapper.has(OPERATORS, str));
   return newOperatorToken(start, str);
 }
开发者ID:B-Thapa,项目名称:angular,代码行数:27,代码来源:lexer.ts

示例3: scanOperator

 scanOperator(start:int, str:string):Token {
   assert(this.peek == StringWrapper.charCodeAt(str, 0));
   assert(SetWrapper.has(OPERATORS, str));
   this.advance();
   return newOperatorToken(start, str);
 }
开发者ID:tavwizard,项目名称:angular,代码行数:6,代码来源:lexer.ts

示例4: scanToken

  scanToken():Token {
    var input = this.input,
      length = this.length,
      peek = this.peek,
      index = this.index;

    // Skip whitespace.
    while (peek <= $SPACE) {
      if (++index >= length) {
        peek = $EOF;
        break;
      } else {
        peek = StringWrapper.charCodeAt(input, index);
      }
    }

    this.peek = peek;
    this.index = index;

    if (index >= length) {
      return null;
    }

    // Handle identifiers and numbers.
    if (isIdentifierStart(peek)) return this.scanIdentifier();
    if (isDigit(peek)) return this.scanNumber(index);

    var start:int = index;
    switch (peek) {
      case $PERIOD:
        this.advance();
        return isDigit(this.peek) ? this.scanNumber(start) :
          newCharacterToken(start, $PERIOD);
      case $LPAREN:   case $RPAREN:
      case $LBRACE:   case $RBRACE:
      case $LBRACKET: case $RBRACKET:
      case $COMMA:
      case $COLON:
      case $SEMICOLON:
        return this.scanCharacter(start, peek);
      case $SQ:
      case $DQ:
        return this.scanString();
      case $HASH:
        return this.scanOperator(start, StringWrapper.fromCharCode(peek));
      case $PLUS:
      case $MINUS:
      case $STAR:
      case $SLASH:
      case $PERCENT:
      case $CARET:
      case $QUESTION:
        return this.scanOperator(start, StringWrapper.fromCharCode(peek));
      case $LT:
      case $GT:
      case $BANG:
      case $EQ:
        return this.scanComplexOperator(start, $EQ, StringWrapper.fromCharCode(peek), '=');
      case $AMPERSAND:
        return this.scanComplexOperator(start, $AMPERSAND, '&', '&');
      case $BAR:
        return this.scanComplexOperator(start, $BAR, '|', '|');
      case $TILDE:
        return this.scanComplexOperator(start, $SLASH, '~', '/');
      case $NBSP:
        while (isWhitespace(this.peek)) this.advance();
        return this.scanToken();
    }

    this.error(`Unexpected character [${StringWrapper.fromCharCode(peek)}]`, 0);
    return null;
  }
开发者ID:tavwizard,项目名称:angular,代码行数:72,代码来源:lexer.ts

示例5: advance

 advance() {
   this.peek = ++this.index >= this.length ? $EOF : StringWrapper.charCodeAt(this.input, this.index);
 }
开发者ID:tavwizard,项目名称:angular,代码行数:3,代码来源:lexer.ts

示例6: expectCharacterToken

function expectCharacterToken(token, index, character) {
  expect(character.length).toBe(1);
  expectToken(token, index);
  expect(token.isCharacter(StringWrapper.charCodeAt(character, 0))).toBe(true);
}
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:5,代码来源:lexer_spec.ts


注:本文中的angular2/src/facade/lang.StringWrapper.charCodeAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。