/*!
* 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');
}
}
};
|