From 56eb1611f4f5f7c8afe01c7b22008f9ffe019b31 Mon Sep 17 00:00:00 2001 From: Francis Russell Date: Tue, 25 Sep 2012 18:38:13 +0100 Subject: [PATCH] Add tentative second-level AST definitions. --- OFC/Common.hs | 7 +++++++ OFC/Parser.hs | 1 + OFC/SecondLevel.hs | 31 +++++++++++++++++++++++++++++++ OFC/TopLevel.hs | 7 +------ ofc.cabal | 4 +++- 5 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 OFC/Common.hs create mode 100644 OFC/SecondLevel.hs diff --git a/OFC/Common.hs b/OFC/Common.hs new file mode 100644 index 0000000..44f77c1 --- /dev/null +++ b/OFC/Common.hs @@ -0,0 +1,7 @@ +module OFC.Common where + +data IndexType = + FunctionIndex | + SpinIndex | + SpatialIndex + deriving (Show, Eq, Enum, Bounded) diff --git a/OFC/Parser.hs b/OFC/Parser.hs index 29f893b..903c220 100644 --- a/OFC/Parser.hs +++ b/OFC/Parser.hs @@ -1,4 +1,5 @@ module OFC.Parser (runOFLParser) where +import OFC.Common import OFC.TopLevel import OFC.TargetMapping import Data.Functor.Identity (Identity) diff --git a/OFC/SecondLevel.hs b/OFC/SecondLevel.hs new file mode 100644 index 0000000..df63c65 --- /dev/null +++ b/OFC/SecondLevel.hs @@ -0,0 +1,31 @@ +module OFC.SecondLevel where +import Data.Complex + +data Type = + RealType | + ComplexType | + IntegerType | + Psinc Integer | + PsincReciprocal Integer + +data Expression = + IndexedIdentifier String [String] | + Upsample | + Downsample | + Apply DiagonalOperator Expression | + Product Expression Expression | + InnerProduct Expression Expression + +data DiagonalOperator = + PositionOperator OperatorExpr | + MomentumOperator OperatorExpr + +data OperatorExpr = + ConstReal Double | + ConstComplex (Complex Double) | + ConstInteger Integer | + Negate OperatorExpr | + LatticeComponent String | + Multiply OperatorExpr OperatorExpr | + Sum OperatorExpr String | + Power OperatorExpr OperatorExpr diff --git a/OFC/TopLevel.hs b/OFC/TopLevel.hs index 91b3df9..8045fed 100644 --- a/OFC/TopLevel.hs +++ b/OFC/TopLevel.hs @@ -1,5 +1,6 @@ module OFC.TopLevel where import OFC.TargetMapping +import OFC.Common import Text.PrettyPrint import Data.List (foldl') import Data.Map (Map) @@ -14,12 +15,6 @@ data BaseType = IntegerType deriving (Show, Eq, Enum, Bounded) -data IndexType = - FunctionIndex | - SpinIndex | - SpatialIndex - deriving (Show, Eq, Enum, Bounded) - -- Expressions data Expression = IndexedIdentifier String [String] | diff --git a/ofc.cabal b/ofc.cabal index 7852547..574813f 100644 --- a/ofc.cabal +++ b/ofc.cabal @@ -10,8 +10,10 @@ Library Hs-Source-Dirs: . GHC-Options: -Wall -fno-warn-missing-signatures Build-Depends: base, containers, parsec >= 3, pretty, transformers - Exposed-Modules: OFC.Parser + Exposed-Modules: OFC.Common + OFC.Parser OFC.TopLevel + OFC.SecondLevel OFC.TargetMapping Executable ofc -- 2.47.3