diff options
| author | aarne <aarne@chalmers.se> | 2009-12-17 21:17:46 +0000 |
|---|---|---|
| committer | aarne <aarne@chalmers.se> | 2009-12-17 21:17:46 +0000 |
| commit | a4eb1800a4913121297eb83970718cd3895aa43f (patch) | |
| tree | 9f70bcdf3089eab2cf6dd9bf7f9049555f2996ae /src | |
| parent | 6a130d2e8640727e2481eaba05fd45494bc1d416 (diff) | |
correct capitalization in unlexmixed; unlextext and unlexmixed now remove string literal quotes
Diffstat (limited to 'src')
| -rw-r--r-- | src/compiler/GF/Text/Lexing.hs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/compiler/GF/Text/Lexing.hs b/src/compiler/GF/Text/Lexing.hs index 3300d311e..a5a2c71eb 100644 --- a/src/compiler/GF/Text/Lexing.hs +++ b/src/compiler/GF/Text/Lexing.hs @@ -18,9 +18,9 @@ stringOp name = case name of "words" -> Just $ appLexer words "bind" -> Just $ appUnlexer bindTok "unchars" -> Just $ appUnlexer concat - "unlextext" -> Just $ appUnlexer unlexText + "unlextext" -> Just $ capitInit . appUnlexer (unlexText . unquote) "unlexcode" -> Just $ appUnlexer unlexCode - "unlexmixed" -> Just $ appUnlexer unlexMixed + "unlexmixed" -> Just $ capitInit . appUnlexer (unlexMixed . unquote) "unwords" -> Just $ appUnlexer unwords "to_html" -> Just wrapHTML "to_utf8" -> Just encodeUTF8 @@ -93,17 +93,25 @@ bindTok ws = case ws of [] -> "" unlexText :: [String] -> String -unlexText = cap . unlext where +unlexText = unlext where unlext s = case s of w:[] -> w w:[c]:[] | isPunct c -> w ++ [c] - w:[c]:cs | isMajorPunct c -> w ++ [c] ++ " " ++ cap (unlext cs) + w:[c]:cs | isMajorPunct c -> w ++ [c] ++ " " ++ capitInit (unlext cs) w:[c]:cs | isMinorPunct c -> w ++ [c] ++ " " ++ unlext cs w:ws -> w ++ " " ++ unlext ws _ -> [] - cap s = case s of - c:cs -> toUpper c : cs - _ -> s + +-- capitalize first letter +capitInit s = case s of + c:cs -> toUpper c : cs + _ -> s + +-- unquote each string of form "foo" +unquote = map unq where + unq s = case s of + '"':cs@(_:_) | last cs == '"' -> init cs + _ -> s unlexCode :: [String] -> String unlexCode s = case s of |
