/**
 * @file include/main.h
 * @brief Define macros and data types for evaluating expr of comp number
 */

#pragma once
#include "matop.h"
#include <stdio.h>

constexpr size_t buf_size = 64;

//! @brief Set of types to handle
typedef enum {
  RTYPE_REAL = 0x01,
  RTYPE_COMP = 0x02,
  RTYPE_MATR = 0x04,
  RTYPE_LAMB = 0x08,
} rtype_t /* result type */;

//! @brief Wrapper of types to handle
typedef union {
  double real;
  comp comp;
  matrix_t matr;
  char *lamb;
} result_t;

//! @brief Tagged union of types to handle
typedef struct {
  result_t elem;
  rtype_t rtype;
} elem_t;

typedef struct {
  union {
    double real;
    char *lamb;
  } elem;
  bool isnum;
} real_t;

void procAList(int, char const **);
void readerLoop(FILE *);
void printElem(elem_t);
void printReal(double);
void printComplexComplex(comp);
void printComplexPolar(comp);
void printMatrix(matrix_t);
void printLambda(char const *);
void procCmds(char const *);
overloadable void printany(elem_t);

extern void (*print_complex)(comp);