summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-04-27 04:03:38 +1000
committerJed Barber <jjbarber@y7mail.com>2014-04-27 04:03:38 +1000
commit13284d4f6bbb5e81f0003fe295e4a6a3aca25efa (patch)
tree181b2414e2efb1699ccbd2f8e0f88608b9fc2f33
parent5faa918bcbb4a2a7c255b789ab76e68748e57f1a (diff)
Parser can now handle interspersed node and edge statements
-rw-r--r--src/Grasp/Parser.hs9
1 files changed, 7 insertions, 2 deletions
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