Fixed parsing of "test$"
This commit is contained in:
parent
092073d0b3
commit
5794f3d390
|
@ -407,7 +407,7 @@ readArithmeticContents =
|
||||||
|
|
||||||
readExpansion = do
|
readExpansion = do
|
||||||
id <- getNextId
|
id <- getNextId
|
||||||
x <- readDollar
|
x <- readNormalDollar
|
||||||
spacing
|
spacing
|
||||||
return $ TA_Expansion id x
|
return $ TA_Expansion id x
|
||||||
|
|
||||||
|
@ -587,7 +587,7 @@ checkPossibleTermination _ _ = return ()
|
||||||
|
|
||||||
readNormalWordPart end = do
|
readNormalWordPart end = do
|
||||||
checkForParenthesis
|
checkForParenthesis
|
||||||
readSingleQuoted <|> readDoubleQuoted <|> readGlob <|> readDollar <|> readBraced <|> readBackTicked <|> readProcSub <|> (readNormalLiteral end)
|
readSingleQuoted <|> readDoubleQuoted <|> readGlob <|> readNormalDollar <|> readBraced <|> readBackTicked <|> readProcSub <|> (readNormalLiteral end)
|
||||||
where
|
where
|
||||||
checkForParenthesis = do
|
checkForParenthesis = do
|
||||||
return () `attempting` do
|
return () `attempting` do
|
||||||
|
@ -606,7 +606,7 @@ readDollarBracedWord = do
|
||||||
list <- many readDollarBracedPart
|
list <- many readDollarBracedPart
|
||||||
return $ T_NormalWord id list
|
return $ T_NormalWord id list
|
||||||
|
|
||||||
readDollarBracedPart = readSingleQuoted <|> readDoubleQuoted <|> readExtglob <|> readDollar <|> readBackTicked <|> readDollarBracedLiteral
|
readDollarBracedPart = readSingleQuoted <|> readDoubleQuoted <|> readExtglob <|> readNormalDollar <|> readBackTicked <|> readDollarBracedLiteral
|
||||||
|
|
||||||
readDollarBracedLiteral = do
|
readDollarBracedLiteral = do
|
||||||
id <- getNextId
|
id <- getNextId
|
||||||
|
@ -670,7 +670,7 @@ readDoubleQuoted = called "double quoted string" $ do
|
||||||
doubleQuote <?> "end of double quoted string"
|
doubleQuote <?> "end of double quoted string"
|
||||||
return $ T_DoubleQuoted id x
|
return $ T_DoubleQuoted id x
|
||||||
|
|
||||||
doubleQuotedPart = readDoubleLiteral <|> readDollar <|> readBackTicked
|
doubleQuotedPart = readDoubleLiteral <|> readDoubleQuotedDollar <|> readBackTicked
|
||||||
|
|
||||||
readDoubleQuotedLiteral = do
|
readDoubleQuotedLiteral = do
|
||||||
doubleQuote
|
doubleQuote
|
||||||
|
@ -817,8 +817,9 @@ readBraced = try $ do
|
||||||
char '}'
|
char '}'
|
||||||
return $ T_BraceExpansion id $ concat str
|
return $ T_BraceExpansion id $ concat str
|
||||||
|
|
||||||
readDollar = readDollarExpression <|> readDollarLonely
|
readNormalDollar = readDollarExpression <|> readDollarLonely <|> readDollarDoubleQuote
|
||||||
readDollarExpression = readDollarArithmetic <|> readDollarBraced <|> readDollarExpansion <|> readDollarVariable <|> readDollarSingleQuote <|> readDollarDoubleQuote
|
readDoubleQuotedDollar = readDollarExpression <|> readDollarLonely
|
||||||
|
readDollarExpression = readDollarArithmetic <|> readDollarBraced <|> readDollarExpansion <|> readDollarVariable <|> readDollarSingleQuote
|
||||||
|
|
||||||
prop_readDollarSingleQuote = isOk readDollarSingleQuote "$'foo\\\'lol'"
|
prop_readDollarSingleQuote = isOk readDollarSingleQuote "$'foo\\\'lol'"
|
||||||
readDollarSingleQuote = called "$'..' expression" $ do
|
readDollarSingleQuote = called "$'..' expression" $ do
|
||||||
|
@ -908,9 +909,10 @@ readVariableName = do
|
||||||
|
|
||||||
readDollarLonely = do
|
readDollarLonely = do
|
||||||
id <- getNextId
|
id <- getNextId
|
||||||
|
pos <- getPosition
|
||||||
char '$'
|
char '$'
|
||||||
n <- lookAhead (anyChar <|> (eof >> return '_'))
|
n <- lookAhead (anyChar <|> (eof >> return '_'))
|
||||||
when (n /= '\'') $ parseNote StyleC "$ is not used specially and should therefore be escaped."
|
when (n /= '\'') $ parseNoteAt pos StyleC "$ is not used specially and should therefore be escaped."
|
||||||
return $ T_Literal id "$"
|
return $ T_Literal id "$"
|
||||||
|
|
||||||
prop_readHereDoc = isOk readHereDoc "<< foo\nlol\ncow\nfoo"
|
prop_readHereDoc = isOk readHereDoc "<< foo\nlol\ncow\nfoo"
|
||||||
|
@ -1399,7 +1401,7 @@ readAssignmentWord = try $ do
|
||||||
pos <- getPosition
|
pos <- getPosition
|
||||||
optional (char '$' >> parseNote ErrorC "Don't use $ on the left side of assignments.")
|
optional (char '$' >> parseNote ErrorC "Don't use $ on the left side of assignments.")
|
||||||
variable <- readVariableName
|
variable <- readVariableName
|
||||||
optional (readDollar >> parseNoteAt pos ErrorC
|
optional (readNormalDollar >> parseNoteAt pos ErrorC
|
||||||
"For indirection, use (associative) arrays or 'read \"var$n\" <<< \"value\"'")
|
"For indirection, use (associative) arrays or 'read \"var$n\" <<< \"value\"'")
|
||||||
optional readArrayIndex -- Throws away the index. Fixme?
|
optional readArrayIndex -- Throws away the index. Fixme?
|
||||||
space <- spacing
|
space <- spacing
|
||||||
|
|
Loading…
Reference in New Issue