Commit e8ed885f by Zachary Snow

support for single-expr implicit dimensions

parent d7b36a03
...@@ -355,8 +355,11 @@ Dimensions :: { [Range] } ...@@ -355,8 +355,11 @@ Dimensions :: { [Range] }
: {- empty -} { [] } : {- empty -} { [] }
| DimensionsNonEmpty { $1 } | DimensionsNonEmpty { $1 }
DimensionsNonEmpty :: { [Range] } DimensionsNonEmpty :: { [Range] }
: Range { [$1] } : Dimension { [$1] }
| DimensionsNonEmpty Range { $1 ++ [$2] } | DimensionsNonEmpty Dimension { $1 ++ [$2] }
Dimension :: { Range }
: Range { $1 }
| "[" Expr "]" { (simplify $ BinOp Sub $2 (Number "1"), Number "0") }
DeclAsgns :: { [(Identifier, Expr)] } DeclAsgns :: { [(Identifier, Expr)] }
: DeclAsgn { [$1] } : DeclAsgn { [$1] }
......
...@@ -239,9 +239,15 @@ takeType (DTIdent tn : rest) = (Alias tn, rest) ...@@ -239,9 +239,15 @@ takeType (DTIdent tn : rest) = (Alias tn, rest)
takeType rest = (Implicit, rest) takeType rest = (Implicit, rest)
takeRanges :: [DeclToken] -> ([Range], [DeclToken]) takeRanges :: [DeclToken] -> ([Range], [DeclToken])
takeRanges (DTRange r : rest) = (r : rs, rest') takeRanges [] = ([], [])
where (rs, rest') = takeRanges rest takeRanges (token : tokens) =
takeRanges rest = ([], rest) case token of
DTRange r -> (r : rs, rest )
DTBit s -> (asRange s : rs, rest )
_ -> ([] , token : tokens)
where
(rs, rest) = takeRanges tokens
asRange s = (simplify $ BinOp Sub s (Number "1"), Number "0")
-- TODO: entrypoints besides `parseDTsAsDeclOrAsgn` should disallow `DTAsgnNBlk` -- TODO: entrypoints besides `parseDTsAsDeclOrAsgn` should disallow `DTAsgnNBlk`
-- Note: matching DTAsgnNBlk too is a bit of a hack to allow for tripLookahead -- Note: matching DTAsgnNBlk too is a bit of a hack to allow for tripLookahead
......
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