Add ^@![]/ to allowed function characters (#909)

This commit is contained in:
Vidar Holen 2017-09-09 15:34:08 -07:00
parent ccc037d458
commit 895ba31337
1 changed files with 7 additions and 5 deletions

View File

@ -62,7 +62,10 @@ singleQuote = char '\''
doubleQuote = char '"' doubleQuote = char '"'
variableStart = upper <|> lower <|> oneOf "_" variableStart = upper <|> lower <|> oneOf "_"
variableChars = upper <|> lower <|> digit <|> oneOf "_" variableChars = upper <|> lower <|> digit <|> oneOf "_"
functionChars = variableChars <|> oneOf ":+-.?" -- Chars to allow in function names
functionChars = variableChars <|> oneOf ":+?-./^"
-- Chars to allow in functions using the 'function' keyword
extendedFunctionChars = functionChars <|> oneOf "[]*=!"
specialVariable = oneOf "@*#?-$!" specialVariable = oneOf "@*#?-$!"
paramSubSpecialChars = oneOf "/:+-=%" paramSubSpecialChars = oneOf "/:+-=%"
quotableChars = "|&;<>()\\ '\t\n\r\xA0" ++ doubleQuotableChars quotableChars = "|&;<>()\\ '\t\n\r\xA0" ++ doubleQuotableChars
@ -2289,6 +2292,7 @@ prop_readFunctionDefinition8 = isOk readFunctionDefinition "foo() (ls)"
prop_readFunctionDefinition9 = isOk readFunctionDefinition "function foo { true; }" prop_readFunctionDefinition9 = isOk readFunctionDefinition "function foo { true; }"
prop_readFunctionDefinition10= isOk readFunctionDefinition "function foo () { true; }" prop_readFunctionDefinition10= isOk readFunctionDefinition "function foo () { true; }"
prop_readFunctionDefinition11= isWarning readFunctionDefinition "function foo{\ntrue\n}" prop_readFunctionDefinition11= isWarning readFunctionDefinition "function foo{\ntrue\n}"
prop_readFunctionDefinition12= isOk readFunctionDefinition "function []!() { true; }"
readFunctionDefinition = called "function" $ do readFunctionDefinition = called "function" $ do
functionSignature <- try readFunctionSignature functionSignature <- try readFunctionSignature
allspacing allspacing
@ -2305,7 +2309,7 @@ readFunctionDefinition = called "function" $ do
string "function" string "function"
whitespace whitespace
spacing spacing
name <- readFunctionName name <- many1 extendedFunctionChars
spaces <- spacing spaces <- spacing
hasParens <- wasIncluded readParens hasParens <- wasIncluded readParens
when (not hasParens && null spaces) $ when (not hasParens && null spaces) $
@ -2315,7 +2319,7 @@ readFunctionDefinition = called "function" $ do
readWithoutFunction = try $ do readWithoutFunction = try $ do
id <- getNextId id <- getNextId
name <- readFunctionName name <- many1 functionChars
guard $ name /= "time" -- Interfers with time ( foo ) guard $ name /= "time" -- Interfers with time ( foo )
spacing spacing
readParens readParens
@ -2330,8 +2334,6 @@ readFunctionDefinition = called "function" $ do
g_Rparen g_Rparen
return () return ()
readFunctionName = many1 functionChars
prop_readCoProc1 = isOk readCoProc "coproc foo { echo bar; }" prop_readCoProc1 = isOk readCoProc "coproc foo { echo bar; }"
prop_readCoProc2 = isOk readCoProc "coproc { echo bar; }" prop_readCoProc2 = isOk readCoProc "coproc { echo bar; }"
prop_readCoProc3 = isOk readCoProc "coproc echo bar" prop_readCoProc3 = isOk readCoProc "coproc echo bar"