提交 5794f3d3 编写于 作者: V Vidar Holen

Fixed parsing of "test$"

上级 092073d0
...@@ -325,7 +325,7 @@ readConditionContents single = do ...@@ -325,7 +325,7 @@ readConditionContents single = do
-- Currently a bit of a hack since parsing rules are obscure -- Currently a bit of a hack since parsing rules are obscure
regexOperatorAhead = (lookAhead $ do regexOperatorAhead = (lookAhead $ do
try (string "=~") <|> try (string "~=") try (string "=~") <|> try (string "~=")
return True) return True)
<|> return False <|> return False
readRegex = called "regex" $ do readRegex = called "regex" $ do
id <- getNextId id <- getNextId
...@@ -407,7 +407,7 @@ readArithmeticContents = ...@@ -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 () ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册