parseUnary method

Expression parseUnary()

Implementation

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

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

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