Save string read by T_ParamSubSpecialChar

This commit is contained in:
Vidar Holen 2016-12-03 10:19:14 -08:00
parent 0897ab7092
commit b4fb439191
3 changed files with 5 additions and 4 deletions

View File

@ -111,7 +111,7 @@ data Token =
| T_NormalWord Id [Token]
| T_OR_IF Id
| T_OrIf Id (Token) (Token)
| T_ParamSubSpecialChar Id -- e.g. '%' in ${foo%bar} or '/' in ${foo/bar/baz}
| T_ParamSubSpecialChar Id String -- e.g. '%' in ${foo%bar} or '/' in ${foo/bar/baz}
| T_Pipeline Id [Token] [Token] -- [Pipe separators] [Commands]
| T_ProcSub Id String [Token]
| T_Rbrace Id
@ -320,7 +320,7 @@ getId t = case t of
T_DollarBraced id _ -> id
T_DollarArithmetic id _ -> id
T_BraceExpansion id _ -> id
T_ParamSubSpecialChar id -> id
T_ParamSubSpecialChar id _ -> id
T_DollarBraceCommandExpansion id _ -> id
T_IoFile id _ _ -> id
T_IoDuplicate id _ _ -> id

View File

@ -86,6 +86,7 @@ oversimplify token =
(T_Glob _ s) -> [s]
(T_Pipeline _ _ [x]) -> oversimplify x
(T_Literal _ x) -> [x]
(T_ParamSubSpecialChar _ x) -> [x]
(T_SimpleCommand _ vars words) -> concatMap oversimplify words
(T_Redirecting _ _ foo) -> oversimplify foo
(T_DollarSingleQuoted _ s) -> [s]
@ -188,6 +189,7 @@ getLiteralStringExt more = g
g (TA_Expansion _ l) = allInList l
g (T_SingleQuoted _ s) = return s
g (T_Literal _ s) = return s
g (T_ParamSubSpecialChar _ s) = return s
g x = more x
-- Is this token a string literal?

View File

@ -1015,8 +1015,7 @@ readDollarBracedLiteral = do
readParamSubSpecialChar = do
id <- getNextId
many1 paramSubSpecialChars
return $ T_ParamSubSpecialChar id
T_ParamSubSpecialChar id <$> many1 paramSubSpecialChars
prop_readProcSub1 = isOk readProcSub "<(echo test | wc -l)"
prop_readProcSub2 = isOk readProcSub "<( if true; then true; fi )"