Commit 76663c78 by Zachary Snow

fix typename decl asgn lookahead (resolves #49)

parent c7f51209
......@@ -358,15 +358,25 @@ takeLifetime (DTLifetime l : rest) = (Just l, rest)
takeLifetime rest = (Nothing, rest)
takeType :: [DeclToken] -> ([Range] -> Type, [DeclToken])
takeType (DTIdent a : DTDot b : rest) = (InterfaceT a (Just b), rest)
takeType (DTType tf : DTSigning sg : rest) = (tf sg , rest)
takeType (DTType tf : rest) = (tf Unspecified, rest)
takeType (DTSigning sg : rest) = (Implicit sg , rest)
takeType (DTIdent tn : DTComma : rest) = (Implicit Unspecified, DTIdent tn : DTComma : rest)
takeType (DTIdent tn : [ ]) = (Implicit Unspecified, DTIdent tn : [ ])
takeType (DTIdent tn : rest) = (Alias (Nothing) tn , rest)
takeType (DTPSIdent ps tn : rest) = (Alias (Just ps) tn , rest)
takeType rest = (Implicit Unspecified, rest)
takeType (DTIdent a : DTDot b : rest) = (InterfaceT a (Just b), rest)
takeType (DTType tf : DTSigning sg : rest) = (tf sg , rest)
takeType (DTType tf : rest) = (tf Unspecified , rest)
takeType (DTSigning sg : rest) = (Implicit sg , rest)
takeType (DTPSIdent ps tn : rest) = (Alias (Just ps) tn , rest)
takeType (DTIdent tn : rest) =
if couldBeTypename
then (Alias (Nothing) tn , rest)
else (Implicit Unspecified, DTIdent tn : rest)
where
couldBeTypename =
case (findIndex isIdent rest, elemIndex DTComma rest) of
-- no identifiers left => no decl asgns
(Nothing, _) -> False
-- an identifier is left, and no more commas
(_, Nothing) -> True
-- if comma is first, then this ident is a declaration
(Just a, Just b) -> a < b
takeType rest = (Implicit Unspecified, rest)
takeRanges :: [DeclToken] -> ([Range], [DeclToken])
takeRanges [] = ([], [])
......
typedef wire b_t;
module top(
input a [1:0],
input b_t b
);
initial $display("%d %d %1d %1d", a, b, $bits(a), $bits(b));
endmodule
module top(
input [1:0] a,
input wire b
);
initial $display("%d %d %1d %1d", a, b, $bits(a), $bits(b));
endmodule
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