git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix warnings introduced by -Wall
commit6fa58292d394eb91f6b1a50e5925c4627d7ec12d authorPhil Freeman <paf31@cantab.net> dateFri 6 Dec 2013, 09:43 (13 years ago) parent38e324a
7 files changed+98−58
purescript.cabal+20−21 src/Language/PureScript/Operators.hs+1 src/Language/PureScript/Parser/Common.hs+67−25 src/Language/PureScript/Parser/Types.hs−1 src/Language/PureScript/Pretty/Values.hs+1 src/Language/PureScript/Values.hs+2−1 src/Main.hs+7−10
purescript.cabal+20−21
@@ -14,46 +14,45 @@ author: Phil Freeman <paf31@cantab.net>
1414data-dir: ""
1515
1616library
17− build-depends: base >=4 && <5, syb -any, cmdtheline -any,
18− containers -any, mtl -any, transformers -any, parsec -any,
19− utf8-string -any
20− exposed-modules: Data.Generics.Extras Language.PureScript.Operators
21− Language.PureScript.Optimize Language.PureScript.Pretty.JS
22− Language.PureScript.CodeGen.JS.AST Main Language.PureScript
23− Language.PureScript.Declarations Language.PureScript.Names
24− Language.PureScript.Types Language.PureScript.Values
25− Language.PureScript.Kinds Language.PureScript.Pretty
26− Language.PureScript.Pretty.Common Language.PureScript.Pretty.Values
27− Language.PureScript.Pretty.Types Language.PureScript.Pretty.Kinds
17+ build-depends: base >=4 && <5, cmdtheline -any, containers -any,
18+ directory -any, filepath -any, mtl -any, parsec -any,
19+ syb -any, transformers -any, utf8-string -any
20+ exposed-modules: Data.Generics.Extras Language.PureScript
2821 Language.PureScript.CodeGen Language.PureScript.CodeGen.Externs
29− Language.PureScript.CodeGen.JS Language.PureScript.CodeGen.Monad
22+ Language.PureScript.CodeGen.JS Language.PureScript.CodeGen.JS.AST
23+ Language.PureScript.CodeGen.Monad Language.PureScript.Declarations
24+ Language.PureScript.Kinds Language.PureScript.Names
25+ Language.PureScript.Operators Language.PureScript.Optimize
3026 Language.PureScript.Parser Language.PureScript.Parser.Common
3127 Language.PureScript.Parser.Declarations
28+ Language.PureScript.Parser.Kinds Language.PureScript.Parser.State
3229 Language.PureScript.Parser.Types Language.PureScript.Parser.Values
33− Language.PureScript.Parser.State Language.PureScript.Parser.Kinds
30+ Language.PureScript.Pretty Language.PureScript.Pretty.Common
31+ Language.PureScript.Pretty.JS Language.PureScript.Pretty.Kinds
32+ Language.PureScript.Pretty.Types Language.PureScript.Pretty.Values
3433 Language.PureScript.TypeChecker
3534 Language.PureScript.TypeChecker.Kinds
3635 Language.PureScript.TypeChecker.Monad
37− Language.PureScript.TypeChecker.Types
3836 Language.PureScript.TypeChecker.Synonyms
39− Language.PureScript.Unknown
37+ Language.PureScript.TypeChecker.Types Language.PureScript.Types
38+ Language.PureScript.Unknown Language.PureScript.Values Main
4039 exposed: True
4140 buildable: True
4241 hs-source-dirs: src
4342
4443executable psc
4544 build-depends: base >=4 && <5, cmdtheline -any, containers -any,
46− mtl -any, transformers -any, parsec -any, utf8-string -any,
47− syb -any
45+ directory -any, filepath -any, mtl -any, parsec -any,
46+ purescript -any, syb -any, transformers -any, utf8-string -any
4847 main-is: Main.hs
4948 buildable: True
5049 hs-source-dirs: src
51− other-modules:
50+ ghc-options: -Wall -O2 -fno-warn-unused-do-bind
5251
5352test-suite tests
54− build-depends: base >=4 && <5, syb -any, directory -any,
55− filepath -any, containers -any, mtl -any, transformers -any,
56− parsec -any, utf8-string -any, purescript -any
53+ build-depends: base >=4 && <5, cmdtheline -any, containers -any,
54+ directory -any, filepath -any, mtl -any, parsec -any,
55+ purescript -any, syb -any, transformers -any, utf8-string -any
5756 type: exitcode-stdio-1.0
5857 main-is: Main.hs
5958 buildable: True
src/Language/PureScript/Operators.hs+1
@@ -113,6 +113,7 @@ builtIns = [ (globalOp "<", Binary LessThan, 3, Infixl)
113113 , (globalOp "/", Binary Divide, 5, Infixl)
114114 , (globalOp "%", Binary Modulus, 5, Infixl)
115115 , (globalOp "++", Binary Concat, 6, Infixr)
116+ , (globalOp ":", Binary Cons, 6, Infixr)
116117 , (globalOp "+", Binary Add, 7, Infixl)
117118 , (globalOp "-", Binary Subtract, 7, Infixl)
118119 , (globalOp "<<", Binary ShiftLeft, 8, Infixl)
src/Language/PureScript/Parser/Common.hs+67−25
@@ -16,14 +16,11 @@
1616
1717module Language.PureScript.Parser.Common where
1818
19−import Data.Char (isSpace)
19+import Data.Functor.Identity
2020import Control.Applicative
2121import Control.Monad
22−import Control.Monad.State
2322import Language.PureScript.Parser.State
24−import qualified Data.Map as M
2523import qualified Text.Parsec as P
26−import qualified Text.Parsec.Pos as P
2724import qualified Text.Parsec.Token as PT
2825
2926import Language.PureScript.Names
@@ -77,7 +74,7 @@ reservedNames = [ "case"
7774
7875builtInOperators :: [String]
7976builtInOperators = [ "~", "-", "<=", ">=", "<", ">", "*", "/", "%", "++", "+", "<<", ">>>", ">>"
80− , "==", "!=", "&&", "||", "&", "^", "|", "!!", "!" ]
77+ , "==", "!=", "&&", "||", "&", "^", "|", "!!", "!", ":" ]
8178
8279reservedOpNames :: [String]
8380reservedOpNames = builtInOperators ++ [ "->" ]
@@ -92,11 +89,12 @@ identLetter :: P.Parsec String u Char
9289identLetter = P.alphaNum <|> P.oneOf "_'"
9390
9491opStart :: P.Parsec String u Char
95−opStart = P.oneOf "!#$%&*+/<=>?@^|~"
92+opStart = P.oneOf "!#$%&*+/<=>?@^|~:"
9693
9794opLetter :: P.Parsec String u Char
9895opLetter = P.oneOf ":#$%&*+./<=>?@^|"
9996
97+langDef :: PT.GenLanguageDef String u Identity
10098langDef = PT.LanguageDef
10199 { PT.reservedNames = reservedNames
102100 , PT.reservedOpNames = reservedOpNames
@@ -111,36 +109,80 @@ langDef = PT.LanguageDef
111109 , PT.caseSensitive = True
112110 }
113111
112+tokenParser :: PT.GenTokenParser String u Identity
114113tokenParser = PT.makeTokenParser langDef
115114
116−lexeme = PT.lexeme tokenParser
117−identifier = PT.identifier tokenParser
118−reserved = PT.reserved tokenParser
119−reservedOp = PT.reservedOp tokenParser
120−operator = PT.operator tokenParser
121−stringLiteral = PT.stringLiteral tokenParser
122−whiteSpace = PT.whiteSpace tokenParser
123−squares = PT.squares tokenParser
124−semi = PT.semi tokenParser
125−comma = PT.comma tokenParser
126−colon = PT.colon tokenParser
127−dot = PT.dot tokenParser
128−natural = PT.natural tokenParser
115+lexeme :: P.Parsec String u a -> P.Parsec String u a
116+lexeme = PT.lexeme tokenParser
129117
118+identifier :: P.Parsec String u String
119+identifier = PT.identifier tokenParser
120+
121+reserved :: String -> P.Parsec String u ()
122+reserved = PT.reserved tokenParser
123+
124+reservedOp :: String -> P.Parsec String u ()
125+reservedOp = PT.reservedOp tokenParser
126+
127+operator :: P.Parsec String u String
128+operator = PT.operator tokenParser
129+
130+stringLiteral :: P.Parsec String u String
131+stringLiteral = PT.stringLiteral tokenParser
132+
133+whiteSpace :: P.Parsec String u ()
134+whiteSpace = PT.whiteSpace tokenParser
135+
136+semi :: P.Parsec String u String
137+semi = PT.semi tokenParser
138+
139+colon :: P.Parsec String u String
140+colon = PT.colon tokenParser
141+
142+dot :: P.Parsec String u String
143+dot = PT.dot tokenParser
144+
145+comma :: P.Parsec String u String
146+comma = PT.comma tokenParser
147+
148+tick :: P.Parsec String u Char
149+tick = lexeme $ P.char '`'
150+
151+pipe :: P.Parsec String u Char
152+pipe = lexeme $ P.char '|'
153+
154+natural :: P.Parsec String u Integer
155+natural = PT.natural tokenParser
156+
157+squares :: P.Parsec String ParseState a -> P.Parsec String ParseState a
158+squares = P.between (lexeme $ P.char '[') (lexeme $ indented *> P.char ']') . (indented *>)
159+
160+parens :: P.Parsec String ParseState a -> P.Parsec String ParseState a
130161parens = P.between (lexeme $ P.char '(') (lexeme $ indented *> P.char ')') . (indented *>)
162+
163+braces :: P.Parsec String ParseState a -> P.Parsec String ParseState a
131164braces = P.between (lexeme $ P.char '{') (lexeme $ indented *> P.char '}') . (indented *>)
165+
166+angles :: P.Parsec String ParseState a -> P.Parsec String ParseState a
132167angles = P.between (lexeme $ P.char '<') (lexeme $ indented *> P.char '>') . (indented *>)
133168
169+sepBy :: P.Parsec String ParseState a -> P.Parsec String ParseState sep -> P.Parsec String ParseState [a]
134170sepBy p s = P.sepBy (indented *> p) (indented *> s)
171+
172+sepBy1 :: P.Parsec String ParseState a -> P.Parsec String ParseState sep -> P.Parsec String ParseState [a]
135173sepBy1 p s = P.sepBy1 (indented *> p) (indented *> s)
136174
137−semiSep = flip sepBy semi
138−semiSep1 = flip sepBy1 semi
139−commaSep = flip sepBy comma
140−commaSep1 = flip sepBy1 comma
175+semiSep :: P.Parsec String ParseState a -> P.Parsec String ParseState [a]
176+semiSep = flip sepBy semi
141177
142−tick = lexeme $ P.char '`'
143−pipe = lexeme $ P.char '|'
178+semiSep1 :: P.Parsec String ParseState a -> P.Parsec String ParseState [a]
179+semiSep1 = flip sepBy1 semi
180+
181+commaSep :: P.Parsec String ParseState a -> P.Parsec String ParseState [a]
182+commaSep = flip sepBy comma
183+
184+commaSep1 :: P.Parsec String ParseState a -> P.Parsec String ParseState [a]
185+commaSep1 = flip sepBy1 comma
144186
145187properName :: P.Parsec String u ProperName
146188properName = lexeme $ ProperName <$> P.try ((:) <$> P.upper <*> many (PT.identLetter langDef) P.<?> "name")
src/Language/PureScript/Parser/Types.hs−1
@@ -24,7 +24,6 @@ import Language.PureScript.Parser.Common
2424import Control.Applicative
2525import qualified Text.Parsec as P
2626import qualified Text.Parsec.Expr as P
27−import Control.Arrow (Arrow(..))
2827import Control.Monad (unless)
2928
3029parseNumber :: P.Parsec String ParseState Type
src/Language/PureScript/Pretty/Values.hs+1
@@ -133,6 +133,7 @@ prettyPrintValue = fromMaybe (error "Incomplete pattern") . pattern matchValue (
133133 , [ binary Divide "/" ]
134134 , [ binary Modulus "%" ]
135135 , [ binary Concat "++" ]
136+ , [ binary Cons ":" ]
136137 , [ binary Add "+" ]
137138 , [ binary Subtract "-" ]
138139 , [ binary ShiftLeft "<<" ]
src/Language/PureScript/Values.hs+2−1
@@ -46,7 +46,8 @@ data BinaryOperator
4646 | ShiftLeft
4747 | ShiftRight
4848 | ZeroFillShiftRight
49− | Concat deriving (Show, Eq, Data, Typeable)
49+ | Concat
50+ | Cons deriving (Show, Eq, Data, Typeable)
5051
5152data Value
5253 = NumericLiteral (Either Integer Double)
src/Main.hs+7−10
@@ -15,19 +15,15 @@
1515module Main where
1616
1717import qualified Language.PureScript as P
18−import Data.Maybe (mapMaybe)
19−import Data.List (intercalate)
2018import System.Console.CmdTheLine
2119import Control.Applicative
2220import Control.Monad (forM)
2321import System.Exit (exitSuccess, exitFailure)
24−import qualified Text.Parsec as P
2522import qualified System.IO.UTF8 as U
26−import qualified Data.Map as M
2723
2824compile :: [FilePath] -> Maybe FilePath -> Maybe FilePath -> IO ()
29−compile inputFiles outputFile externsFile = do
30− asts <- fmap (fmap concat . sequence) $ forM inputFiles $ \inputFile -> do
25+compile input output externs = do
26+ asts <- fmap (fmap concat . sequence) $ forM input $ \inputFile -> do
3127 text <- U.readFile inputFile
3228 return $ P.runIndentParser P.parseDeclarations text
3329 case asts of
@@ -36,14 +32,14 @@ compile inputFiles outputFile externsFile = do
3632 exitFailure
3733 Right decls ->
3834 case P.compile decls of
39− Left error -> do
40− U.putStrLn error
35+ Left err -> do
36+ U.putStrLn err
4137 exitFailure
4238 Right (js, exts, _) -> do
43− case outputFile of
39+ case output of
4440 Just path -> U.writeFile path js
4541 Nothing -> U.putStrLn js
46− case externsFile of
42+ case externs of
4743 Nothing -> return ()
4844 Just filePath -> U.writeFile filePath exts
4945 exitSuccess
@@ -70,4 +66,5 @@ termInfo = defTI
7066 , termDoc = "Compiles PureScript to Javascript"
7167 }
7268
69+main :: IO ()
7370main = run (term, termInfo)