summaryrefslogtreecommitdiff
path: root/utils/genprimopcode
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2016-01-15 00:03:58 +0200
committerAlan Zimmerman <alan.zimm@gmail.com>2016-01-16 15:54:04 +0200
commit3a1babd6243edd96073ed3e3a5fb6e0aaf11350e (patch)
treee578589e61895b392c761daaa2cb14f790fac5d8 /utils/genprimopcode
parent148a50b5f8a9db4c3e2724540c41a7a7a10b3194 (diff)
downloadhaskell-3a1babd6243edd96073ed3e3a5fb6e0aaf11350e.tar.gz
Work SourceText in for all integer literals
Summary: Certain syntactic elements have integers in them, such as fixity specifications, SPECIALISE pragmas and so on. The lexer will accept mult-radix literals, with arbitrary leading zeros in these. Bring in a SourceText field to each affected AST element to capture the original literal text for use with API Annotations. Affected hsSyn elements are ``` -- See note [Pragma source text] data Activation = NeverActive | AlwaysActive | ActiveBefore SourceText PhaseNum -- Active only *strictly before* this phase | ActiveAfter SourceText PhaseNum -- Active in this phase and later deriving( Eq, Data, Typeable ) -- Eq used in comparing rules in HsDecls data Fixity = Fixity SourceText Int FixityDirection -- Note [Pragma source text] deriving (Data, Typeable) ``` and ``` | HsTickPragma -- A pragma introduced tick SourceText -- Note [Pragma source text] in BasicTypes (StringLiteral,(Int,Int),(Int,Int)) -- external span for this tick ((SourceText,SourceText),(SourceText,SourceText)) -- Source text for the four integers used in the span. -- See note [Pragma source text] in BasicTypes (LHsExpr id) ``` Updates haddock submodule Test Plan: ./validate Reviewers: goldfire, bgamari, austin Reviewed By: bgamari Subscribers: thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1781 GHC Trac Issues: #11430
Diffstat (limited to 'utils/genprimopcode')
-rw-r--r--utils/genprimopcode/Main.hs5
-rw-r--r--utils/genprimopcode/Parser.y6
-rw-r--r--utils/genprimopcode/Syntax.hs4
3 files changed, 9 insertions, 6 deletions
diff --git a/utils/genprimopcode/Main.hs b/utils/genprimopcode/Main.hs
index 781317ab11..e6af0f200e 100644
--- a/utils/genprimopcode/Main.hs
+++ b/utils/genprimopcode/Main.hs
@@ -350,7 +350,8 @@ gen_hs_source (Info defaults entries) =
escape = concatMap (\c -> if c `elem` special then '\\':c:[] else c:[])
where special = "/'`\"@<"
- pprFixity (Fixity i d) n = pprFixityDir d ++ " " ++ show i ++ " " ++ n
+ pprFixity (Fixity _ i d) n
+ = pprFixityDir d ++ " " ++ show i ++ " " ++ n
{- Note [Placeholder declarations]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -495,7 +496,7 @@ gen_latex_doc (Info defaults entries)
Nothing -> ""
mk_fixity o = case lookup_attrib "fixity" o of
- Just (OptionFixity (Just (Fixity i d)))
+ Just (OptionFixity (Just (Fixity _ i d)))
-> pprFixityDir d ++ " " ++ show i
_ -> ""
diff --git a/utils/genprimopcode/Parser.y b/utils/genprimopcode/Parser.y
index 6a3c0d0043..51ca9ad6eb 100644
--- a/utils/genprimopcode/Parser.y
+++ b/utils/genprimopcode/Parser.y
@@ -77,9 +77,9 @@ pOption : lowerName '=' false { OptionFalse $1 }
| fixity '=' pInfix { OptionFixity $3 }
pInfix :: { Maybe Fixity }
-pInfix : infix integer { Just $ Fixity $2 InfixN }
- | infixl integer { Just $ Fixity $2 InfixL }
- | infixr integer { Just $ Fixity $2 InfixR }
+pInfix : infix integer { Just $ Fixity (show $2) $2 InfixN }
+ | infixl integer { Just $ Fixity (show $2) $2 InfixL }
+ | infixr integer { Just $ Fixity (show $2) $2 InfixR }
| nothing { Nothing }
diff --git a/utils/genprimopcode/Syntax.hs b/utils/genprimopcode/Syntax.hs
index 68b20adbdd..17c264d44a 100644
--- a/utils/genprimopcode/Syntax.hs
+++ b/utils/genprimopcode/Syntax.hs
@@ -96,7 +96,9 @@ instance Show TyCon where
-- Follow definitions of Fixity and FixityDirection in GHC
-data Fixity = Fixity Int FixityDirection
+-- The String exists so that it matches the SourceText field in
+-- BasicTypes.Fixity
+data Fixity = Fixity String Int FixityDirection
deriving (Eq, Show)
data FixityDirection = InfixN | InfixL | InfixR