Ignore === in assignments, and add a special warning 1097 for ==.

This commit is contained in:
Vidar Holen 2015-08-22 12:20:03 -07:00
parent eea7bc326e
commit d0029ae1d4
1 changed files with 17 additions and 6 deletions

View File

@ -280,9 +280,9 @@ thenSkip main follow = do
return r return r
unexpecting s p = try $ unexpecting s p = try $
(try p >> unexpected s) <|> return () (try p >> fail ("Unexpected " ++ s)) <|> return ()
notFollowedBy2 = unexpecting "keyword/token" notFollowedBy2 = unexpecting ""
disregard = void disregard = void
@ -2058,8 +2058,19 @@ readAssignmentWord = try $ do
spacing spacing
return $ T_Assignment id op variable index value return $ T_Assignment id op variable index value
where where
readAssignmentOp = readAssignmentOp = do
(string "+=" >> return Append) <|> (string "=" >> return Assign) pos <- getPosition
unexpecting "" $ string "==="
choice [
string "+=" >> return Append,
do
try (string "==")
parseProblemAt pos ErrorC 1097
"Unexpected ==. For assignment, use =. For comparison, use [/[[."
return Assign,
string "=" >> return Assign
]
readEmptyLiteral = do readEmptyLiteral = do
id <- getNextId id <- getNextId
return $ T_Literal id "" return $ T_Literal id ""
@ -2119,8 +2130,8 @@ tryParseWordToken keyword t = try $ do
"Scripts are case sensitive. Use '" ++ keyword ++ "', not '" ++ str ++ "'." "Scripts are case sensitive. Use '" ++ keyword ++ "', not '" ++ str ++ "'."
return $ t id return $ t id
anycaseString str = anycaseString =
mapM anycaseChar str mapM anycaseChar
where where
anycaseChar c = char (toLower c) <|> char (toUpper c) anycaseChar c = char (toLower c) <|> char (toUpper c)