<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>ActionhaXe/CLArgs.hs</filename>
    </added>
    <added>
      <filename>System/Console/ParseArgs.hs</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -18,6 +18,8 @@
 module ActionhaXe.Data where
 
 import ActionhaXe.Lexer
+import ActionhaXe.CLArgs
+
 import Text.Parsec
 import Text.Parsec.Prim
 
@@ -240,11 +242,11 @@ type AsDefTuple = (AsDef, AsDefInfo)
 data AsStateEl = AsStateEl { sid::Int, scope::Map AsDef AsDefInfo }
     deriving (Show, Data, Typeable)
 
-data AsState = AsState{ filename::String, outfile::String, curId::Int, flags::Map String String, accessors::Map String (AsType, Bool, Bool), initMembers::[String], path::[Int], scopes::Tree AsStateEl }
+data AsState = AsState{ conf::Conf, filename::String, outfile::String, curId::Int, flags::Map String String, accessors::Map String (AsType, Bool, Bool), initMembers::[String], path::[Int], scopes::Tree AsStateEl }
     deriving (Show, Data, Typeable)
 
 initState :: AsState
-initState = AsState{ filename = &quot;&quot;, outfile = &quot;&quot;, curId = 0, path = [0], flags = Map.empty, accessors = Map.empty, initMembers = [], scopes = newScope 0}
+initState = AsState{ conf = ConfNone, filename = &quot;&quot;, outfile = &quot;&quot;, curId = 0, path = [0], flags = Map.empty, accessors = Map.empty, initMembers = [], scopes = newScope 0}
 
 getProperty name = 
     do x &lt;- getState</diff>
      <filename>ActionhaXe/Data.hs</filename>
    </modified>
    <modified>
      <diff>@@ -23,6 +23,9 @@ import ActionhaXe.Lexer
 import ActionhaXe.Data
 import ActionhaXe.Prim
 import ActionhaXe.Parser
+import ActionhaXe.CLArgs
+import qualified System.Console.ParseArgs as PA
+
 import Data.Map (Map)
 import qualified Data.Map as Map
 import Control.Monad.State
@@ -62,6 +65,9 @@ getMembers = do st &lt;- get
                 put st{initMembers = []}
                 return ret
 
+getCLArg f = do st &lt;- get
+                return $ PA.gotArg (confArgs (conf st)) f
+
 maybeEl f i = maybe &quot;&quot; (\m -&gt; f m) i
 
 cleanup s = subRegex (mkRegex &quot;\\$&quot;) s &quot;_S_&quot;
@@ -94,10 +100,13 @@ classBlock (Block l bs r)  = do
     x &lt;- get
     let a = accessors x
     let al = Map.toList a
-    let props = foldl (\str (k, (t, g, s)) -&gt; str ++ showws l ++ &quot;public var &quot; ++ k ++ &quot;(&quot; 
-                                          ++ (if g then &quot;get&quot;++ [toUpper $ head k] ++ tail k else &quot;null&quot;) ++ &quot;, &quot;
-                                          ++ (if s then &quot;set&quot;++ [toUpper $ head k] ++ tail k else &quot;null&quot;) 
-                                          ++ &quot;) : &quot; ++ datatype t ++ &quot;;&quot;) &quot;&quot; al
+    props &lt;- foldlM (\str (k, (t, g, s)) -&gt; do{ t' &lt;- datatype t
+                                              ; return $ str ++ showws l ++ &quot;public var &quot; ++ k ++ &quot;(&quot; 
+                                                         ++ (if g then &quot;get&quot;++ [toUpper $ head k] ++ tail k else &quot;null&quot;) ++ &quot;, &quot;
+                                                         ++ (if s then &quot;set&quot;++ [toUpper $ head k] ++ tail k else &quot;null&quot;) 
+                                                         ++ &quot;) : &quot; ++ t' ++ &quot;;&quot;
+                                              }
+                     ) &quot;&quot; al
     bi &lt;-  foldlM (\s b -&gt; do{ x &lt;- classBlockItem b; return $ s ++ x} ) &quot;&quot; bs 
     return $ showd l ++ props ++ showw l ++ bi ++ showb r
 
@@ -218,8 +227,9 @@ methodDecl (MethodDecl a f ac n s b) = do
           accessor ac name s@(Signature l args r ret) t = 
               case ac of
                   Just x -&gt; do{ a &lt;- showArgs args
+                              ; t' &lt;- datatypet t
                               ; return $ showd x ++ [toUpper $ head $ showd name] ++ tail (showb name) ++ showb l ++ a ++ showd r ++ &quot;:&quot; 
-                                ++ fst (datatypet t) ++ (case ret of { Just (c, t) -&gt; snd (datatypet t); Nothing -&gt; showw r})
+                                ++ fst t' ++ (case ret of { Just (c, t) -&gt; snd t'; Nothing -&gt; showw r})
                               }
                   Nothing -&gt; do{ s' &lt;- signature s; return $ showb name ++ s'}
           accblock arg ac (Block l bs r) = 
