Quick hack to read and discard array indexing in arithmetic contexts
This commit is contained in:
parent
9f244edae3
commit
6abb5fe72b
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue