Sockeye: Allow to use inlined for in node decls
authorDaniel Schwyn <schwyda@student.ethz.ch>
Tue, 4 Jul 2017 08:50:57 +0000 (10:50 +0200)
committerDaniel Schwyn <schwyda@student.ethz.ch>
Tue, 4 Jul 2017 08:50:57 +0000 (10:50 +0200)
Signed-off-by: Daniel Schwyn <schwyda@student.ethz.ch>

tools/sockeye/SockeyeASTFrontend.hs
tools/sockeye/SockeyeParser.hs

index ec675e5..5b50bf2 100644 (file)
@@ -83,7 +83,9 @@ data NodeDecl
     = NodeDecl
         { nodeId   :: Identifier
         , nodeSpec :: NodeSpec
-        } deriving (Show)
+        }
+    | MultiNodeDecl (For NodeDecl)
+    deriving (Show)
 
 data Identifier
     = SimpleIdent !String
index 858d83c..e943729 100644 (file)
@@ -177,15 +177,19 @@ nodeDecls = do
         single = do
             nodeId <- identifier
             reserved "is"
-            return [nodeId]
+            return [(Nothing, nodeId)]
         multiple = do
-            nodeIds <- commaSep1 identifier
+            nodeIds <- commaSep1 identifierFor
             reserved "are"
             return nodeIds
-        toNodeDecl nodeSpec nodeId = AST.NodeDecl
-            { AST.nodeId = nodeId
-            , AST.nodeSpec = nodeSpec
-            } 
+        toNodeDecl nodeSpec (forFn, ident) = let
+            nodeDecl = AST.NodeDecl
+                { AST.nodeId = ident
+                , AST.nodeSpec = nodeSpec
+                }
+            in case forFn of
+                Nothing -> nodeDecl
+                Just f  -> AST.MultiNodeDecl $ f nodeDecl
 
 identifier = do
     (_, ident) <- identifierHelper False