git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Allow : and . in operator names
commit67df3cd1e2e3841aabff01da4770a3d8bbeb2a6c authorPhil Freeman <paf31@cantab.net> dateSun 22 Dec 2013, 14:12 (13 years ago) parentaa13d6d
5 files changed+18−6
examples/passing/Cons.purs+7 examples/passing/Operators.purs+5 purescript.cabal+1−1 src/Language/PureScript/Parser/Common.hs+3−3 src/Language/PureScript/Parser/Values.hs+2−2
examples/passing/Cons.pursnew file+7
@@ -0,0 +1,7 @@
1+infixr 6 :
2+
3+foreign import (:) :: forall a. a -> [a] -> [a]
4+
5+test1 = \xs -> 1 : xs
6+
7+test2 = 1 : 2 : 3 : []
examples/passing/Operators.purs+5
@@ -35,3 +35,8 @@ module Ops where
3535test9 = Ops.foo Ops.@@ "Hello World"
3636
3737test10 = "Hello" `Ops.bar` "World"
38+
39+(...) :: forall a. [a] -> [a] -> [a]
40+(...) = \as -> \bs -> as
41+
42+test11 = [1, 2, 3] ... [4, 5, 6]
purescript.cabal+1−1
@@ -1,5 +1,5 @@
11name: purescript
2−version: 0.1.16
2+version: 0.1.17
33cabal-version: >=1.8
44build-type: Simple
55license: MIT
src/Language/PureScript/Parser/Common.hs+3−3
@@ -74,7 +74,7 @@ reservedNames = [ "case"
7474
7575builtInOperators :: [String]
7676builtInOperators = [ "~", "-", "<=", ">=", "<", ">", "*", "/", "%", "++", "+", "<<", ">>>", ">>"
77− , "==", "!=", "&&", "||", "&", "^", "|", "!!", "!" ]
77+ , "==", "!=", "&&", "||", "&", "^", "|", "!!", "!", "." ]
7878
7979reservedOpNames :: [String]
8080reservedOpNames = builtInOperators ++ [ "->" ]
@@ -89,10 +89,10 @@ identLetter :: P.Parsec String u Char
8989identLetter = P.alphaNum <|> P.oneOf "_'"
9090
9191opStart :: P.Parsec String u Char
92−opStart = P.oneOf "!#%&*+/<=>?@^|~"
92+opStart = P.oneOf ":.!#%&*+/<=>?@^|~"
9393
9494opLetter :: P.Parsec String u Char
95−opLetter = P.oneOf ":#$%&*+./<=>?@^|"
95+opLetter = P.oneOf ":.#$%&*+./<=>?@^|"
9696
9797langDef :: PT.GenLanguageDef String u Identity
9898langDef = PT.LanguageDef
src/Language/PureScript/Parser/Values.hs+2−2
@@ -120,7 +120,7 @@ parsePropertyUpdate = do
120120
121121parseAccessor :: Value -> P.Parsec String ParseState Value
122122parseAccessor (Constructor _) = P.unexpected "constructor"
123−parseAccessor obj = Accessor <$> (C.indented *> C.dot *> C.indented *> C.identifier) <*> pure obj
123+parseAccessor obj = P.try $ Accessor <$> (C.indented *> C.dot *> P.notFollowedBy C.opLetter *> C.indented *> C.identifier) <*> pure obj
124124
125125parseValue :: P.Parsec String ParseState Value
126126parseValue =
@@ -161,7 +161,7 @@ parseAssignment = do
161161
162162parseWhile :: P.Parsec String ParseState Statement
163163parseWhile = While <$> (C.reserved "while" *> C.indented *> C.parens parseValue)
164− <*> (C.indented *> parseManyStatements)
164+ <*> (C.indented *> parseManyStatements)
165165
166166parseFor :: P.Parsec String ParseState Statement
167167parseFor = For <$> (C.reserved "for" *> C.indented *> C.lexeme (P.char '(') *> C.indented *> C.parseIdent)