@@ -241,11 +251,12 @@ signatureArgs (Signature l args r ret) = do{ a &lt;- showArgs args
                                            }
 
 rettype ret = case ret of
-                  Just (c, t) -&gt; showb c ++ datatype t
-                  Nothing     -&gt; &quot;&quot;
+                  Just (c, t) -&gt; do{ t' &lt;- datatype t; return $ showb c ++ t'}
+                  Nothing     -&gt; return &quot;&quot;
 
 signature (Signature l args r ret) = do{ a &lt;- showArgs args
-                                       ; return $ showb l ++ a ++ showb r ++ rettype ret
+                                       ; ret' &lt;- rettype ret
+                                       ; return $ showb l ++ a ++ showb r ++ ret'
                                        }
 
 showArgs as = do{ as' &lt;- mapM showArg as; return $ concat as'}
@@ -308,28 +319,33 @@ namespace ns = case ns of
                    Just x -&gt; concat $ map (\n -&gt; (case (showd n) of { &quot;protected&quot; -&gt; &quot;public&quot;; _ -&gt; showd n})  ++ showw n) x
                    Nothing -&gt; &quot;&quot;
 
-datatypet d = span (\c -&gt; isAlphaNum c || c =='&gt;' || c == '&lt;') (datatype d)
+datatypet d = do{ d' &lt;- datatype d; return $ span (\c -&gt; isAlphaNum c || c =='&gt;' || c == '&lt;') d'}
 
+datatype :: AsType -&gt; StateT AsState IO String
 datatype d = 
     case d of
