Commit 1a394cff by Zachary Snow

support mintypmax expressions

parent f0368714
...@@ -475,6 +475,12 @@ convertAsgn structs types (lhs, expr) = ...@@ -475,6 +475,12 @@ convertAsgn structs types (lhs, expr) =
where where
items' = map mapItem items items' = map mapItem items
mapItem (mx, e) = (mx, snd $ convertSubExpr e) mapItem (mx, e) = (mx, snd $ convertSubExpr e)
convertSubExpr (MinTypMax a b c) =
(t, MinTypMax a' b' c')
where
(_, a') = convertSubExpr a
(t, b') = convertSubExpr b
(_, c') = convertSubExpr c
convertSubExpr Nil = (Implicit Unspecified [], Nil) convertSubExpr Nil = (Implicit Unspecified [], Nil)
convertTypeOrExpr :: TypeOrExpr -> TypeOrExpr convertTypeOrExpr :: TypeOrExpr -> TypeOrExpr
......
...@@ -481,6 +481,11 @@ traverseNestedExprsM mapper = exprMapper ...@@ -481,6 +481,11 @@ traverseNestedExprsM mapper = exprMapper
let names = map fst l let names = map fst l
exprs <- mapM exprMapper $ map snd l exprs <- mapM exprMapper $ map snd l
return $ Pattern $ zip names exprs return $ Pattern $ zip names exprs
em (MinTypMax e1 e2 e3) = do
e1' <- exprMapper e1
e2' <- exprMapper e2
e3' <- exprMapper e3
return $ MinTypMax e1' e2' e3'
em (Nil) = return Nil em (Nil) = return Nil
exprMapperHelpers :: Monad m => MapperM m Expr -> exprMapperHelpers :: Monad m => MapperM m Expr ->
......
...@@ -55,6 +55,7 @@ data Expr ...@@ -55,6 +55,7 @@ data Expr
| DimFn DimFn TypeOrExpr Expr | DimFn DimFn TypeOrExpr Expr
| Dot Expr Identifier | Dot Expr Identifier
| Pattern [(Maybe Identifier, Expr)] | Pattern [(Maybe Identifier, Expr)]
| MinTypMax Expr Expr Expr
| Nil | Nil
deriving (Eq, Ord) deriving (Eq, Ord)
...@@ -83,6 +84,7 @@ instance Show Expr where ...@@ -83,6 +84,7 @@ instance Show Expr where
showPatternItem :: (Maybe Identifier, Expr) -> String showPatternItem :: (Maybe Identifier, Expr) -> String
showPatternItem (Nothing, e) = show e showPatternItem (Nothing, e) = show e
showPatternItem (Just n , e) = printf "%s: %s" n (show e) showPatternItem (Just n , e) = printf "%s: %s" n (show e)
show (MinTypMax a b c) = printf "(%s : %s : %s)" (show a) (show b) (show c)
data Args data Args
= Args [Maybe Expr] [(Identifier, Maybe Expr)] = Args [Maybe Expr] [(Identifier, Maybe Expr)]
......
...@@ -1019,6 +1019,7 @@ DelayValue :: { Expr } ...@@ -1019,6 +1019,7 @@ DelayValue :: { Expr }
: Number { Number $1 } : Number { Number $1 }
| Identifier { Ident $1 } | Identifier { Ident $1 }
| Identifier "::" Identifier { PSIdent $1 $3 } | Identifier "::" Identifier { PSIdent $1 $3 }
| "(" Expr ":" Expr ":" Expr ")" { MinTypMax $2 $4 $6 }
-- TODO: Support these other DelayValues? -- TODO: Support these other DelayValues?
-- | real_number -- | real_number
-- | time_literal -- | time_literal
...@@ -1106,6 +1107,7 @@ Expr :: { Expr } ...@@ -1106,6 +1107,7 @@ Expr :: { Expr }
| "{" StreamOp StreamSize Concat "}" { Stream $2 $3 $4 } | "{" StreamOp StreamSize Concat "}" { Stream $2 $3 $4 }
| "{" StreamOp Concat "}" { Stream $2 (Number "1") $3 } | "{" StreamOp Concat "}" { Stream $2 (Number "1") $3 }
| Expr "inside" Concat { foldl1 (BinOp LogOr) $ map (BinOp Eq $1) $3 } | Expr "inside" Concat { foldl1 (BinOp LogOr) $ map (BinOp Eq $1) $3 }
| "(" Expr ":" Expr ":" Expr ")" { MinTypMax $2 $4 $6 }
-- binary expressions -- binary expressions
| Expr "||" Expr { BinOp LogOr $1 $3 } | Expr "||" Expr { BinOp LogOr $1 $3 }
| Expr "&&" Expr { BinOp LogAnd $1 $3 } | Expr "&&" Expr { BinOp LogAnd $1 $3 }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment