summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-04-27 22:37:47 +1000
committerJed Barber <jjbarber@y7mail.com>2014-04-27 22:37:47 +1000
commita0c0d197659eb12f9f22a154af2af7b50c57d57f (patch)
tree6862b10f4352c3e5c74e7d960177b809abf7f958 /src
parent13284d4f6bbb5e81f0003fe295e4a6a3aca25efa (diff)
Added variables to node data structure
Diffstat (limited to 'src')
-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 {"