Commit e8ed885f by Zachary Snow

support for single-expr implicit dimensions

parent d7b36a03
......@@ -355,8 +355,11 @@ Dimensions :: { [Range] }
: {- empty -} { [] }
| DimensionsNonEmpty { $1 }
DimensionsNonEmpty :: { [Range] }
: Range { [$1] }
| DimensionsNonEmpty Range { $1 ++ [$2] }
: Dimension { [$1] }
| DimensionsNonEmpty Dimension { $1 ++ [$2] }
Dimension :: { Range }
: Range { $1 }
| "[" Expr "]" { (simplify $ BinOp Sub $2 (Number "1"), Number "0") }
DeclAsgns :: { [(Identifier, Expr)] }
: DeclAsgn { [$1] }
......
......@@ -239,9 +239,15 @@ takeType (DTIdent tn : rest) = (Alias tn, rest)
takeType rest = (Implicit, rest)
takeRanges :: [DeclToken] -> ([Range], [DeclToken])
takeRanges (DTRange r : rest) = (r : rs, rest')
where (rs, rest') = takeRanges rest
takeRanges rest = ([], rest)
takeRanges [] = ([], [])
takeRanges (token : tokens) =
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`
-- 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