module Parser.Tree where
import Data.Text (Text)
import Util.SourceLoc as SL
data Program = Program
{ Program -> [Located ImportDecl]
importDecls :: ![SL.Located ImportDecl],
Program -> [Located FieldDecl]
fieldDecls :: ![SL.Located FieldDecl],
Program -> [Located MethodDecl]
methodDecls :: ![SL.Located MethodDecl]
}
deriving (Int -> Program -> ShowS
[Program] -> ShowS
Program -> String
(Int -> Program -> ShowS)
-> (Program -> String) -> ([Program] -> ShowS) -> Show Program
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Program -> ShowS
showsPrec :: Int -> Program -> ShowS
$cshow :: Program -> String
show :: Program -> String
$cshowList :: [Program] -> ShowS
showList :: [Program] -> ShowS
Show)
data ImportDecl = ImportDecl {ImportDecl -> Text
importId :: !Text}
deriving (Int -> ImportDecl -> ShowS
[ImportDecl] -> ShowS
ImportDecl -> String
(Int -> ImportDecl -> ShowS)
-> (ImportDecl -> String)
-> ([ImportDecl] -> ShowS)
-> Show ImportDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ImportDecl -> ShowS
showsPrec :: Int -> ImportDecl -> ShowS
$cshow :: ImportDecl -> String
show :: ImportDecl -> String
$cshowList :: [ImportDecl] -> ShowS
showList :: [ImportDecl] -> ShowS
Show)
data FieldDecl = FieldDecl
{ FieldDecl -> Type
fieldType :: !Type,
FieldDecl -> [Located FieldElem]
elems :: ![SL.Located FieldElem]
}
deriving (Int -> FieldDecl -> ShowS
[FieldDecl] -> ShowS
FieldDecl -> String
(Int -> FieldDecl -> ShowS)
-> (FieldDecl -> String)
-> ([FieldDecl] -> ShowS)
-> Show FieldDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FieldDecl -> ShowS
showsPrec :: Int -> FieldDecl -> ShowS
$cshow :: FieldDecl -> String
show :: FieldDecl -> String
$cshowList :: [FieldDecl] -> ShowS
showList :: [FieldDecl] -> ShowS
Show)
data FieldElem
= ScalarField {FieldElem -> Text
fieldId :: !Text}
| VectorField {fieldId :: !Text, FieldElem -> Text
size :: !Text}
deriving (Int -> FieldElem -> ShowS
[FieldElem] -> ShowS
FieldElem -> String
(Int -> FieldElem -> ShowS)
-> (FieldElem -> String)
-> ([FieldElem] -> ShowS)
-> Show FieldElem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FieldElem -> ShowS
showsPrec :: Int -> FieldElem -> ShowS
$cshow :: FieldElem -> String
show :: FieldElem -> String
$cshowList :: [FieldElem] -> ShowS
showList :: [FieldElem] -> ShowS
Show)
data Type = IntType | BoolType
deriving (Int -> Type -> ShowS
[Type] -> ShowS
Type -> String
(Int -> Type -> ShowS)
-> (Type -> String) -> ([Type] -> ShowS) -> Show Type
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Type -> ShowS
showsPrec :: Int -> Type -> ShowS
$cshow :: Type -> String
show :: Type -> String
$cshowList :: [Type] -> ShowS
showList :: [Type] -> ShowS
Show)
data MethodDecl = MethodDecl
{ MethodDecl -> Text
methodId :: !Text,
MethodDecl -> Maybe Type
returnType :: !(Maybe Type),
MethodDecl -> [Located Argument]
arguments :: ![SL.Located Argument],
MethodDecl -> Block
block :: !Block
}
deriving (Int -> MethodDecl -> ShowS
[MethodDecl] -> ShowS
MethodDecl -> String
(Int -> MethodDecl -> ShowS)
-> (MethodDecl -> String)
-> ([MethodDecl] -> ShowS)
-> Show MethodDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MethodDecl -> ShowS
showsPrec :: Int -> MethodDecl -> ShowS
$cshow :: MethodDecl -> String
show :: MethodDecl -> String
$cshowList :: [MethodDecl] -> ShowS
showList :: [MethodDecl] -> ShowS
Show)
data Argument = Argument
{ Argument -> Text
argumentId :: !Text,
Argument -> Type
argumentType :: !Type
}
deriving (Int -> Argument -> ShowS
[Argument] -> ShowS
Argument -> String
(Int -> Argument -> ShowS)
-> (Argument -> String) -> ([Argument] -> ShowS) -> Show Argument
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Argument -> ShowS
showsPrec :: Int -> Argument -> ShowS
$cshow :: Argument -> String
show :: Argument -> String
$cshowList :: [Argument] -> ShowS
showList :: [Argument] -> ShowS
Show)
data Block = Block
{ Block -> [Located FieldDecl]
blockFieldDecls :: ![SL.Located FieldDecl],
Block -> [Located Statement]
blockStatements :: ![SL.Located Statement]
}
deriving (Int -> Block -> ShowS
[Block] -> ShowS
Block -> String
(Int -> Block -> ShowS)
-> (Block -> String) -> ([Block] -> ShowS) -> Show Block
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Block -> ShowS
showsPrec :: Int -> Block -> ShowS
$cshow :: Block -> String
show :: Block -> String
$cshowList :: [Block] -> ShowS
showList :: [Block] -> ShowS
Show)
data Statement
= AssignStatement {Statement -> Location
assignLocation :: !Location, Statement -> AssignExpr
assignExpr :: !AssignExpr}
| MethodCallStatement {Statement -> MethodCall
methodCallStatement :: !MethodCall}
| IfStatement {Statement -> Located Expr
ifExpr :: !(SL.Located Expr), Statement -> Block
ifBlock :: !Block}
| IfElseStatement {ifExpr :: !(SL.Located Expr), ifBlock :: !Block, Statement -> Block
elseBlock :: !Block}
| ForStatement
{ Statement -> Text
counterId :: !Text,
Statement -> Located Expr
counterExpr :: !(SL.Located Expr),
Statement -> Located Expr
forPredExpr :: !(SL.Located Expr),
Statement -> CounterUpdate
counterUpdate :: !CounterUpdate,
Statement -> Block
forBlock :: !Block
}
| WhileStatement {Statement -> Located Expr
whileExpr :: !(SL.Located Expr), Statement -> Block
whileBlock :: !Block}
| ReturnVoidStatement
| ReturnExprStatement {Statement -> Located Expr
returnExpr :: !(SL.Located Expr)}
| BreakStatement
| ContinueStatement
| ErrorStatement
deriving (Int -> Statement -> ShowS
[Statement] -> ShowS
Statement -> String
(Int -> Statement -> ShowS)
-> (Statement -> String)
-> ([Statement] -> ShowS)
-> Show Statement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Statement -> ShowS
showsPrec :: Int -> Statement -> ShowS
$cshow :: Statement -> String
show :: Statement -> String
$cshowList :: [Statement] -> ShowS
showList :: [Statement] -> ShowS
Show)
data Location
= ScalarLocation {Location -> Text
locationId :: !Text}
| VectorLocation {locationId :: !Text, Location -> Located Expr
arrayIndexExpr :: !(SL.Located Expr)}
deriving (Int -> Location -> ShowS
[Location] -> ShowS
Location -> String
(Int -> Location -> ShowS)
-> (Location -> String) -> ([Location] -> ShowS) -> Show Location
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Location -> ShowS
showsPrec :: Int -> Location -> ShowS
$cshow :: Location -> String
show :: Location -> String
$cshowList :: [Location] -> ShowS
showList :: [Location] -> ShowS
Show)
data AssignExpr
= AssignExpr {AssignExpr -> Text
assignOp :: !Text, AssignExpr -> Located Expr
assignSourceExpr :: !(SL.Located Expr)}
| IncrementExpr {AssignExpr -> Text
incrementOp :: !Text}
deriving (Int -> AssignExpr -> ShowS
[AssignExpr] -> ShowS
AssignExpr -> String
(Int -> AssignExpr -> ShowS)
-> (AssignExpr -> String)
-> ([AssignExpr] -> ShowS)
-> Show AssignExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AssignExpr -> ShowS
showsPrec :: Int -> AssignExpr -> ShowS
$cshow :: AssignExpr -> String
show :: AssignExpr -> String
$cshowList :: [AssignExpr] -> ShowS
showList :: [AssignExpr] -> ShowS
Show)
data MethodCall = MethodCall {MethodCall -> Text
methodName :: !Text, MethodCall -> [Located ImportArg]
importArguments :: ![SL.Located ImportArg]}
deriving (Int -> MethodCall -> ShowS
[MethodCall] -> ShowS
MethodCall -> String
(Int -> MethodCall -> ShowS)
-> (MethodCall -> String)
-> ([MethodCall] -> ShowS)
-> Show MethodCall
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MethodCall -> ShowS
showsPrec :: Int -> MethodCall -> ShowS
$cshow :: MethodCall -> String
show :: MethodCall -> String
$cshowList :: [MethodCall] -> ShowS
showList :: [MethodCall] -> ShowS
Show)
data ImportArg
= ExprImportArg {ImportArg -> Located Expr
argumentExpr :: !(SL.Located Expr)}
| StringImportArg {ImportArg -> Text
argumentString :: !Text}
deriving (Int -> ImportArg -> ShowS
[ImportArg] -> ShowS
ImportArg -> String
(Int -> ImportArg -> ShowS)
-> (ImportArg -> String)
-> ([ImportArg] -> ShowS)
-> Show ImportArg
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ImportArg -> ShowS
showsPrec :: Int -> ImportArg -> ShowS
$cshow :: ImportArg -> String
show :: ImportArg -> String
$cshowList :: [ImportArg] -> ShowS
showList :: [ImportArg] -> ShowS
Show)
data CounterUpdate = CounterUpdate {CounterUpdate -> Location
counterLocation :: !Location, CounterUpdate -> AssignExpr
updateExpr :: !AssignExpr}
deriving (Int -> CounterUpdate -> ShowS
[CounterUpdate] -> ShowS
CounterUpdate -> String
(Int -> CounterUpdate -> ShowS)
-> (CounterUpdate -> String)
-> ([CounterUpdate] -> ShowS)
-> Show CounterUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CounterUpdate -> ShowS
showsPrec :: Int -> CounterUpdate -> ShowS
$cshow :: CounterUpdate -> String
show :: CounterUpdate -> String
$cshowList :: [CounterUpdate] -> ShowS
showList :: [CounterUpdate] -> ShowS
Show)
data Expr
= LocationExpr {Expr -> Location
location :: !Location}
| MethodCallExpr {Expr -> MethodCall
methodCallExpr :: !MethodCall}
| IntLiteralExpr {Expr -> Text
intLiteral :: !Text}
| CharLiteralExpr {Expr -> Text
charLiteral :: !Text}
| BoolLiteralExpr {Expr -> Text
boolLiteral :: !Text}
| LenExpr {Expr -> Text
lenId :: !Text}
| ArithOpExpr {Expr -> Text
arithOp :: !Text, Expr -> Located Expr
lExpr :: !(SL.Located Expr), Expr -> Located Expr
rExpr :: !(SL.Located Expr)}
| RelOpExpr {Expr -> Text
relOp :: !Text, lExpr :: !(SL.Located Expr), rExpr :: !(SL.Located Expr)}
| EqOpExpr {Expr -> Text
eqOp :: !Text, lExpr :: !(SL.Located Expr), rExpr :: !(SL.Located Expr)}
| CondOpExpr {Expr -> Text
condOp :: !Text, lExpr :: !(SL.Located Expr), rExpr :: !(SL.Located Expr)}
| NegativeExpr {Expr -> Located Expr
negativeExpr :: !(SL.Located Expr)}
| NegateExpr {Expr -> Located Expr
negateExpr :: !(SL.Located Expr)}
| ParenExpr {Expr -> Located Expr
parenExpr :: !(SL.Located Expr)}
| ChoiceExpr {Expr -> Located Expr
choicePredExpr :: !(SL.Located Expr), lExpr :: !(SL.Located Expr), rExpr :: !(SL.Located Expr)}
deriving (Int -> Expr -> ShowS
[Expr] -> ShowS
Expr -> String
(Int -> Expr -> ShowS)
-> (Expr -> String) -> ([Expr] -> ShowS) -> Show Expr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Expr -> ShowS
showsPrec :: Int -> Expr -> ShowS
$cshow :: Expr -> String
show :: Expr -> String
$cshowList :: [Expr] -> ShowS
showList :: [Expr] -> ShowS
Show)