From 13284d4f6bbb5e81f0003fe295e4a6a3aca25efa Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sun, 27 Apr 2014 04:03:38 +1000 Subject: Parser can now handle interspersed node and edge statements --- src/Grasp/Parser.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Grasp/Parser.hs b/src/Grasp/Parser.hs index 3a71fdf..4b42ab6 100644 --- a/src/Grasp/Parser.hs +++ b/src/Grasp/Parser.hs @@ -36,14 +36,19 @@ parseGrasp = parse grasp "error" grasp = do string "digraph {" whiteSpace - n <- many node - e <- many edge + (n,e) <- stmtList ([],[]) string "}" eol eof return (n,e) +stmtList (n,e) = + try (node >>= (\x -> stmtList (x:n,e)) ) + <|> try (edge >>= (\x -> stmtList (n,x:e)) ) + <|> return (reverse n, reverse e) + + node = do i <- ident l <- labelAttrib -- cgit