Skip to content
Snippets Groups Projects
Commit 81c379da authored by Mateusz Kowalczyk's avatar Mateusz Kowalczyk
Browse files

Parse identifiers with ^ and ⋆ in them.

Fixes #298.
parent 99e37051
No related branches found
No related tags found
No related merge requests found
Changes in version 2.14.3
* Fix parsing of identifiers with ^ or ⋆ in them (#298)
Changes in version 2.14.2 Changes in version 2.14.2
* Always drop --split-objs GHC flag for performance reasons (#292) * Always drop --split-objs GHC flag for performance reasons (#292)
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
><head
><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
/><title
>Bug298</title
><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
/><script src="haddock-util.js" type="text/javascript"
></script
><script type="text/javascript"
>//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Bug298.html");};
//]]>
</script
></head
><body
><div id="package-header"
><ul class="links" id="page-menu"
><li
><a href=""
>Contents</a
></li
><li
><a href=""
>Index</a
></li
></ul
><p class="caption empty"
>&nbsp;</p
></div
><div id="content"
><div id="module-header"
><table class="info"
><tr
><th
>Safe Haskell</th
><td
>Safe-Inferred</td
></tr
></table
><p class="caption"
>Bug298</p
></div
><div id="synopsis"
><p id="control.syn" class="caption expander" onclick="toggleSection('syn')"
>Synopsis</p
><ul id="section.syn" class="hide" onclick="toggleSection('syn')"
><li class="src short"
><a href=""
>(&lt;^&gt;)</a
> :: (a -&gt; a) -&gt; a -&gt; a</li
><li class="src short"
><a href=""
>(&lt;^)</a
> :: a -&gt; a -&gt; a</li
><li class="src short"
><a href=""
>(^&gt;)</a
> :: a -&gt; a -&gt; a</li
><li class="src short"
><a href=""
>(&#8902;^)</a
> :: a -&gt; a -&gt; a</li
><li class="src short"
><a href=""
>f</a
> :: ()</li
></ul
></div
><div id="interface"
><h1
>Documentation</h1
><div class="top"
><p class="src"
><a name="v:-60--94--62-" class="def"
>(&lt;^&gt;)</a
> :: (a -&gt; a) -&gt; a -&gt; a</p
></div
><div class="top"
><p class="src"
><a name="v:-60--94-" class="def"
>(&lt;^)</a
> :: a -&gt; a -&gt; a</p
></div
><div class="top"
><p class="src"
><a name="v:-94--62-" class="def"
>(^&gt;)</a
> :: a -&gt; a -&gt; a</p
></div
><div class="top"
><p class="src"
><a name="v:-8902--94-" class="def"
>(&#8902;^)</a
> :: a -&gt; a -&gt; a</p
></div
><div class="top"
><p class="src"
><a name="v:f" class="def"
>f</a
> :: ()</p
><div class="doc"
><p
>Links to <code
><a href=""
>&lt;^&gt;</a
></code
> and <code
><a href=""
>^&gt;</a
></code
>, <code
><a href=""
>&lt;^</a
></code
> and <code
><a href=""
>&#8902;^</a
></code
>.</p
></div
></div
></div
></div
><div id="footer"
><p
>Produced by <a href=""
>Haddock</a
> version 2.15.0</p
></div
></body
></html
>
-- We introduced a regression in 2.14.x where we don't consider
-- identifiers with ^ as valid. We test that the regression goes away
-- here. It's a silly typo in the parser, really. Same with ★ which is a valid
-- symbol according to the 2010 report.
module Bug298 where
(<^>) :: (a -> a) -> a -> a
x <^> y = x y
(<^) :: a -> a -> a
x <^ y = x
(^>) :: a -> a -> a
x ^> y = y
(^) :: a -> a -> a
x ^ y = y
-- | Links to '<^>' and '^>', '<^' and '⋆^'.
f :: ()
f = ()
...@@ -419,13 +419,21 @@ autoUrl = mkLink <$> url ...@@ -419,13 +419,21 @@ autoUrl = mkLink <$> url
-- characters and does no actual validation itself. -- characters and does no actual validation itself.
parseValid :: Parser String parseValid :: Parser String
parseValid = do parseValid = do
vs <- many' $ satisfy (`elem` "_.!#$%&*+/<=>?@\\|-~:") <|> digit <|> letter_ascii vs' <- many' $ utf8String "⋆" <|> return <$> idChar
let vs = concat vs'
c <- peekChar c <- peekChar
case c of case c of
Just '`' -> return vs Just '`' -> return vs
Just '\'' -> (\x -> vs ++ "'" ++ x) <$> ("'" *> parseValid) Just '\'' -> (\x -> vs ++ "'" ++ x) <$> ("'" *> parseValid)
<|> return vs <|> return vs
_ -> fail "outofvalid" _ -> fail "outofvalid"
where
idChar = satisfy (`elem` "_.!#$%&*+/<=>?@\\|-~:^")
<|> digit <|> letter_ascii
-- | Parses UTF8 strings from ByteString streams.
utf8String :: String -> Parser String
utf8String x = decodeUtf8 <$> string (encodeUtf8 x)
-- | Parses identifiers with help of 'parseValid'. Asks GHC for 'RdrName' from the -- | Parses identifiers with help of 'parseValid'. Asks GHC for 'RdrName' from the
-- string it deems valid. -- string it deems valid.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment