Capture original source for literals
ClosedPublic

Authored by alanz on Nov 1 2014, 12:54 PM.

Details

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

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

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
alanz updated this revision to Diff 1180.Nov 1 2014, 12:54 PM
alanz retitled this revision from to Capture original source for literals.
alanz updated this object.
alanz edited the test plan for this revision. (Show Details)
alanz added reviewers: austin, simonpj.
alanz updated the Trac tickets for this revision.
alanz updated this object.Nov 1 2014, 3:12 PM
alanz edited edge metadata.
alanz updated this object.
alanz updated this object.Nov 1 2014, 3:14 PM
alanz updated this object.Nov 5 2014, 8:58 AM
alanz added a parent revision: D438: Add API Annotations.
alanz updated this revision to Diff 1264.Nov 5 2014, 9:00 AM
alanz updated this object.
  • Merge branch 'wip/annotations-literals' into wip/ast-annotations-all
  • fix test for no longer broken comments
alanz updated this revision to Diff 1265.Nov 5 2014, 9:04 AM

Capture against D438

alanz updated this revision to Diff 1267.Nov 5 2014, 9:11 AM
  • Merge branch 'wip/annotations-literals' into wip/ast-annotations-all
  • fix test for no longer broken comments
simonpj accepted this revision.Nov 6 2014, 8:45 AM
simonpj edited edge metadata.

I'm happy, assuming you add the Notes I mention.

Thanks for doing this

SImon

compiler/hsSyn/HsLit.lhs
47–51

Please, I beg you, DOCUMENT this String field. Write a Note explaining why it is needed, preferably including an example of each kind (HsString, HsStringPrim, HsIntPrim, etc) showing why it matters.

The refer to the Note from the data type declaration.

compiler/parser/Lexer.x
642–644

Exactly the same comment here. You can just refer to the same Note if you like. But I beg you to make sure that anyone looking at the data type declaration will be in no doubt what the String fields are.

alanz updated this revision to Diff 1378.Nov 10 2014, 10:34 AM
alanz edited edge metadata.

rebased against master

alanz updated this revision to Diff 1381.Nov 10 2014, 11:54 AM
  • Provide documentation, including motivation.
alanz updated this revision to Diff 1382.Nov 10 2014, 12:20 PM
  • More documentation
alanz updated this revision to Diff 1518.Nov 18 2014, 3:53 PM

Rebase

austin accepted this revision.Nov 18 2014, 9:51 PM
austin edited edge metadata.

LGTM!

This revision is now accepted and ready to land.Nov 18 2014, 9:51 PM
alanz updated this revision to Diff 1640.Nov 21 2014, 12:13 PM
alanz edited edge metadata.

Rebase

alanz updated this revision to Diff 1641.Nov 21 2014, 12:47 PM
This revision was automatically updated to reflect the committed changes.