Commit dca3a55f by Zachary Snow

support for indexed part select in first procedural Stmt

parent 9b51d756
...@@ -402,7 +402,7 @@ DeclOrStmtTokens(delim) :: { [DeclToken] } ...@@ -402,7 +402,7 @@ DeclOrStmtTokens(delim) :: { [DeclToken] }
| "<=" opt(DelayOrEventControl) Expr delim { [DTAsgnNBlk $2 $3] } | "<=" opt(DelayOrEventControl) Expr delim { [DTAsgnNBlk $2 $3] }
DeclOrStmtToken :: { DeclToken } DeclOrStmtToken :: { DeclToken }
: "," { DTComma } : "," { DTComma }
| Range { DTRange $1 } | PartSelect { DTRange $1 }
| Identifier { DTIdent $1 } | Identifier { DTIdent $1 }
| Direction { DTDir $1 } | Direction { DTDir $1 }
| "[" Expr "]" { DTBit $2 } | "[" Expr "]" { DTBit $2 }
......
...@@ -49,7 +49,7 @@ data DeclToken ...@@ -49,7 +49,7 @@ data DeclToken
= DTComma = DTComma
| DTAsgn AsgnOp Expr | DTAsgn AsgnOp Expr
| DTAsgnNBlk (Maybe Timing) Expr | DTAsgnNBlk (Maybe Timing) Expr
| DTRange Range | DTRange (PartSelectMode, Range)
| DTIdent Identifier | DTIdent Identifier
| DTDir Direction | DTDir Direction
| DTType (Signing -> [Range] -> Type) | DTType (Signing -> [Range] -> Type)
...@@ -137,8 +137,9 @@ parseDTsAsIntantiations (DTIdent name : tokens) = ...@@ -137,8 +137,9 @@ parseDTsAsIntantiations (DTIdent name : tokens) =
where where
(inst, toks') = span (DTComma /=) toks (inst, toks') = span (DTComma /=) toks
(x, mr, p) = case inst of (x, mr, p) = case inst of
[DTIdent a, DTRange s, DTInstance b] -> (a, Just s , b) [DTIdent a, DTRange (NonIndexed, s), DTInstance b] ->
[DTIdent a, DTInstance b] -> (a, Nothing, b) (a, Just s , b)
[DTIdent a, DTInstance b] -> (a, Nothing, b)
_ -> error $ "unrecognized instantiation: " ++ show inst _ -> error $ "unrecognized instantiation: " ++ show inst
follow = x `seq` if null toks' then [] else step (tail toks') follow = x `seq` if null toks' then [] else step (tail toks')
(params, rest) = (params, rest) =
...@@ -235,7 +236,7 @@ takeLHSStep :: Maybe LHS -> DeclToken -> Maybe LHS ...@@ -235,7 +236,7 @@ takeLHSStep :: Maybe LHS -> DeclToken -> Maybe LHS
takeLHSStep (Nothing ) (DTConcat lhss) = Just $ LHSConcat lhss takeLHSStep (Nothing ) (DTConcat lhss) = Just $ LHSConcat lhss
takeLHSStep (Nothing ) (DTIdent x ) = Just $ LHSIdent x takeLHSStep (Nothing ) (DTIdent x ) = Just $ LHSIdent x
takeLHSStep (Just curr) (DTBit e ) = Just $ LHSBit curr e takeLHSStep (Just curr) (DTBit e ) = Just $ LHSBit curr e
takeLHSStep (Just curr) (DTRange r ) = Just $ LHSRange curr NonIndexed r takeLHSStep (Just curr) (DTRange (m,r)) = Just $ LHSRange curr m r
takeLHSStep (Just curr) (DTDot x ) = Just $ LHSDot curr x takeLHSStep (Just curr) (DTDot x ) = Just $ LHSDot curr x
takeLHSStep (maybeCurr) token = takeLHSStep (maybeCurr) token =
error $ "unexpected token in LHS: " ++ show (maybeCurr, token) error $ "unexpected token in LHS: " ++ show (maybeCurr, token)
...@@ -323,9 +324,9 @@ takeRanges :: [DeclToken] -> ([Range], [DeclToken]) ...@@ -323,9 +324,9 @@ takeRanges :: [DeclToken] -> ([Range], [DeclToken])
takeRanges [] = ([], []) takeRanges [] = ([], [])
takeRanges (token : tokens) = takeRanges (token : tokens) =
case token of case token of
DTRange r -> (r : rs, rest ) DTRange (NonIndexed, r) -> (r : rs, rest )
DTBit s -> (asRange s : rs, rest ) DTBit s -> (asRange s : rs, rest )
_ -> ([] , token : tokens) _ -> ([] , token : tokens)
where where
(rs, rest) = takeRanges tokens (rs, rest) = takeRanges tokens
asRange s = (simplify $ BinOp Sub s (Number "1"), Number "0") asRange s = (simplify $ BinOp Sub s (Number "1"), Number "0")
...@@ -342,7 +343,7 @@ takeAsgn rest = (Nothing, rest) ...@@ -342,7 +343,7 @@ takeAsgn rest = (Nothing, rest)
takeComma :: [DeclToken] -> (Bool, [DeclToken]) takeComma :: [DeclToken] -> (Bool, [DeclToken])
takeComma [] = (False, []) takeComma [] = (False, [])
takeComma (DTComma : rest) = (True, rest) takeComma (DTComma : rest) = (True, rest)
takeComma _ = error "take comma encountered neither comma nor end of tokens" takeComma toks = error $ "expected comma or end of decl, got: " ++ show toks
takeIdent :: [DeclToken] -> (Identifier, [DeclToken]) takeIdent :: [DeclToken] -> (Identifier, [DeclToken])
takeIdent (DTIdent x : rest) = (x, rest) takeIdent (DTIdent x : rest) = (x, rest)
......
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