Fixed parsing of | outside of groups in =~ regex

This commit is contained in:
Vidar Holen 2013-11-03 13:13:24 -08:00
parent 8a3d259ae6
commit 71bc26aefa
1 changed files with 13 additions and 1 deletions

View File

@ -357,7 +357,14 @@ readConditionContents single = do
<|> return False <|> return False
readRegex = called "regex" $ do readRegex = called "regex" $ do
id <- getNextId id <- getNextId
parts <- many1 (readGroup <|> readSingleQuoted <|> readDoubleQuoted <|> readDollarExpression <|> readNormalLiteral "( " <|> readGlobLiteral) parts <- many1 (
readGroup <|>
readSingleQuoted <|>
readDoubleQuoted <|>
readDollarExpression <|>
readNormalLiteral "( " <|>
readPipeLiteral <|>
readGlobLiteral)
disregard spacing disregard spacing
return $ T_NormalWord id parts return $ T_NormalWord id parts
where where
@ -375,6 +382,10 @@ readConditionContents single = do
id <- getNextId id <- getNextId
str <- readGenericLiteral1 (singleQuote <|> doubleQuotable <|> oneOf "()") str <- readGenericLiteral1 (singleQuote <|> doubleQuotable <|> oneOf "()")
return $ T_Literal id str return $ T_Literal id str
readPipeLiteral = do
id <- getNextId
str <- string "|"
return $ T_Literal id str
readCondTerm = readCondNot <|> readCondExpr readCondTerm = readCondNot <|> readCondExpr
readCondNot = do readCondNot = do
@ -571,6 +582,7 @@ prop_readCondition5a= isOk readCondition "[[ $c =~ a(b) ]]"
prop_readCondition5b= isOk readCondition "[[ $c =~ f( ($var ]]) )* ]]" prop_readCondition5b= isOk readCondition "[[ $c =~ f( ($var ]]) )* ]]"
prop_readCondition6 = isOk readCondition "[[ $c =~ ^[yY]$ ]]" prop_readCondition6 = isOk readCondition "[[ $c =~ ^[yY]$ ]]"
prop_readCondition7 = isOk readCondition "[[ ${line} =~ ^[[:space:]]*# ]]" prop_readCondition7 = isOk readCondition "[[ ${line} =~ ^[[:space:]]*# ]]"
prop_readCondition8 = isOk readCondition "[[ $l =~ ogg|flac ]]"
readCondition = called "test expression" $ do readCondition = called "test expression" $ do
opos <- getPosition opos <- getPosition
id <- getNextId id <- getNextId