git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Use dot for module name separator, not a colon
commit38e324a8c692ffc3fb8e7249a3aa9c7ba8d17125 authorPhil Freeman <paf31@cantab.net> dateFri 6 Dec 2013, 09:01 (13 years ago) parent93c5248
8 files changed+33−21
examples/passing/Module.purs+6−6 examples/passing/NameResolution.purs+1−1 examples/passing/Operators.purs+2−2 purescript.cabal+1−1 src/Language/PureScript/Names.hs+1−1 src/Language/PureScript/Parser/Common.hs+11−3 src/Language/PureScript/Parser/Types.hs+2−2 src/Language/PureScript/Parser/Values.hs+9−5
examples/passing/Module.purs+6−6
@@ -2,7 +2,7 @@ module Test where
22
33 data Foo = Foo String
44
5− foo :: Test:Foo -> String
5+ foo :: Test.Foo -> String
66 foo = \f -> case f of Foo s -> s ++ "foo"
77
88 bar :: Foo -> String
@@ -12,11 +12,11 @@ module Test where
1212
1313 inner = "Inner"
1414
15−baz :: Test:Foo -> String
16−baz = Test:foo
15+baz :: Test.Foo -> String
16+baz = Test.foo
1717
1818innerCopy :: String
19−innerCopy = Test:Inner:inner
19+innerCopy = Test.Inner.inner
2020
21−match :: Test:Foo -> String
22−match = \f -> case f of Test:Foo s -> s ++ "foo"
21+match :: Test.Foo -> String
22+match = \f -> case f of Test.Foo s -> s ++ "foo"
examples/passing/NameResolution.purs+1−1
@@ -12,4 +12,4 @@ module A where
1212
1313 baz = foo
1414
15− abc = A:B:abc
15+ abc = A.B.abc
examples/passing/Operators.purs+2−2
@@ -32,6 +32,6 @@ module Ops where
3232
3333 bar = \s1 s2 -> s1 ++ s2
3434
35−test9 = Ops:foo Ops:@@ "Hello World"
35+test9 = Ops.foo Ops.@@ "Hello World"
3636
37−test10 = "Hello" `Ops:bar` "World"
37+test10 = "Hello" `Ops.bar` "World"
purescript.cabal+1−1
@@ -1,5 +1,5 @@
11name: purescript
2−version: 0.1.14
2+version: 0.1.15
33cabal-version: >=1.8
44build-type: Simple
55license: MIT
src/Language/PureScript/Names.hs+1−1
@@ -44,7 +44,7 @@ global = ModulePath []
4444data Qualified a = Qualified ModulePath a deriving (Eq, Ord, Data, Typeable)
4545
4646instance (Show a) => Show (Qualified a) where
47− show (Qualified (ModulePath names) a) = intercalate ":" (map show names ++ [show a])
47+ show (Qualified (ModulePath names) a) = intercalate "." (map show names ++ [show a])
4848
4949qualify :: ModulePath -> Qualified a -> (ModulePath, a)
5050qualify mp (Qualified (ModulePath []) a) = (mp, a)
src/Language/PureScript/Parser/Common.hs+11−3
@@ -151,7 +151,7 @@ parseQualified parser = part global
151151 part path = (do name <- P.try (properName <* delimiter)
152152 part (subModule path name))
153153 <|> (Qualified path <$> P.try parser)
154− delimiter = indented *> colon <* P.notFollowedBy colon
154+ delimiter = indented *> dot
155155
156156integerOrFloat :: P.Parsec String u (Either Integer Double)
157157integerOrFloat = (Left <$> P.try (PT.natural tokenParser) <|>
@@ -166,8 +166,16 @@ fold first more combine = do
166166 bs <- P.many more
167167 return $ foldl combine a bs
168168
169−buildPostfixParser :: P.Stream s m t => [P.ParsecT s u m (a -> a)] -> P.ParsecT s u m a -> P.ParsecT s u m a
170−buildPostfixParser f x = fold x (P.choice f) (flip ($))
169+buildPostfixParser :: P.Stream s m t => [a -> P.ParsecT s u m a] -> P.ParsecT s u m a -> P.ParsecT s u m a
170+buildPostfixParser fs first = do
171+ a <- first
172+ go a
173+ where
174+ go a = do
175+ maybeA <- P.optionMaybe $ P.choice (map ($ a) fs)
176+ case maybeA of
177+ Nothing -> return a
178+ Just a' -> go a'
171179
172180operatorOrBuiltIn :: P.Parsec String u String
173181operatorOrBuiltIn = P.try operator <|> P.choice (map (\s -> P.try (reservedOp s) >> return s) builtInOperators)
src/Language/PureScript/Parser/Types.hs+2−2
@@ -75,8 +75,8 @@ parseTypeAtom = indented *> P.choice (map P.try
7575parseAnyType :: P.Parsec String ParseState Type
7676parseAnyType = (P.buildExpressionParser operators . buildPostfixParser postfixTable $ parseTypeAtom) P.<?> "type"
7777 where
78− postfixTable :: [P.Parsec String ParseState (Type -> Type)]
79− postfixTable = [ flip TypeApp <$> P.try (indented *> parseTypeAtom) ]
78+ postfixTable :: [Type -> P.Parsec String ParseState Type]
79+ postfixTable = [ \x -> TypeApp x <$> P.try (indented *> parseTypeAtom) ]
8080 operators = [ [ P.Infix (lexeme (P.try (P.string "->")) >> return (\t1 t2 -> Function [t1] t2)) P.AssocRight ] ]
8181
8282parseType :: P.Parsec String ParseState Type
src/Language/PureScript/Parser/Values.hs+9−5
@@ -126,6 +126,10 @@ parsePropertyUpdate = do
126126 value <- C.indented *> parseValue
127127 return (name, value)
128128
129+parseAccessor :: Value -> P.Parsec String ParseState Value
130+parseAccessor (Constructor _) = P.unexpected "constructor"
131+parseAccessor obj = Accessor <$> (C.indented *> C.dot *> C.indented *> C.identifier) <*> pure obj
132+
129133parseValue :: P.Parsec String ParseState Value
130134parseValue =
131135 (buildExpressionParser operators
@@ -133,11 +137,11 @@ parseValue =
133137 $ indexersAndAccessors) P.<?> "expression"
134138 where
135139 indexersAndAccessors = C.buildPostfixParser postfixTable1 parseValueAtom
136− postfixTable1 = [ Accessor <$> (C.indented *> C.dot *> C.indented *> C.identifier)
137− , P.try $ flip ObjectUpdate <$> (C.indented *> C.braces (C.commaSep1 (C.indented *> parsePropertyUpdate))) ]
138− postfixTable2 = [ P.try (C.indented *> indexersAndAccessors >>= \t2 -> return (\t1 -> App t1 [t2]))
139− , P.try $ flip App <$> (C.indented *> C.parens (C.commaSep parseValue))
140− , flip TypedValue <$> (P.try (C.lexeme (C.indented *> P.string "::")) *> parsePolyType) ]
140+ postfixTable1 = [ parseAccessor
141+ , \v -> P.try $ flip ObjectUpdate <$> (C.indented *> C.braces (C.commaSep1 (C.indented *> parsePropertyUpdate))) <*> pure v ]
142+ postfixTable2 = [ \v -> P.try (C.indented *> indexersAndAccessors >>= \t2 -> return (\t1 -> App t1 [t2])) <*> pure v
143+ , \v -> P.try $ flip App <$> (C.indented *> C.parens (C.commaSep parseValue)) <*> pure v
144+ , \v -> flip TypedValue <$> (P.try (C.lexeme (C.indented *> P.string "::")) *> parsePolyType) <*> pure v ]
141145 operators = [ [ Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "!") >> return (Unary Not)
142146 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "~") >> return (Unary BitwiseNot)
143147 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "-") >> return (Unary Negate)