on master help sign in
Merge pull request #55 from raichoo/master

Parser goes into infinite loop

commit835b4389d201414ed323aa75c98c2c05d5140cca authorEdwin Brady <edwin.brady@gmail.com> dateTue 9 Oct 2012, 15:05 (14 years ago) parent0f957f67cb5a60
1 file changed+12−8
src/Idris/Parser.hs+12−8
src/Idris/Parser.hs+12−8
@@ -279,14 +279,18 @@ parseProg syn fname input pos
279279collect :: [PDecl] -> [PDecl]
280280collect (c@(PClauses _ o _ _) : ds)
281281 = clauses (cname c) [] (c : ds)
282− where clauses n acc (PClauses fc _ _ [PClause fc' n' l ws r w] : ds)
283− | n == n' = clauses n (PClause fc' n' l ws r (collect w) : acc) ds
284− clauses n acc (PClauses fc _ _ [PWith fc' n' l ws r w] : ds)
285− | n == n' = clauses n (PWith fc' n' l ws r (collect w) : acc) ds
286− clauses n acc xs = PClauses (getfc c) o n (reverse acc) : collect xs
287−
288− cname (PClauses fc _ _ [PClause _ n _ _ _ _]) = n
289− cname (PClauses fc _ _ [PWith _ n _ _ _ _]) = n
282+ where clauses j@(Just n) acc (PClauses fc _ _ [PClause fc' n' l ws r w] : ds)
283+ | n == n' = clauses j (PClause fc' n' l ws r (collect w) : acc) ds
284+ clauses j@(Just n) acc (PClauses fc _ _ [PWith fc' n' l ws r w] : ds)
285+ | n == n' = clauses j (PWith fc' n' l ws r (collect w) : acc) ds
286+ clauses (Just n) acc xs = PClauses (getfc c) o n (reverse acc) : collect xs
287+ clauses Nothing acc (x:xs) = collect xs
288+ clauses Nothing acc [] = []
289+
290+ cname (PClauses fc _ _ [PClause _ n _ _ _ _]) = Just n
291+ cname (PClauses fc _ _ [PWith _ n _ _ _ _]) = Just n
292+ cname (PClauses fc _ _ [PClauseR _ _ _ _]) = Nothing
293+ cname (PClauses fc _ _ [PWithR _ _ _ _]) = Nothing
290294 getfc (PClauses fc _ _ _) = fc
291295
292296collect (PParams f ns ps : ds) = PParams f ns (collect ps) : collect ds