Quick hack to read and discard array indexing in arithmetic contexts

This commit is contained in:
Vidar Holen 2013-03-22 16:42:40 -07:00
parent 9f244edae3
commit 6abb5fe72b
1 changed files with 12 additions and 2 deletions

View File

@ -345,6 +345,7 @@ prop_a9 = isOk readArithmeticContents "a^!-b"
prop_aA = isOk readArithmeticContents "! $?" prop_aA = isOk readArithmeticContents "! $?"
prop_aB = isOk readArithmeticContents "10#08 * 16#f" prop_aB = isOk readArithmeticContents "10#08 * 16#f"
prop_aC = isOk readArithmeticContents "\"$((3+2))\" + '37'" prop_aC = isOk readArithmeticContents "\"$((3+2))\" + '37'"
prop_aD = isOk readArithmeticContents "foo[9*y+x]++"
readArithmeticContents = readArithmeticContents =
readSequence readSequence
where where
@ -364,8 +365,17 @@ readArithmeticContents =
readVar = do readVar = do
id <- getNextId id <- getNextId
x <- readVariableName `thenSkip` spacing x <- readVariableName
return $ TA_Variable id x y <- readArrayIndex <|> return ""
optional spacing
return $ TA_Variable id (x ++ y)
-- Doesn't help with foo[foo]
readArrayIndex = do
char '['
x <- anyChar `reluctantlyTill1` (char ']')
char ']'
return $ "[" ++ x ++ "]"
readExpansion = do readExpansion = do
id <- getNextId id <- getNextId