module Parser.Ast where
import Data.Text (Text)
import MaybeVoid (MaybeVoid)
data Program = Program
{
Program -> [VarDecl]
topLevelVarDecls :: [VarDecl],
Program -> [FunctionDef]
topLevelFunctionDefs :: [FunctionDef]
}
deriving (Int -> Program -> ShowS
[Program] -> ShowS
Program -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Program] -> ShowS
$cshowList :: [Program] -> ShowS
show :: Program -> String
$cshow :: Program -> String
showsPrec :: Int -> Program -> ShowS
$cshowsPrec :: Int -> Program -> ShowS
Show)
data FunctionDef = FunctionDef {FunctionDef -> Identifier
funcName :: Identifier, FunctionDef -> Function
func :: Function}
deriving (Int -> FunctionDef -> ShowS
[FunctionDef] -> ShowS
FunctionDef -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionDef] -> ShowS
$cshowList :: [FunctionDef] -> ShowS
show :: FunctionDef -> String
$cshow :: FunctionDef -> String
showsPrec :: Int -> FunctionDef -> ShowS
$cshowsPrec :: Int -> FunctionDef -> ShowS
Show)
data Expression
=
ExprValue Value
|
ExprIdentifier Identifier
|
ExprUnaryOp UnaryOp Expression
|
ExprBinaryOp BinaryOp Expression Expression
|
ExprArrayAccessByIndex Expression Expression
|
ExprFuncCall Expression [Expression]
|
ExprLenFuncCall Expression
|
ExprPrintFuncCall [Expression]
|
ExprPrintlnFuncCall [Expression]
|
ExprPanicFuncCall Expression
deriving (Int -> Expression -> ShowS
[Expression] -> ShowS
Expression -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Expression] -> ShowS
$cshowList :: [Expression] -> ShowS
show :: Expression -> String
$cshow :: Expression -> String
showsPrec :: Int -> Expression -> ShowS
$cshowsPrec :: Int -> Expression -> ShowS
Show)
data BinaryOp
=
OrOp
|
AndOp
|
EqOp
|
NeOp
|
LeOp
|
LtOp
|
MeOp
|
MtOp
|
PlusOp
|
MinusOp
|
MultOp
|
DivOp
|
ModOp
deriving (Int -> BinaryOp -> ShowS
[BinaryOp] -> ShowS
BinaryOp -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BinaryOp] -> ShowS
$cshowList :: [BinaryOp] -> ShowS
show :: BinaryOp -> String
$cshow :: BinaryOp -> String
showsPrec :: Int -> BinaryOp -> ShowS
$cshowsPrec :: Int -> BinaryOp -> ShowS
Show)
data UnaryOp
=
UnaryPlusOp
|
UnaryMinusOp
|
NotOp
deriving (Int -> UnaryOp -> ShowS
[UnaryOp] -> ShowS
UnaryOp -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnaryOp] -> ShowS
$cshowList :: [UnaryOp] -> ShowS
show :: UnaryOp -> String
$cshow :: UnaryOp -> String
showsPrec :: Int -> UnaryOp -> ShowS
$cshowsPrec :: Int -> UnaryOp -> ShowS
Show)
data Type
=
TInt
|
TBool
|
TString
|
TArray ArrayType
|
TFunction FunctionType
deriving (Int -> Type -> ShowS
[Type] -> ShowS
Type -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Type] -> ShowS
$cshowList :: [Type] -> ShowS
show :: Type -> String
$cshow :: Type -> String
showsPrec :: Int -> Type -> ShowS
$cshowsPrec :: Int -> Type -> ShowS
Show)
data ArrayType = ArrayType {ArrayType -> Type
arrElementT :: Type, ArrayType -> Expression
arrLength :: Expression}
deriving (Int -> ArrayType -> ShowS
[ArrayType] -> ShowS
ArrayType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ArrayType] -> ShowS
$cshowList :: [ArrayType] -> ShowS
show :: ArrayType -> String
$cshow :: ArrayType -> String
showsPrec :: Int -> ArrayType -> ShowS
$cshowsPrec :: Int -> ArrayType -> ShowS
Show)
data FunctionType = FunctionType {FunctionType -> [Type]
funcParamsTs :: [Type], FunctionType -> MaybeVoid Type
funcResultT :: MaybeVoid Type}
deriving (Int -> FunctionType -> ShowS
[FunctionType] -> ShowS
FunctionType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionType] -> ShowS
$cshowList :: [FunctionType] -> ShowS
show :: FunctionType -> String
$cshow :: FunctionType -> String
showsPrec :: Int -> FunctionType -> ShowS
$cshowsPrec :: Int -> FunctionType -> ShowS
Show)
data Statement
=
StmtReturn (MaybeVoid Expression)
|
StmtForGoTo ForGoTo
|
StmtFor For
|
StmtVarDecl VarDecl
|
StmtIfElse IfElse
|
StmtBlock Block
|
StmtSimple SimpleStmt
deriving (Int -> Statement -> ShowS
[Statement] -> ShowS
Statement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Statement] -> ShowS
$cshowList :: [Statement] -> ShowS
show :: Statement -> String
$cshow :: Statement -> String
showsPrec :: Int -> Statement -> ShowS
$cshowsPrec :: Int -> Statement -> ShowS
Show)
type Block = [Statement]
data ForGoTo
=
Break
|
Continue
deriving (Int -> ForGoTo -> ShowS
[ForGoTo] -> ShowS
ForGoTo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ForGoTo] -> ShowS
$cshowList :: [ForGoTo] -> ShowS
show :: ForGoTo -> String
$cshow :: ForGoTo -> String
showsPrec :: Int -> ForGoTo -> ShowS
$cshowsPrec :: Int -> ForGoTo -> ShowS
Show)
data For = For {For -> ForHead
forHead :: ForHead, For -> [Statement]
forBody :: Block}
deriving (Int -> For -> ShowS
[For] -> ShowS
For -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [For] -> ShowS
$cshowList :: [For] -> ShowS
show :: For -> String
$cshow :: For -> String
showsPrec :: Int -> For -> ShowS
$cshowsPrec :: Int -> For -> ShowS
Show)
data ForHead = ForHead
{ ForHead -> Maybe SimpleStmt
forPreStmt :: Maybe SimpleStmt,
ForHead -> Maybe Expression
forCondition :: Maybe Expression,
ForHead -> Maybe SimpleStmt
forPostStmt :: Maybe SimpleStmt
}
deriving (Int -> ForHead -> ShowS
[ForHead] -> ShowS
ForHead -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ForHead] -> ShowS
$cshowList :: [ForHead] -> ShowS
show :: ForHead -> String
$cshow :: ForHead -> String
showsPrec :: Int -> ForHead -> ShowS
$cshowsPrec :: Int -> ForHead -> ShowS
Show)
data VarDecl = VarDecl {VarDecl -> Identifier
varName :: Identifier, VarDecl -> VarValue
varValue :: VarValue}
deriving (Int -> VarDecl -> ShowS
[VarDecl] -> ShowS
VarDecl -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VarDecl] -> ShowS
$cshowList :: [VarDecl] -> ShowS
show :: VarDecl -> String
$cshow :: VarDecl -> String
showsPrec :: Int -> VarDecl -> ShowS
$cshowsPrec :: Int -> VarDecl -> ShowS
Show)
data VarValue
= VarValue (Maybe Type) Expression
| DefaultedVarValue Type
deriving (Int -> VarValue -> ShowS
[VarValue] -> ShowS
VarValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VarValue] -> ShowS
$cshowList :: [VarValue] -> ShowS
show :: VarValue -> String
$cshow :: VarValue -> String
showsPrec :: Int -> VarValue -> ShowS
$cshowsPrec :: Int -> VarValue -> ShowS
Show)
data IfElse = IfElse
{ IfElse -> Maybe SimpleStmt
ifPreStmt :: Maybe SimpleStmt,
IfElse -> Expression
ifCondition :: Expression,
IfElse -> [Statement]
ifBody :: Block,
IfElse -> Else
elseStmt :: Else
}
deriving (Int -> IfElse -> ShowS
[IfElse] -> ShowS
IfElse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IfElse] -> ShowS
$cshowList :: [IfElse] -> ShowS
show :: IfElse -> String
$cshow :: IfElse -> String
showsPrec :: Int -> IfElse -> ShowS
$cshowsPrec :: Int -> IfElse -> ShowS
Show)
data Else = NoElse | Else Block | Elif IfElse
deriving (Int -> Else -> ShowS
[Else] -> ShowS
Else -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Else] -> ShowS
$cshowList :: [Else] -> ShowS
show :: Else -> String
$cshow :: Else -> String
showsPrec :: Int -> Else -> ShowS
$cshowsPrec :: Int -> Else -> ShowS
Show)
data SimpleStmt
=
StmtAssignment Lvalue Expression
|
StmtIncDec Lvalue IncDec
|
StmtShortVarDecl Identifier Expression
|
StmtExpression Expression
deriving (Int -> SimpleStmt -> ShowS
[SimpleStmt] -> ShowS
SimpleStmt -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SimpleStmt] -> ShowS
$cshowList :: [SimpleStmt] -> ShowS
show :: SimpleStmt -> String
$cshow :: SimpleStmt -> String
showsPrec :: Int -> SimpleStmt -> ShowS
$cshowsPrec :: Int -> SimpleStmt -> ShowS
Show)
data Lvalue
=
LvalVar Identifier
|
LvalArrEl Identifier [Expression]
deriving (Int -> Lvalue -> ShowS
[Lvalue] -> ShowS
Lvalue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Lvalue] -> ShowS
$cshowList :: [Lvalue] -> ShowS
show :: Lvalue -> String
$cshow :: Lvalue -> String
showsPrec :: Int -> Lvalue -> ShowS
$cshowsPrec :: Int -> Lvalue -> ShowS
Show)
data IncDec = Inc | Dec
deriving (Int -> IncDec -> ShowS
[IncDec] -> ShowS
IncDec -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IncDec] -> ShowS
$cshowList :: [IncDec] -> ShowS
show :: IncDec -> String
$cshow :: IncDec -> String
showsPrec :: Int -> IncDec -> ShowS
$cshowsPrec :: Int -> IncDec -> ShowS
Show)
data Value
=
ValInt Integer
|
ValBool Bool
|
ValString Text
|
ValArray ArrayValue
|
ValFunction FunctionValue
deriving (Int -> Value -> ShowS
[Value] -> ShowS
Value -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Value] -> ShowS
$cshowList :: [Value] -> ShowS
show :: Value -> String
$cshow :: Value -> String
showsPrec :: Int -> Value -> ShowS
$cshowsPrec :: Int -> Value -> ShowS
Show)
data ArrayValue = ArrayValue {ArrayValue -> ArrayType
arrT :: ArrayType, ArrayValue -> [Expression]
arrElements :: [Expression]}
deriving (Int -> ArrayValue -> ShowS
[ArrayValue] -> ShowS
ArrayValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ArrayValue] -> ShowS
$cshowList :: [ArrayValue] -> ShowS
show :: ArrayValue -> String
$cshow :: ArrayValue -> String
showsPrec :: Int -> ArrayValue -> ShowS
$cshowsPrec :: Int -> ArrayValue -> ShowS
Show)
data FunctionValue
=
AnonymousFunction Function
|
Nil
deriving (Int -> FunctionValue -> ShowS
[FunctionValue] -> ShowS
FunctionValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionValue] -> ShowS
$cshowList :: [FunctionValue] -> ShowS
show :: FunctionValue -> String
$cshow :: FunctionValue -> String
showsPrec :: Int -> FunctionValue -> ShowS
$cshowsPrec :: Int -> FunctionValue -> ShowS
Show)
data Function = Function {Function -> [(Identifier, Type)]
funcParams :: [(Identifier, Type)], Function -> MaybeVoid Type
funcResult :: MaybeVoid Type, Function -> [Statement]
funcBody :: Block}
deriving (Int -> Function -> ShowS
[Function] -> ShowS
Function -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Function] -> ShowS
$cshowList :: [Function] -> ShowS
show :: Function -> String
$cshow :: Function -> String
showsPrec :: Int -> Function -> ShowS
$cshowsPrec :: Int -> Function -> ShowS
Show)
type Identifier = Text