Commit a863321d by Zachary Snow

combine handling of concatenation LHSs

parent df2524ea
...@@ -642,7 +642,8 @@ DeclToken :: { DeclToken } ...@@ -642,7 +642,8 @@ DeclToken :: { DeclToken }
| PartSelectP { uncurry (DTRange $ fst $1) (snd $1) } | PartSelectP { uncurry (DTRange $ fst $1) (snd $1) }
| IdentifierP { uncurry DTIdent $1 } | IdentifierP { uncurry DTIdent $1 }
| DirectionP { uncurry DTDir $1 } | DirectionP { uncurry DTDir $1 }
| LHSConcatP { uncurry DTConcat $1 } | LHSConcatP { uncurry DTLHSBase $1 }
| LHSStreamP { uncurry DTLHSBase $1 }
| PartialTypeP { uncurry DTType $1 } | PartialTypeP { uncurry DTType $1 }
| NetTypeP Strength { uncurry DTNet $1 $2 } | NetTypeP Strength { uncurry DTNet $1 $2 }
| PortBindingsP { uncurry DTPorts $1 } | PortBindingsP { uncurry DTPorts $1 }
...@@ -650,8 +651,6 @@ DeclToken :: { DeclToken } ...@@ -650,8 +651,6 @@ DeclToken :: { DeclToken }
| "[" Expr "]" { DTBit (tokenPosition $1) $2 } | "[" Expr "]" { DTBit (tokenPosition $1) $2 }
| "." Identifier { DTDot (tokenPosition $1) $2 } | "." Identifier { DTDot (tokenPosition $1) $2 }
| "automatic" { DTLifetime (tokenPosition $1) Automatic } | "automatic" { DTLifetime (tokenPosition $1) Automatic }
| "{" StreamOp StreamSize Concat "}" { DTStream (tokenPosition $1) $2 $3 (map toLHS $4) }
| "{" StreamOp Concat "}" { DTStream (tokenPosition $1) $2 (RawNum 1) (map toLHS $3) }
| "type" "(" Expr ")" { uncurry DTType $ makeTypeOf $1 $3 } | "type" "(" Expr ")" { uncurry DTType $ makeTypeOf $1 $3 }
| IncOrDecOperatorP { DTAsgn (fst $1) (AsgnOp $ snd $1) Nothing (RawNum 1) } | IncOrDecOperatorP { DTAsgn (fst $1) (AsgnOp $ snd $1) Nothing (RawNum 1) }
| IdentifierP "::" Identifier { uncurry DTPSIdent $1 $3 } | IdentifierP "::" Identifier { uncurry DTPSIdent $1 $3 }
...@@ -990,12 +989,15 @@ LHS :: { LHS } ...@@ -990,12 +989,15 @@ LHS :: { LHS }
| LHS PartSelectP { uncurry (LHSRange $1) (snd $2) } | LHS PartSelectP { uncurry (LHSRange $1) (snd $2) }
| LHS "[" Expr "]" { LHSBit $1 $3 } | LHS "[" Expr "]" { LHSBit $1 $3 }
| LHS "." Identifier { LHSDot $1 $3 } | LHS "." Identifier { LHSDot $1 $3 }
| LHSConcatP { LHSConcat $ snd $1 } | LHSConcatP { snd $1 }
| "{" StreamOp StreamSize Concat "}" { LHSStream $2 $3 (map toLHS $4) } | LHSStreamP { snd $1 }
| "{" StreamOp Concat "}" { LHSStream $2 (RawNum 1) (map toLHS $3) }
LHSConcatP :: { (Position, [LHS]) } LHSStreamP :: { (Position, LHS) }
: "{" LHSs "}" { withPos $1 $2 } : "{" StreamOp StreamSize Concat "}" { withPos $1 $ LHSStream $2 $3 (map toLHS $4) }
| "{" StreamOp Concat "}" { withPos $1 $ LHSStream $2 (RawNum 1) (map toLHS $3) }
LHSConcatP :: { (Position, LHS) }
: "{" LHSs "}" { withPos $1 $ LHSConcat $2 }
LHSs :: { [LHS] } LHSs :: { [LHS] }
: LHS { [$1] } : LHS { [$1] }
| LHSs "," LHS { $1 ++ [$3] } | LHSs "," LHS { $1 ++ [$3] }
......
...@@ -66,8 +66,7 @@ data DeclToken ...@@ -66,8 +66,7 @@ data DeclToken
| DTParams Position [ParamBinding] | DTParams Position [ParamBinding]
| DTPorts Position [PortBinding] | DTPorts Position [PortBinding]
| DTBit Position Expr | DTBit Position Expr
| DTConcat Position [LHS] | DTLHSBase Position LHS
| DTStream Position StreamOp Expr [LHS]
| DTDot Position Identifier | DTDot Position Identifier
| DTSigning Position Signing | DTSigning Position Signing
| DTLifetime Position Lifetime | DTLifetime Position Lifetime
...@@ -357,9 +356,8 @@ takeLHS tokens = takeLHSStep (takeLHSStart tok) toks ...@@ -357,9 +356,8 @@ takeLHS tokens = takeLHSStep (takeLHSStart tok) toks
where tok : toks = tokens where tok : toks = tokens
takeLHSStart :: DeclToken -> LHS takeLHSStart :: DeclToken -> LHS
takeLHSStart (DTConcat _ lhss) = LHSConcat lhss takeLHSStart (DTLHSBase _ lhs) = lhs
takeLHSStart (DTStream _ o e lhss) = LHSStream o e lhss takeLHSStart (DTIdent _ x) = LHSIdent x
takeLHSStart (DTIdent _ x ) = LHSIdent x
takeLHSStart tok = parseError tok "expected primary token or type" takeLHSStart tok = parseError tok "expected primary token or type"
takeLHSStep :: LHS -> [DeclToken] -> (LHS, [DeclToken]) takeLHSStep :: LHS -> [DeclToken] -> (LHS, [DeclToken])
...@@ -580,8 +578,7 @@ tokPos (DTNet p _ _) = p ...@@ -580,8 +578,7 @@ tokPos (DTNet p _ _) = p
tokPos (DTParams p _) = p tokPos (DTParams p _) = p
tokPos (DTPorts p _) = p tokPos (DTPorts p _) = p
tokPos (DTBit p _) = p tokPos (DTBit p _) = p
tokPos (DTConcat p _) = p tokPos (DTLHSBase p _) = p
tokPos (DTStream p _ _ _) = p
tokPos (DTDot p _) = p tokPos (DTDot p _) = p
tokPos (DTSigning p _) = p tokPos (DTSigning p _) = p
tokPos (DTLifetime p _) = p tokPos (DTLifetime p _) = p
......
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