module Ast where
import Lexer (Position(..))

-- Constants : variables, numbers, etc.
data Constant_ =
  Letter Char
  | Number String
  | GreekLetter String
  | StdFun String
  -- Operation symbols
  | Add | Sub | Mul | Mmul | Mmmul | Sslash | Bbslash
  | Times | Div | Comp | Oplus | Otimes | Odot
  | Sum | Prod | Wedge | Wwedge | Vv | Vvv | Nn | Nnn | Uu | Uuu
  -- Miscellaneous symbols
  | Inte | Oint | Del | Grad | Addsub | Void | Infty | Aleph
  | Angle | Therefore | Abs | Cdots | Vdots | Ddots | Bslash
  | Quad | Diamond | Square | Lfloor | Rfloor | Lceil | Rceil
  | Cc | Ensnn | Qq | Rr | Zz | Space
  -- Relation symbols
  | Eq | Neq | Lt | Gt | Le | Ge | Prec | Succ
  | In | Notin | Subset | Supset | Subsete | Supsete
  | Mod | Congr | Approx | Prop
  -- Logical symbols
  | And | Or | Not | Implies | If | Iff | Forall | Exists
  | Falsum | Taut | Turnstile | Tturnstile
  Arrows
  | Uarr | Darr | Larr | To
  | Mapsto | Harr | Llarr
  Additionnal symbols
  | Comma | Dot | Semicolon | Quote | Facto
  deriving (Show, Eq)
data Constant = Constant Constant_ Position deriving (Show, Eq)

  Unary operators
data UnaryOp_ =
  Usqrt | Utext
  | Ubb | Ubbb | Ucc | Utt | Ufr | Usf
  | Utilde | Uhat | Ubar | Uul | Uvec | Udot | Uddot
  deriving (Show, Eq)
data UnaryOp = UnaryOp UnaryOp_ Position deriving (Show, Eq)

-- Binary operators
data BinaryOp_ = BFrac | BRoot | BStackRel deriving (Show, Eq)
data BinaryOp = BinaryOp BinaryOp_ Position deriving (Show, Eq)

-- Left brackets
data LBracket_ = LPar | LCro | LBra | LChe | LBraCons deriving (Show, Eq)
data LBracket = LBracket LBracket_ Position deriving (Show, Eq)

-- Right brackets
data RBracket_ = RPar | RCro | RBra | RChe | RBraCons deriving (Show, Eq)
data RBracket = RBracket RBracket_ Position deriving (Show, Eq)

-- Matrix type
data MatrixType = RawMatrix | ColMatrix deriving (Show, Eq)

-- Simple expressions
data SimpleExpr_ =
  SEConst Constant
  | Delimited LBracket Code RBracket
  | Matrix MatrixType [[Code]]
  | UnaryApp UnaryOp SimpleExpr
  | BinaryApp BinaryOp SimpleExpr SimpleExpr
  raw text , redered in a 
  deriving(Show, Eq)
data SimpleExpr = SimpleExpr SimpleExpr_ Position deriving (Show, Eq)

-- Global expressions
data Expr_ =
  Simple SimpleExpr
  | Frac SimpleExpr SimpleExpr
  | Under SimpleExpr SimpleExpr
  | Super SimpleExpr SimpleExpr
  | SubSuper SimpleExpr SimpleExpr SimpleExpr
  deriving (Show, Eq)
data Expr = Expr Expr_ Position deriving (Show, Eq)

-- Whole asciimath code
type Code = [Expr]

 Constants : variables, numbers, etc.
 Operation symbols
 Miscellaneous symbols
 Relation symbols
 Logical symbols
 Binary operators
 Left brackets
 Right brackets
 Matrix type
 Simple expressions
 Global expressions
 Whole asciimath code
module Ast where
import Lexer (Position(..))

data Constant_ =
  Letter Char
  | Number String
  | GreekLetter String
  | StdFun String
  | Add | Sub | Mul | Mmul | Mmmul | Sslash | Bbslash
  | Times | Div | Comp | Oplus | Otimes | Odot
  | Sum | Prod | Wedge | Wwedge | Vv | Vvv | Nn | Nnn | Uu | Uuu
  | Inte | Oint | Del | Grad | Addsub | Void | Infty | Aleph
  | Angle | Therefore | Abs | Cdots | Vdots | Ddots | Bslash
  | Quad | Diamond | Square | Lfloor | Rfloor | Lceil | Rceil
  | Cc | Ensnn | Qq | Rr | Zz | Space
  | Eq | Neq | Lt | Gt | Le | Ge | Prec | Succ
  | In | Notin | Subset | Supset | Subsete | Supsete
  | Mod | Congr | Approx | Prop
  | And | Or | Not | Implies | If | Iff | Forall | Exists
  | Falsum | Taut | Turnstile | Tturnstile
  Arrows
  | Uarr | Darr | Larr | To
  | Mapsto | Harr | Llarr
  Additionnal symbols
  | Comma | Dot | Semicolon | Quote | Facto
  deriving (Show, Eq)
data Constant = Constant Constant_ Position deriving (Show, Eq)

  Unary operators
data UnaryOp_ =
  Usqrt | Utext
  | Ubb | Ubbb | Ucc | Utt | Ufr | Usf
  | Utilde | Uhat | Ubar | Uul | Uvec | Udot | Uddot
  deriving (Show, Eq)
data UnaryOp = UnaryOp UnaryOp_ Position deriving (Show, Eq)

data BinaryOp_ = BFrac | BRoot | BStackRel deriving (Show, Eq)
data BinaryOp = BinaryOp BinaryOp_ Position deriving (Show, Eq)

data LBracket_ = LPar | LCro | LBra | LChe | LBraCons deriving (Show, Eq)
data LBracket = LBracket LBracket_ Position deriving (Show, Eq)

data RBracket_ = RPar | RCro | RBra | RChe | RBraCons deriving (Show, Eq)
data RBracket = RBracket RBracket_ Position deriving (Show, Eq)

data MatrixType = RawMatrix | ColMatrix deriving (Show, Eq)

data SimpleExpr_ =
  SEConst Constant
  | Delimited LBracket Code RBracket
  | Matrix MatrixType [[Code]]
  | UnaryApp UnaryOp SimpleExpr
  | BinaryApp BinaryOp SimpleExpr SimpleExpr
  raw text , redered in a 
  deriving(Show, Eq)
data SimpleExpr = SimpleExpr SimpleExpr_ Position deriving (Show, Eq)

data Expr_ =
  Simple SimpleExpr
  | Frac SimpleExpr SimpleExpr
  | Under SimpleExpr SimpleExpr
  | Super SimpleExpr SimpleExpr
  | SubSuper SimpleExpr SimpleExpr SimpleExpr
  deriving (Show, Eq)
data Expr = Expr Expr_ Position deriving (Show, Eq)

type Code = [Expr]
