()
| 1064 | } |
| 1065 | |
| 1066 | private parsePrefix(): AST { |
| 1067 | if (this.next.type == TokenType.Operator) { |
| 1068 | const start = this.inputIndex; |
| 1069 | const operator = this.next.strValue; |
| 1070 | let result: AST; |
| 1071 | switch (operator) { |
| 1072 | case '+': |
| 1073 | this.advance(); |
| 1074 | result = this.parsePrefix(); |
| 1075 | return Unary.createPlus(this.span(start), this.sourceSpan(start), result); |
| 1076 | case '-': |
| 1077 | this.advance(); |
| 1078 | result = this.parsePrefix(); |
| 1079 | return Unary.createMinus(this.span(start), this.sourceSpan(start), result); |
| 1080 | case '!': |
| 1081 | this.advance(); |
| 1082 | result = this.parsePrefix(); |
| 1083 | return new PrefixNot(this.span(start), this.sourceSpan(start), result); |
| 1084 | case '++': |
| 1085 | case '--': { |
| 1086 | this.advance(); |
| 1087 | const operand = this.parsePrefix(); |
| 1088 | return this.validateIncrementDecrementTarget(operand) |
| 1089 | ? Unary.createPrefixUpdate(this.span(start), this.sourceSpan(start), operator, operand) |
| 1090 | : new EmptyExpr(this.span(start), this.sourceSpan(start)); |
| 1091 | } |
| 1092 | } |
| 1093 | } else if (this.next.isKeywordTypeof()) { |
| 1094 | const start = this.inputIndex; |
| 1095 | this.advance(); |
| 1096 | const result = this.parsePrefix(); |
| 1097 | return new TypeofExpression(this.span(start), this.sourceSpan(start), result); |
| 1098 | } else if (this.next.isKeywordVoid()) { |
| 1099 | const start = this.inputIndex; |
| 1100 | this.advance(); |
| 1101 | const result = this.parsePrefix(); |
| 1102 | return new VoidExpression(this.span(start), this.sourceSpan(start), result); |
| 1103 | } |
| 1104 | return this.parseCallChain(); |
| 1105 | } |
| 1106 | |
| 1107 | private parseCallChain(): AST { |
| 1108 | const start = this.inputIndex; |
no test coverage detected