Commit 1a394cff by Zachary Snow

support mintypmax expressions

parent f0368714
......@@ -475,6 +475,12 @@ convertAsgn structs types (lhs, expr) =
where
items' = map mapItem items
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)
convertTypeOrExpr :: TypeOrExpr -> TypeOrExpr
......
......@@ -481,6 +481,11 @@ traverseNestedExprsM mapper = exprMapper
let names = map fst l
exprs <- mapM exprMapper $ map snd l
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
exprMapperHelpers :: Monad m => MapperM m Expr ->
......
......@@ -55,6 +55,7 @@ data Expr
| DimFn DimFn TypeOrExpr Expr
| Dot Expr Identifier
| Pattern [(Maybe Identifier, Expr)]
| MinTypMax Expr Expr Expr
| Nil
deriving (Eq, Ord)
......@@ -83,6 +84,7 @@ instance Show Expr where
showPatternItem :: (Maybe Identifier, Expr) -> String
showPatternItem (Nothing, e) = 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
= Args [Maybe Expr] [(Identifier, Maybe Expr)]
......
......@@ -1019,6 +1019,7 @@ DelayValue :: { Expr }
: Number { Number $1 }
| Identifier { Ident $1 }
| Identifier "::" Identifier { PSIdent $1 $3 }
| "(" Expr ":" Expr ":" Expr ")" { MinTypMax $2 $4 $6 }
-- TODO: Support these other DelayValues?
-- | real_number
-- | time_literal
......@@ -1106,6 +1107,7 @@ Expr :: { Expr }
| "{" StreamOp StreamSize Concat "}" { Stream $2 $3 $4 }
| "{" StreamOp Concat "}" { Stream $2 (Number "1") $3 }
| Expr "inside" Concat { foldl1 (BinOp LogOr) $ map (BinOp Eq $1) $3 }
| "(" Expr ":" Expr ":" Expr ")" { MinTypMax $2 $4 $6 }
-- binary expressions
| Expr "||" Expr { BinOp LogOr $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