parseUnary method

Expression parseUnary()

Implementation

Expression parseUnary() {
  switch (token!.type) {
    case Token.UNARY:
      Token operator = next();
      Expression exp = parseUnary();
      return UnaryExpression(operator.text, exp)
        ..start = operator.startOffset
        ..end = endOffset
        ..line = operator.line;

    case Token.UPDATE:
      Token operator = next();
      Expression exp = parseUnary();
      return UpdateExpression.prefix(operator.text, exp)
        ..start = operator.startOffset
        ..end = endOffset
        ..line = operator.line;

    case Token.NAME:
      if (token!.text == 'delete' ||
          token!.text == 'void' ||
          token!.text == 'typeof') {
        Token operator = next();
        Expression exp = parseUnary();
        return UnaryExpression(operator.text, exp)
          ..start = operator.startOffset
          ..end = endOffset
          ..line = operator.line;
      }
      break;
  }
  return parsePostfix();
}