summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Grasp/Parser.hs37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/Grasp/Parser.hs b/src/Grasp/Parser.hs
index 4b42ab6..75f8fad 100644
--- a/src/Grasp/Parser.hs
+++ b/src/Grasp/Parser.hs
@@ -1,6 +1,12 @@
module Grasp.Parser (
GraspProgram(..),
- parseGrasp
+ GraspNode,
+
+ parseGrasp,
+
+ getNodeLabel,
+ getFloat,
+ getString
) where
@@ -13,7 +19,15 @@ import Data.Graph.Inductive.Tree
-data GraspProgram = Gr String String
+data GraspProgram = Gr GraspNode GraspLabel
+
+
+data GraspNode = GFloat GraspLabel Float
+ | GString GraspLabel String
+ | GEmpty GraspLabel
+
+
+type GraspLabel = String
@@ -32,6 +46,25 @@ parseGrasp = parse grasp "error"
+getNodeLabel :: GraspNode -> GraspLabel
+getNodeLabel (GFloat label _) = label
+getNodeLabel (GString label _) = label
+getNodelabel (GEmpty label) = label
+
+
+
+getFloat :: GraspNode -> Maybe Float
+getFloat (GFloat _ f) = Just f
+getFloat _ = Nothing
+
+
+
+getString :: GraspNode -> Maybe String
+getString (GString _ s) = Just s
+getString _ = Nothing
+
+
+
grasp = do
string "digraph {"