{-# LANGUAGE DeriveDataTypeable #-}
module Language.BASIC.Types where
import Data.Typeable

infix 0 :=
data Expr a
    = Cmd Integer Command [Expr a]
    | Str String
    | Dbl Double
    | Label Integer
    | Binop (Expr a) String (Expr a)
    | Expr a := Expr a
    | RND (Expr a) | INT (Expr a) | SGN (Expr a)
    | Var
    | I | S | X | Y | Z
    | None
    deriving (Eq, Ord, Show, Typeable)

cmdLabel :: Expr a -> Integer
cmdLabel (Cmd l _ _) = l
cmdLabel e = error $ "Strange top level command " ++ show e

data Command = Print | End | Let | Goto | Gosub | Return | If | Input | For | Next | Rem
    deriving (Eq, Ord, Show, Typeable)

type BASIC = Expr ()