mirror of
https://github.com/adelphes/android-dev-ext.git
synced 2025-12-23 01:48:18 +00:00
add support for prefix/postfix inc expressions
This commit is contained in:
@@ -87,6 +87,18 @@ class UnaryOpExpression extends ParsedExpression {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class IncOpExpression extends ParsedExpression {
|
||||||
|
/**
|
||||||
|
* @param {'e++'|'e--'|'++e'|'--e'} which
|
||||||
|
* @param {ParsedExpression} expression
|
||||||
|
*/
|
||||||
|
constructor(which, expression) {
|
||||||
|
super();
|
||||||
|
this.which = which;
|
||||||
|
this.expression = expression;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class TernaryExpression extends ParsedExpression {
|
class TernaryExpression extends ParsedExpression {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -287,7 +299,23 @@ function getBinaryOperator(s) {
|
|||||||
* @returns {ParsedExpression}
|
* @returns {ParsedExpression}
|
||||||
*/
|
*/
|
||||||
function parse_expression(e) {
|
function parse_expression(e) {
|
||||||
|
const prefix_incdec = e.expr.match(/^(?:(\+\+)|\-\-)(?=[a-zA-Z_])/);
|
||||||
|
if (prefix_incdec) {
|
||||||
|
strip(e, 2);
|
||||||
|
}
|
||||||
let res = parse_expression_term(e);
|
let res = parse_expression_term(e);
|
||||||
|
if (prefix_incdec) {
|
||||||
|
res = new IncOpExpression(e.expr[1] ? '++e' : '--e', res);
|
||||||
|
}
|
||||||
|
|
||||||
|
const postfix_incdec = e.expr.match(/^(?:(\+\+)|\-\-)(?![+-])/);
|
||||||
|
if (postfix_incdec) {
|
||||||
|
if (prefix_incdec) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
strip(e, 2);
|
||||||
|
res = new IncOpExpression(e.expr[1] ? 'e++' : 'e--', res);
|
||||||
|
}
|
||||||
|
|
||||||
for (; ;) {
|
for (; ;) {
|
||||||
const binary_operator = getBinaryOperator(e.expr);
|
const binary_operator = getBinaryOperator(e.expr);
|
||||||
|
|||||||
Reference in New Issue
Block a user