git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Make the test suite pass
commite21a4838d438c02ac2d49402c2d938e2a2a25482 authorPhil Freeman <paf31@cantab.net> dateThu 14 Nov 2013, 15:34 (13 years ago) parent6deb41c
3 files changed+34−30
src/Language/PureScript/Operators.hs+23−22 src/Language/PureScript/Parser/Common.hs+10−7 src/Language/PureScript/Parser/Values.hs+1−1
src/Language/PureScript/Operators.hs+23−22
@@ -38,7 +38,7 @@ rebracket :: [Declaration] -> Either String [Declaration]
3838rebracket ds = do
3939 m <- collectFixities ds
4040 let opTable = customOperatorTable m
41− ds' <- G.everywhereM (G.mkM (matchOperators opTable)) ds
41+ ds' <- G.everywhereM' (G.mkM (matchOperators opTable)) ds
4242 return $ G.everywhere (G.mkT removeParens) ds'
4343
4444removeParens :: Value -> Value
@@ -104,25 +104,26 @@ globalOp :: String -> Qualified Ident
104104globalOp = Qualified global . Op
105105
106106builtIns :: [(Qualified Ident, Value -> Value -> Value, Precedence, Associativity)]
107−builtIns = [ (globalOp "!!", flip Indexer, 3, Infixl)
108− , (globalOp "&&", Binary And, 3, Infixr)
109− , (globalOp "||", Binary Or, 3, Infixr)
110− , (globalOp "<=", Binary LessThanOrEqualTo, 4, Infixl)
111− , (globalOp ">=", Binary GreaterThanOrEqualTo, 4, Infixl)
112− , (globalOp "<", Binary LessThan, 4, Infixl)
113− , (globalOp ">", Binary GreaterThan, 4, Infixl)
114− , (globalOp "==", Binary EqualTo, 4, Infixl)
115− , (globalOp "!=", Binary NotEqualTo, 4, Infixl)
116− , (globalOp "*", Binary Multiply, 7, Infixl)
117− , (globalOp "/", Binary Divide, 7, Infixl)
118− , (globalOp "%", Binary Modulus, 7, Infixl)
119− , (globalOp "++", Binary Concat, 5, Infixr)
120− , (globalOp "+", Binary Add, 6, Infixl)
121− , (globalOp "-", Binary Subtract, 6, Infixl)
122− , (globalOp "<<", Binary ShiftLeft, 7, Infixl)
123− , (globalOp ">>>", Binary ZeroFillShiftRight, 7, Infixl)
124− , (globalOp ">>", Binary ShiftRight, 7, Infixl)
125− , (globalOp "&", Binary BitwiseAnd, 7, Infixl)
126− , (globalOp "^", Binary BitwiseXor, 7, Infixl)
127− , (globalOp "|", Binary BitwiseOr, 7, Infixl)
107+builtIns = [ (globalOp "<", Binary LessThan, 3, Infixl)
108+ , (globalOp "<=", Binary LessThanOrEqualTo, 3, Infixl)
109+ , (globalOp ">", Binary GreaterThan, 3, Infixl)
110+ , (globalOp ">=", Binary GreaterThanOrEqualTo, 3, Infixl)
111+ , (globalOp "!!", flip Indexer, 4, Infixl)
112+ , (globalOp "*", Binary Multiply, 5, Infixl)
113+ , (globalOp "/", Binary Divide, 5, Infixl)
114+ , (globalOp "%", Binary Modulus, 5, Infixl)
115+ , (globalOp "++", Binary Concat, 6, Infixr)
116+ , (globalOp "+", Binary Add, 7, Infixl)
117+ , (globalOp "-", Binary Subtract, 7, Infixl)
118+ , (globalOp "<<", Binary ShiftLeft, 8, Infixl)
119+ , (globalOp ">>", Binary ShiftRight, 8, Infixl)
120+ , (globalOp ">>>", Binary ZeroFillShiftRight, 8, Infixl)
121+ , (globalOp "==", Binary EqualTo, 9, Infixl)
122+ , (globalOp "!=", Binary NotEqualTo, 9, Infixl)
123+ , (globalOp "&", Binary BitwiseAnd, 10, Infixl)
124+ , (globalOp "^", Binary BitwiseXor, 10, Infixl)
125+ , (globalOp "|", Binary BitwiseOr, 10, Infixl)
126+ , (globalOp "&&", Binary And, 11, Infixr)
127+ , (globalOp "||", Binary Or, 11, Infixr)
128128 ]
129+
src/Language/PureScript/Parser/Common.hs+10−7
@@ -75,9 +75,12 @@ reservedNames = [ "case"
7575 , "infixr"
7676 , "module" ]
7777
78+builtInOperators :: [String]
79+builtInOperators = [ "~", "-", "<=", ">=", "<", ">", "*", "/", "%", "++", "+", "<<", ">>>", ">>"
80+ , "==", "!=", "&&", "||", "&", "^", "|", "!!", "!" ]
81+
7882reservedOpNames :: [String]
79−reservedOpNames = [ "!", "~", "-", "<=", ">=", "<", ">", "*", "/", "%", "++", "+", "<<", ">>>", ">>"
80− , "==", "!=", "&", "^", "|", "&&", "||", "->", "!!" ]
83+reservedOpNames = builtInOperators ++ [ "->" ]
8184
8285identStart :: P.Parsec String u Char
8386identStart = P.lower <|> P.oneOf "_$"
@@ -89,7 +92,7 @@ identLetter :: P.Parsec String u Char
8992identLetter = P.alphaNum <|> P.oneOf "_'"
9093
9194opStart :: P.Parsec String u Char
92−opStart = P.oneOf "!#$%&*+/<=>?@^|-~"
95+opStart = P.oneOf "!#$%&*+/<=>?@^|~"
9396
9497opLetter :: P.Parsec String u Char
9598opLetter = P.oneOf ":#$%&*+./<=>?@^|"
@@ -161,14 +164,14 @@ fold first more combine = do
161164buildPostfixParser :: P.Stream s m t => [P.ParsecT s u m (a -> a)] -> P.ParsecT s u m a -> P.ParsecT s u m a
162165buildPostfixParser f x = fold x (P.choice f) (flip ($))
163166
164−operatorOrReserved :: P.Parsec String u String
165−operatorOrReserved = P.try operator <|> P.choice (map (\s -> P.try (reservedOp s) >> return s) reservedOpNames)
167+operatorOrBuiltIn :: P.Parsec String u String
168+operatorOrBuiltIn = P.try operator <|> P.choice (map (\s -> P.try (reservedOp s) >> return s) builtInOperators)
166169
167170parseIdent :: P.Parsec String u Ident
168−parseIdent = (Ident <$> identifier) <|> (Op <$> parens operatorOrReserved)
171+parseIdent = (Ident <$> identifier) <|> (Op <$> parens operatorOrBuiltIn)
169172
170173parseIdentInfix :: P.Parsec String ParseState (Qualified Ident)
171−parseIdentInfix = (P.between tick tick (parseQualified (Ident <$> identifier))) <|> parseQualified (Op <$> operatorOrReserved)
174+parseIdentInfix = (P.between tick tick (parseQualified (Ident <$> identifier))) <|> parseQualified (Op <$> operatorOrBuiltIn)
172175
173176mark :: P.Parsec String ParseState a -> P.Parsec String ParseState a
174177mark p = do
src/Language/PureScript/Parser/Values.hs+1−1
@@ -143,7 +143,7 @@ parseValue =
143143 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "-") >> return (Unary Negate)
144144 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "+") >> return id ]
145145 , [ Infix (C.lexeme (P.try (C.indented *> C.parseIdentInfix P.<?> "operator") >>= \ident ->
146− return (BinaryNoParens ident))) AssocLeft ]
146+ return (BinaryNoParens ident))) AssocRight ]
147147 ]
148148
149149parseVariableIntroduction :: P.Parsec String ParseState Statement