git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Make the test suite pass
e21a483Phil Freeman
src/Language/PureScript/Operators.hs+23−22
@@ -38,7 +38,7 @@ rebracket :: [Declaration] -> Either String [Declaration]
38rebracket ds = do
38rebracket ds = do
39 m <- collectFixities ds
39 m <- collectFixities ds
40 let opTable = customOperatorTable m
40 let opTable = customOperatorTable m
41− ds' <- G.everywhereM (G.mkM (matchOperators opTable)) ds
41+ ds' <- G.everywhereM' (G.mkM (matchOperators opTable)) ds
42 return $ G.everywhere (G.mkT removeParens) ds'
42 return $ G.everywhere (G.mkT removeParens) ds'
43
43
44removeParens :: Value -> Value
44removeParens :: Value -> Value
@@ -104,25 +104,26 @@ globalOp :: String -> Qualified Ident
104globalOp = Qualified global . Op
104globalOp = Qualified global . Op
105
105
106builtIns :: [(Qualified Ident, Value -> Value -> Value, Precedence, Associativity)]
106builtIns :: [(Qualified Ident, Value -> Value -> Value, Precedence, Associativity)]
107−builtIns = [ (globalOp "!!", flip Indexer, 3, Infixl)
107+builtIns = [ (globalOp "<", Binary LessThan, 3, Infixl)
108− , (globalOp "&&", Binary And, 3, Infixr)
108+ , (globalOp "<=", Binary LessThanOrEqualTo, 3, Infixl)
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)
109+ , (globalOp ">", Binary GreaterThan, 3, Infixl)
114− , (globalOp "==", Binary EqualTo, 4, Infixl)
110+ , (globalOp ">=", Binary GreaterThanOrEqualTo, 3, Infixl)
115− , (globalOp "!=", Binary NotEqualTo, 4, Infixl)
111+ , (globalOp "!!", flip Indexer, 4, Infixl)
116− , (globalOp "*", Binary Multiply, 7, Infixl)
112+ , (globalOp "*", Binary Multiply, 5, Infixl)
117− , (globalOp "/", Binary Divide, 7, Infixl)
113+ , (globalOp "/", Binary Divide, 5, Infixl)
118− , (globalOp "%", Binary Modulus, 7, Infixl)
114+ , (globalOp "%", Binary Modulus, 5, Infixl)
119− , (globalOp "++", Binary Concat, 5, Infixr)
115+ , (globalOp "++", Binary Concat, 6, Infixr)
120− , (globalOp "+", Binary Add, 6, Infixl)
116+ , (globalOp "+", Binary Add, 7, Infixl)
121− , (globalOp "-", Binary Subtract, 6, Infixl)
117+ , (globalOp "-", Binary Subtract, 7, Infixl)
122− , (globalOp "<<", Binary ShiftLeft, 7, Infixl)
118+ , (globalOp "<<", Binary ShiftLeft, 8, Infixl)
119+ , (globalOp ">>", Binary ShiftRight, 8, Infixl)
123− , (globalOp ">>>", Binary ZeroFillShiftRight, 7, Infixl)
120+ , (globalOp ">>>", Binary ZeroFillShiftRight, 8, Infixl)
121+ , (globalOp "==", Binary EqualTo, 9, Infixl)
124− , (globalOp ">>", Binary ShiftRight, 7, Infixl)
122+ , (globalOp "!=", Binary NotEqualTo, 9, Infixl)
125− , (globalOp "&", Binary BitwiseAnd, 7, Infixl)
123+ , (globalOp "&", Binary BitwiseAnd, 10, Infixl)
126− , (globalOp "^", Binary BitwiseXor, 7, Infixl)
124+ , (globalOp "^", Binary BitwiseXor, 10, Infixl)
127− , (globalOp "|", Binary BitwiseOr, 7, Infixl)
125+ , (globalOp "|", Binary BitwiseOr, 10, Infixl)
126+ , (globalOp "&&", Binary And, 11, Infixr)
127+ , (globalOp "||", Binary Or, 11, Infixr)
128 ]
128 ]
129+
src/Language/PureScript/Parser/Common.hs+10−7
@@ -75,9 +75,12 @@ reservedNames = [ "case"
75 , "infixr"
75 , "infixr"
76 , "module" ]
76 , "module" ]
77
77
78+builtInOperators :: [String]
79+builtInOperators = [ "~", "-", "<=", ">=", "<", ">", "*", "/", "%", "++", "+", "<<", ">>>", ">>"
80+ , "==", "!=", "&&", "||", "&", "^", "|", "!!", "!" ]
81+
78reservedOpNames :: [String]
82reservedOpNames :: [String]
79−reservedOpNames = [ "!", "~", "-", "<=", ">=", "<", ">", "*", "/", "%", "++", "+", "<<", ">>>", ">>"
83+reservedOpNames = builtInOperators ++ [ "->" ]
80− , "==", "!=", "&", "^", "|", "&&", "||", "->", "!!" ]
81
84
82identStart :: P.Parsec String u Char
85identStart :: P.Parsec String u Char
83identStart = P.lower <|> P.oneOf "_$"
86identStart = P.lower <|> P.oneOf "_$"
@@ -89,7 +92,7 @@ identLetter :: P.Parsec String u Char
89identLetter = P.alphaNum <|> P.oneOf "_'"
92identLetter = P.alphaNum <|> P.oneOf "_'"
90
93
91opStart :: P.Parsec String u Char
94opStart :: P.Parsec String u Char
92−opStart = P.oneOf "!#$%&*+/<=>?@^|-~"
95+opStart = P.oneOf "!#$%&*+/<=>?@^|~"
93
96
94opLetter :: P.Parsec String u Char
97opLetter :: P.Parsec String u Char
95opLetter = P.oneOf ":#$%&*+./<=>?@^|"
98opLetter = P.oneOf ":#$%&*+./<=>?@^|"
@@ -161,14 +164,14 @@ fold first more combine = do
161buildPostfixParser :: P.Stream s m t => [P.ParsecT s u m (a -> a)] -> P.ParsecT s u m a -> P.ParsecT s u m a
164buildPostfixParser :: P.Stream s m t => [P.ParsecT s u m (a -> a)] -> P.ParsecT s u m a -> P.ParsecT s u m a
162buildPostfixParser f x = fold x (P.choice f) (flip ($))
165buildPostfixParser f x = fold x (P.choice f) (flip ($))
163
166
164−operatorOrReserved :: P.Parsec String u String
167+operatorOrBuiltIn :: P.Parsec String u String
165−operatorOrReserved = P.try operator <|> P.choice (map (\s -> P.try (reservedOp s) >> return s) reservedOpNames)
168+operatorOrBuiltIn = P.try operator <|> P.choice (map (\s -> P.try (reservedOp s) >> return s) builtInOperators)
166
169
167parseIdent :: P.Parsec String u Ident
170parseIdent :: P.Parsec String u Ident
168−parseIdent = (Ident <$> identifier) <|> (Op <$> parens operatorOrReserved)
171+parseIdent = (Ident <$> identifier) <|> (Op <$> parens operatorOrBuiltIn)
169
172
170parseIdentInfix :: P.Parsec String ParseState (Qualified Ident)
173parseIdentInfix :: 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)
172
175
173mark :: P.Parsec String ParseState a -> P.Parsec String ParseState a
176mark :: P.Parsec String ParseState a -> P.Parsec String ParseState a
174mark p = do
177mark p = do
src/Language/PureScript/Parser/Values.hs+1−1
@@ -143,7 +143,7 @@ parseValue =
143 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "-") >> return (Unary Negate)
143 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "-") >> return (Unary Negate)
144 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "+") >> return id ]
144 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "+") >> return id ]
145 , [ Infix (C.lexeme (P.try (C.indented *> C.parseIdentInfix P.<?> "operator") >>= \ident ->
145 , [ Infix (C.lexeme (P.try (C.indented *> C.parseIdentInfix P.<?> "operator") >>= \ident ->
146− return (BinaryNoParens ident))) AssocLeft ]
146+ return (BinaryNoParens ident))) AssocRight ]
147 ]
147 ]
148
148
149parseVariableIntroduction :: P.Parsec String ParseState Statement
149parseVariableIntroduction :: P.Parsec String ParseState Statement