Commit 73404643 by Zachary Snow

ParseDecl edge case

parent 97fda59c
......@@ -184,7 +184,7 @@ parseDTsAsDeclOrAsgn :: [DeclToken] -> ([Decl], [Stmt])
parseDTsAsDeclOrAsgn [DTIdent f] = ([], [Subroutine (Nothing) f (Args [] [])])
parseDTsAsDeclOrAsgn [DTPSIdent p f] = ([], [Subroutine (Just p) f (Args [] [])])
parseDTsAsDeclOrAsgn tokens =
if (any isAsgnToken tokens || tripLookahead tokens) && lhs /= Nothing
if (isAsgn (last tokens) || tripLookahead tokens) && lhs /= Nothing
then ([], [constructor (fromJust lhs) expr])
else (parseDTsAsDecl tokens, [])
where
......@@ -193,6 +193,10 @@ parseDTsAsDeclOrAsgn tokens =
DTAsgnNBlk mt e -> (Asgn mt, e)
_ -> error $ "invalid block item decl or stmt: " ++ (show tokens)
lhs = takeLHS $ init tokens
isAsgn :: DeclToken -> Bool
isAsgn (DTAsgnNBlk _ _) = True
isAsgn (DTAsgn _ _) = True
isAsgn _ = False
-- [PUBLIC]: parser for mixed comma-separated declaration and assignment lists;
-- the main use case is for `for` loop initialization lists
......
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