Fixed glob parsing for [[:class:]] and [~.:]. Thanks to dualbus!

This commit is contained in:
Vidar Holen 2013-05-23 20:44:28 -07:00
parent 13d4ea6540
commit 034cfee66e
1 changed files with 13 additions and 2 deletions

View File

@ -504,6 +504,7 @@ readArithmeticContents =
prop_readCondition = isOk readCondition "[ \\( a = b \\) -a \\( c = d \\) ]" prop_readCondition = isOk readCondition "[ \\( a = b \\) -a \\( c = d \\) ]"
prop_readCondition2 = isOk readCondition "[[ (a = b) || (c = d) ]]" prop_readCondition2 = isOk readCondition "[[ (a = b) || (c = d) ]]"
prop_readCondition3 = isOk readCondition "[[ $c = [[:alpha:].~-] ]]"
readCondition = called "test expression" $ do readCondition = called "test expression" $ do
opos <- getPosition opos <- getPosition
id <- getNextId id <- getNextId
@ -660,6 +661,9 @@ readNormalLiteral end = do
prop_readGlob1 = isOk readGlob "*" prop_readGlob1 = isOk readGlob "*"
prop_readGlob2 = isOk readGlob "[^0-9]" prop_readGlob2 = isOk readGlob "[^0-9]"
prop_readGlob3 = isOk readGlob "[a[:alpha:]]"
prop_readGlob4 = isOk readGlob "[[:alnum:]]"
prop_readGlob5 = isOk readGlob "[^[:alpha:]1-9]"
readGlob = readExtglob <|> readSimple <|> readClass <|> readGlobbyLiteral readGlob = readExtglob <|> readSimple <|> readClass <|> readGlobbyLiteral
where where
readSimple = do readSimple = do
@ -670,9 +674,16 @@ readGlob = readExtglob <|> readSimple <|> readClass <|> readGlobbyLiteral
readClass = try $ do readClass = try $ do
id <- getNextId id <- getNextId
char '[' char '['
s <- many1 (letter <|> digit <|> oneOf "^-_:") s <- many1 (predefined <|> (liftM return $ letter <|> digit <|> oneOf globchars))
char ']' char ']'
return $ T_Glob id $ "[" ++ s ++ "]" return $ T_Glob id $ "[" ++ (concat s) ++ "]"
where
globchars = "^-_:?*.,!~@#$%=+{}/~"
predefined = do
try $ string "[:"
s <- many1 letter
string ":]"
return $ "[:" ++ s ++ ":]"
readGlobbyLiteral = do readGlobbyLiteral = do
id <- getNextId id <- getNextId