objectField()

in lib/parser.js [1175:1219]


  objectField() {
    // objectField = objectFieldName "=" expr
    const begin = this.getIndex();
    if(this.is(Tag.STRING)) { 
      const fieldName = this.look;
      this.move();
      this.match('=');
      const expr = this.expr();
      const end = this.getIndex();
      return {
        type: 'objectField',
        fieldName: fieldName,
        expr: expr,
        tokenRange: [begin, end]
      };
    }

    if (this.isID()) {
      const fieldName = this.fieldName();
      this.match('=');
      const expr = this.expr();
      const end = this.getIndex();
      return {
        type: 'objectField',
        fieldName: fieldName,
        expr: expr,
        tokenRange: [begin, end]
      };
    }

    if (this.look.tag === '.') {
      this.move();
      this.match('.');
      this.match('.');
      let expr = this.expr();
      const end = this.getIndex();
      return {
        type: 'expandField',
        expr: expr,
        tokenRange: [begin, end]
      };
    }

    this.error('expect "..." or ID');
  }