-        AsType n -&gt; (case (showd n) of
-                         &quot;void&quot;    -&gt; &quot;Void&quot;
-                         &quot;Boolean&quot; -&gt; &quot;Bool&quot;
-                         &quot;uint&quot;    -&gt; &quot;UInt&quot;
-                         &quot;int&quot;     -&gt; &quot;Int&quot;
-                         &quot;Number&quot;  -&gt; &quot;Number&quot;
-                         &quot;String&quot;  -&gt; &quot;String&quot;
-                         &quot;*&quot;       -&gt; &quot;Dynamic&quot;
-                         &quot;Object&quot;  -&gt; &quot;Dynamic&quot;
-                         &quot;Function&quot;-&gt; &quot;Dynamic&quot;
-                         &quot;Array&quot;   -&gt; &quot;Array&lt;Dynamic&gt;&quot;
-                         &quot;XML&quot;     -&gt; &quot;XML&quot;
-                         &quot;RegExp&quot;  -&gt; &quot;EReg&quot;
-                      ) ++ showw n
-        AsTypeRest -&gt; &quot;Array&lt;Dynamic&gt;&quot;
-        AsTypeUser n -&gt; showb n
-
-datatypeiM d Nothing = return $ datatype d
+        AsType n -&gt; do d' &lt;- (case (showd n) of 
+                                  &quot;void&quot;    -&gt; return &quot;Void&quot;
+                                  &quot;Boolean&quot; -&gt; return &quot;Bool&quot;
+                                  &quot;uint&quot;    -&gt; return &quot;UInt&quot;
+                                  &quot;int&quot;     -&gt; return &quot;Int&quot;
+                                  &quot;Number&quot;  -&gt; do ni &lt;- getCLArg NumberToInt
+                                                  if ni
+                                                       then return &quot;Int&quot;
+                                                       else return &quot;Float&quot;
+                                  &quot;String&quot;  -&gt; return &quot;String&quot;
+                                  &quot;*&quot;       -&gt; return &quot;Dynamic&quot;
+                                  &quot;Object&quot;  -&gt; return &quot;Dynamic&quot;
+                                  &quot;Function&quot;-&gt; return &quot;Dynamic&quot;
+                                  &quot;Array&quot;   -&gt; return &quot;Array&lt;Dynamic&gt;&quot;
+                                  &quot;XML&quot;     -&gt; return &quot;XML&quot;
+                                  &quot;RegExp&quot;  -&gt; return &quot;EReg&quot;
+                              )
+                       return $ d' ++ showw n
+        AsTypeRest -&gt; return &quot;Array&lt;Dynamic&gt;&quot;
+        AsTypeUser n -&gt; return $ showb n
+
+datatypeiM d Nothing = datatype d
 datatypeiM d i = 
     case d of
         AsType n -&gt; do{ r &lt;- case (showd n) of
@@ -337,13 +353,16 @@ datatypeiM d i =
                             &quot;Boolean&quot; -&gt; return &quot;Bool&quot;
                             &quot;uint&quot;    -&gt; return &quot;UInt&quot;
                             &quot;int&quot;     -&gt; return &quot;Int&quot;
-                            &quot;Number&quot;  -&gt; do{ case i of
+                            &quot;Number&quot;  -&gt; do  case i of
                                                  Just (o, e) -&gt; do{ if hasFloat e
                                                                         then return &quot;Float&quot;
                                                                         else return &quot;Int&quot;
                                                                   } 
-                                                 Nothing -&gt; return &quot;Float&quot;
-                                           }
+                                                 Nothing -&gt; do ni &lt;- getCLArg NumberToInt
+                                                               if ni
+                                                                   then return &quot;Int&quot;
+                                                                   else return &quot;Float&quot;
+                                           
                             &quot;String&quot;  -&gt; return &quot;String&quot;
                             &quot;*&quot;       -&gt; return &quot;Dynamic&quot;
                             &quot;Object&quot;  -&gt; return &quot;Dynamic&quot;</diff>
      <filename>ActionhaXe/Translator.hs</filename>
    </modified>
    <modified>
      <diff>@@ -2,20 +2,21 @@ as3tohaxe - An Actionscript 3 to haXe source file converter written in Haskell
 Copyright (C) 2008 Don-Duong Quach
 
 For more info check visit: 
-http://geekrelief.wordpress.com
+http://groups.google.com/group/as3tohaxe
 http://www.github.com/geekrelief/as3tohaxe
+http://geekrelief.wordpress.com
 Donations are appreciated!
 
-
 -- Running --
 Type 'as3tohaxe' and a directory or file to convert.  
 A directory named &quot;hx_output&quot; will be created in the current
 directory if necessary.  The supplied &quot;.as&quot; files will be 
 translated into haxe files and stored there.  If the command
-is run more than once, and pre-existing files will be skipped.
+is run more than once, and pre-existing files will be overwritten.
 
 -- Binary --
-There is a binary 'as3tohaxe' included for Mac OSX 10.5.
+Binaries for Mac OSX Leopard and Windows are available under 
+the Files section of the as3tohaxe google group.
 
 -- Compiling --
 Requirements 
@@ -24,8 +25,7 @@ Requirements
 - Cabal for parsec http://www.haskell.org/cabal/
 - parsec 3 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/parsec
 
-Running: ghc --make -XDeriveDataTypeable as3tohaxe.hs
-will produce the binary 'as3tohaxe'
+Compile with: ghc --make -XDeriveDataTypeable as3tohaxe.hs
 
 -- License --
 This program and its source is GPL licensed.  Please read the LICENSE</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -22,47 +22,70 @@ import ActionhaXe.Data
 import ActionhaXe.Prim
 import ActionhaXe.Parser
 import ActionhaXe.Translator
+import ActionhaXe.CLArgs
+
 import System.Directory
 import System.Environment (getArgs)
 import Control.Monad.State
 import System.Exit
 import Data.Char (toUpper, toLower)
 import Data.List (isSuffixOf)
+import System.Console.ParseArgs
+import Data.Maybe (fromJust, fromMaybe)
 
-outdir = &quot;hx_output/&quot;
-
+translateFile :: String -&gt; StateT Conf IO ()
 translateFile filename = do
-    putStrLn $ &quot;Translating &quot; ++ filename
-    contents &lt;- readFile filename
+    conf &lt;- get
+    let outdir = confOutput conf
+    liftIO $ putStrLn $ &quot;Translating &quot; ++ filename
+    contents &lt;- liftIO $ readFile filename
     let tokens = runLexer &quot;&quot; contents
     let outfilename = outdir ++ (reverse $ &quot;xh&quot; ++ ( drop 2 $ reverse filename))
     program &lt;- case parseTokens filename tokens of
-        Right p@(AS3Program x st) -&gt; return (p, st{outfile = outfilename })
-        Right p@(AS3Directives x st) -&gt; return (p, st{outfile = outfilename })
+        Right p@(AS3Program x st) -&gt; return (p, st{outfile = outfilename, conf=conf })
+        Right p@(AS3Directives x st) -&gt; return (p, st{outfile = outfilename, conf=conf })
         Left err  -&gt; fail $ show err
-    trans &lt;- runStateT (translateAs3Ast (fst program)) (snd program)
-    writeFile outfilename $ fst trans
+    trans &lt;- liftIO $ runStateT (translateAs3Ast (fst program)) (snd program)
+    liftIO $ writeFile outfilename $ fst trans
 
-isFile f = do t &lt;- doesFileExist f
+isFile :: String -&gt; StateT Conf IO Bool
+isFile f = do conf &lt;- get
+              let outdir = confOutput conf
+              t &lt;- liftIO $ doesFileExist f
               let outfilename = outdir ++ (reverse $ &quot;xh&quot; ++ ( drop 2 $ reverse f))
-              o &lt;- doesFileExist (outfilename)
-              when o $ putStrLn $ &quot;Skipping &quot; ++ f
+              o &lt;- liftIO $ doesFileExist (outfilename)
+              when o $ liftIO $ putStrLn $ &quot;Skipping &quot; ++ f
               return $ not o &amp;&amp; t &amp;&amp; (&quot;as&quot; == (map toLower $ reverse $ take 2 $ reverse f))
 
-isDir d = do t &lt;- doesDirectoryExist d
+isDir :: String -&gt; StateT Conf IO Bool
+isDir d = do t &lt;- liftIO $ doesDirectoryExist d
              return $ t
 
+translateDir :: String -&gt; StateT Conf IO ()
 translateDir dir = do 
-    contents &lt;- getDirectoryContents dir
-    dirExists &lt;- doesDirectoryExist (outdir ++ dir) 
-    unless dirExists (createDirectoryIfMissing True (outdir++dir) &gt;&gt; putStrLn (&quot;Created &quot; ++ outdir++dir))
+    conf &lt;- get
+    let outdir = confOutput conf
+    contents &lt;- liftIO $ getDirectoryContents dir
+    dirExists &lt;- liftIO $ doesDirectoryExist (outdir ++ dir) 
+    liftIO $ unless dirExists (createDirectoryIfMissing True (outdir++dir) &gt;&gt; putStrLn (&quot;Created &quot; ++ outdir++dir))
     let c = map (\e -&gt; dir++&quot;/&quot;++e) (filter (\d-&gt; d /= &quot;.&quot; &amp;&amp; d /=&quot;..&quot; &amp;&amp; d /= &quot;.svn&quot;) contents)
     asfiles &lt;- filterM isFile c
     asdirs &lt;- filterM isDir c
     mapM_ translateFile asfiles
     mapM_ translateDir asdirs
 
-main = do args &lt;- getArgs
+main = do args &lt;- parseArgsIO ArgsTrailing clargs
+          let input = fromJust $ getArgString args Input 
+          let outdir = fromMaybe &quot;hx_output/&quot; $ getArgString args OutputDir 
+          let conf = Conf{ confArgs = args , confInput = input, confOutput = outdir}
+          if isSuffixOf &quot;.as&quot; input
+              then do
+                      dirExists &lt;- doesDirectoryExist outdir
+                      unless dirExists ((createDirectoryIfMissing True outdir) &gt;&gt; putStrLn (&quot;Created &quot; ++ outdir))
+                      runStateT (translateFile input) conf
+              else runStateT (translateDir input) conf
+
+{-        args &lt;- getArgs
           if length args == 0
               then do putStrLn &quot;as3tohaxe Copyright (c) 2008 Don-Duong Quach\nUsage: as3tohaxe [directory | filename]&quot;
                       exitWith ExitSuccess
@@ -73,3 +96,4 @@ main = do args &lt;- getArgs
                        unless dirExists ((createDirectoryIfMissing True outdir) &gt;&gt; putStrLn (&quot;Created &quot; ++ outdir))
                        translateFile $ args!!0
               else translateDir $ args!!0
+-}</diff>
      <filename>as3tohaxe.hs</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9796ed455099204720413200532155e1fed963ca</id>
    </parent>
  </parents>
  <author>
    <name>Don-Duong Quach</name>
    <email>geekrelief@gmail.com</email>
  </author>
  <url>http://github.com/geekrelief/as3tohaxe/commit/152a4cba3ac9147751bfd27b09d921d550bb343e</url>
  <id>152a4cba3ac9147751bfd27b09d921d550bb343e</id>
  <committed-date>2008-10-29T21:26:13-07:00</committed-date>
  <authored-date>2008-10-29T21:26:13-07:00</authored-date>
  <message>Added command line options</message>
  <tree>10b6a680bb2b2cc4075991e4999fdd76b0baa08d</tree>
  <committer>
    <name>Don-Duong Quach</name>
    <email>geekrelief@gmail.com</email>
  </committer>
</commit>
