Capture original source for literals
authorAlan Zimmerman <alan.zimm@gmail.com>
Fri, 21 Nov 2014 19:24:30 +0000 (13:24 -0600)
committerAustin Seipp <austin@well-typed.com>
Fri, 21 Nov 2014 19:24:31 +0000 (13:24 -0600)
commitc0ad5bc03e02ce0d7d545599e4b1a68a6f727f2b
treee1033354c6514a3474d5c5f3f80aa3eaaf33b505
parenta97f90cecb6351a6db5a62c1551fcbf079b0acdd
Capture original source for literals

Summary:
Make HsLit and OverLitVal have original source strings, for source to
source conversions using the GHC API

This is part of the ongoing AST Annotations work, as captured in
https://ghc.haskell.org/trac/ghc/wiki/GhcAstAnnotations and
https://ghc.haskell.org/trac/ghc/ticket/9628#comment:28

The motivations for the literals is as follows

```lang=haskell
x,y :: Int
x = 0003
y = 0x04

s :: String
s = "\x20"

c :: Char
c = '\x20'

d :: Double
d = 0.00

blah = x
  where
    charH = '\x41'#
    intH = 0004#
    wordH = 005##
    floatH = 3.20#
    doubleH = 04.16##
    x = 1
```

Test Plan: ./sh validate

Reviewers: simonpj, austin

Reviewed By: simonpj, austin

Subscribers: thomie, goldfire, carter, simonmar

Differential Revision: https://phabricator.haskell.org/D412

GHC Trac Issues: #9628
31 files changed:
compiler/deSugar/Check.lhs
compiler/deSugar/DsMeta.hs
compiler/deSugar/MatchLit.lhs
compiler/ghc.mk
compiler/hsSyn/Convert.lhs
compiler/hsSyn/HsExpr.lhs
compiler/hsSyn/HsLit.lhs
compiler/hsSyn/HsPat.lhs
compiler/hsSyn/HsUtils.lhs
compiler/parser/Lexer.x
compiler/parser/Parser.y
compiler/parser/RdrHsSyn.hs
compiler/rename/RnExpr.lhs
compiler/rename/RnPat.lhs
compiler/typecheck/Inst.lhs
compiler/typecheck/TcBinds.lhs
compiler/typecheck/TcExpr.lhs
compiler/typecheck/TcGenDeriv.lhs
compiler/typecheck/TcHsSyn.lhs
compiler/typecheck/TcInstDcls.lhs
compiler/typecheck/TcRnDriver.lhs
compiler/typecheck/TcSplice.lhs
compiler/typecheck/TcTyClsDecls.lhs
testsuite/tests/ghc-api/annotations-literals/.gitignore [new file with mode: 0644]
testsuite/tests/ghc-api/annotations-literals/LiteralsTest.hs [new file with mode: 0644]
testsuite/tests/ghc-api/annotations-literals/Makefile [new file with mode: 0644]
testsuite/tests/ghc-api/annotations-literals/all.T [new file with mode: 0644]
testsuite/tests/ghc-api/annotations-literals/literals.hs [new file with mode: 0644]
testsuite/tests/ghc-api/annotations-literals/literals.stdout [new file with mode: 0644]
testsuite/tests/ghc-api/annotations-literals/parsed.hs [new file with mode: 0644]
testsuite/tests/ghc-api/annotations-literals/parsed.stdout [new file with mode: 0644]