```ts
export function readSexpr(text: string): number | string | any[] {
  if (typeof text !== 'string' || !text.trim()) throw new Error('Invalid input');

  const tokens = text.match(/-?\d+|[a-zA-Z0-9+\-*/!?]+|\(|\)/g);
  if (!tokens) throw new Error('Invalid input');

  function parse(): any {
    const token = tokens.shift();
    if (token === '(') {
      const result: any[] = [];
      while (tokens[0] !== ')') {
        result.push(parse());
      }
      tokens.shift(); // consume the closing parenthesis
      return result;
    } else if (token === ')') {
      throw new Error('Unclosed list');
    } else if (/^-?\d+$/.test(token)) {
      return parseInt(token, 10);
    } else if (/^[a-zA-Z0-9+\-*/!?]+$/.test(token)) {
      return token;
    } else {
      throw new Error(`Invalid atom: ${token}`);
    }
  }

  const result = parse();
  if (tokens.length > 0) throw new Error('Extra characters after expression');
  return result;
}
```