Sfoglia il codice sorgente

gidl: debug parser, fix example idl to be valid

parser errors are really bad. idk what to do about that honestly. monadic
parsing gets u every time
Pat Hickey 9 anni fa
parent
commit
cdab4a5b2b
3 ha cambiato i file con 19 aggiunte e 13 eliminazioni
  1. 3 2
      gidl.cabal
  2. 11 5
      src/Gidl.hs
  3. 5 6
      tests/example.idl

+ 3 - 2
gidl.cabal

@@ -9,7 +9,8 @@ build-type:          Simple
 cabal-version:       >=1.10
 
 library
-  exposed-modules:     Gidl.Parse,
+  exposed-modules:     Gidl,
+                       Gidl.Parse,
                        Gidl.Interface,
                        Gidl.Interface.AST,
                        Gidl.Schema,
@@ -17,7 +18,6 @@ library
                        Gidl.Types.AST,
                        Gidl.Types.Base,
                        Gidl.Backend.Cabal
-                     --  Gidl,
                      --  Gidl.Backend.Haskell,
                      --  Gidl.Backend.Haskell.Interface,
                      --  Gidl.Backend.Haskell.Test,
@@ -31,6 +31,7 @@ library
                        hashable,
                        mainland-pretty,
                        parsec,
+                       pretty-show,
                        transformers,
                        ivory-artifact
   hs-source-dirs:      src

+ 11 - 5
src/Gidl.hs

@@ -9,11 +9,12 @@ import Control.Monad
 import System.Console.GetOpt
 import System.Environment
 import System.Exit
+import Text.Show.Pretty
 
 import Ivory.Artifact
 import Gidl.Parse
-import Gidl.Backend.Haskell
-import Gidl.Backend.Ivory
+--import Gidl.Backend.Haskell
+--import Gidl.Backend.Ivory
 
 data OptParser opt = OptParser [String] (opt -> opt)
 instance Monoid (OptParser opt) where
@@ -123,12 +124,17 @@ run = do
   idl <- readFile (idlpath opts)
   case parseDecls idl of
     Left e -> print e >> exitFailure
-    Right (te, ie) ->
+    Right (te, ie) -> do
+      when (debug opts) $ do
+        putStrLn (ppShow te)
+        putStrLn (ppShow ie)
       case backend opts of
         HaskellBackend -> artifactBackend opts $
-          haskellBackend te ie (packagename opts) (namespace opts)
+          []
+          --haskellBackend te ie (packagename opts) (namespace opts)
         IvoryBackend -> artifactBackend opts $
-          ivoryBackend te ie (packagename opts) (namespace opts)
+          []
+          --ivoryBackend te ie (packagename opts) (namespace opts)
 
   where
   artifactBackend :: Opts -> [Artifact] -> IO ()

+ 5 - 6
tests/example.idl

@@ -36,11 +36,10 @@
   (alt meters_t)))
 
 (def-struct timed_coord_t
- ((coord coordinate_t)
-  (time time_micros_t)))
-
-
-(def-newtype waypoint_t coordinate_t)
+  ((lat lat_t)
+   (lon lon_t)
+   (alt meters_t)
+   (time time_micros_t)))
 
 -- Todo: the following interface syntax and semantics are a strawman.
 -- Interfaces have methods that are either streams or attrs.
@@ -56,7 +55,7 @@
 -- names permitted.
 
 (def-interface controllable_vehicle_i
-  ((current_waypoint (attr read      waypoint_t))
+  ((current_waypoint (attr read      coordinate_t))
    (next_waypoint    (attr readwrite timed_coord_t)))
   (vehicle_i)) -- Inherits from interface vehicle