Code coverage report for src/lexer/property.js

Statements: 67.92% (36 / 53)      Branches: 54.76% (23 / 42)      Functions: 100% (3 / 3)      Lines: 70% (35 / 50)      Ignored: none     

All files » src/lexer/ » property.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77          1   17 17 3 3   3     14   14 14 14               8 8 3 3 3 3 3 3 3           5 5 5   5       15 15 5 5 10 5 5 5               5     5   5 5            
/*!
 * Copyright (C) 2017 Glayzzle (BSD3 License)
 * @authors https://github.com/glayzzle/php-parser/graphs/contributors
 * @url http://glayzzle.com
 */
module.exports = {
  matchST_LOOKING_FOR_PROPERTY: function() {
    var ch = this.input();
    if (ch === '-') {
      ch = this.input();
      Eif (ch === '>') {
        // https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.l#L1296
        return this.tok.T_OBJECT_OPERATOR;
      }
      if (ch) this.unput(1);
    } else Eif (this.is_LABEL_START()) {
      // https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.l#L1300
      this.consume_LABEL();
      this.popState();
      return this.tok.T_STRING;
    }
    // https://github.com/php/php-src/blob/master/Zend/zend_language_scanner.l#L1306
    this.popState();
    if (ch) this.unput(1);
    return false;
  },
  matchST_LOOKING_FOR_VARNAME: function() {
    var ch = this.input();
    if (this.is_LABEL_START()) {
      this.consume_LABEL();
      ch = this.input();
      this.popState();
      Eif (ch === '[' || ch === '}') {
        this.begin('ST_IN_SCRIPTING');
        this.unput(1);
        return this.tok.T_STRING_VARNAME;
      } else {
        this.unput(this.yytext.length);
        return false;
      }
    } else {
      Eif (ch) this.unput(1);
      this.popState();
      this.begin('ST_IN_SCRIPTING');
      // console.log(this.yylineno, 'ST_LOOKING_FOR_VARNAME', this._input[this.offset - 1], this.conditionStack);
      return false;
    }
  },
  matchST_VAR_OFFSET: function() {
    var ch = this.input();
    if (this.is_NUM()) {
      this.consume_NUM();
      return this.tok.T_NUM_STRING;
    } else if (ch === ']') {
      this.popState();
      return ']';
    } else Iif (ch === '$') {
      this.input();
      if (this.is_LABEL_START()) {
        this.consume_LABEL();
        return this.tok.T_VARIABLE;
      } else {
        throw new Error('Unexpected terminal');
      }
    } else Iif (this.is_LABEL_START()) {
      this.consume_LABEL();
      return this.tok.T_STRING;
    } else Iif (this.is_WHITESPACE() || ch === '\\' || ch === '\'' || ch === '#') {
      return this.tok.T_ENCAPSED_AND_WHITESPACE;
    } else Eif (ch === '[' || ch === '{' || ch === '}' || ch === '"' || ch === '`' || this.is_TOKEN()) {
      return ch;
    } else {
      throw new Error('Unexpected terminal');
    }
  }
};