[Git][ghc/ghc][wip/az/exactprint] Proof of Concept implementation of in-tree API Annotations

Alan Zimmerman gitlab at gitlab.haskell.org
Fri Oct 9 13:38:53 UTC 2020



Alan Zimmerman pushed to branch wip/az/exactprint at Glasgow Haskell Compiler / GHC


Commits:
ccd9aa3b by Alan Zimmerman at 2020-10-09T14:38:15+01:00
Proof of Concept implementation of in-tree API Annotations

This MR introduces a possible machinery to introduce API Annotations
into the TTG extension points.

It is intended to be a concrete example for discussion.

It still needs to process comments.

----

Work in progress, adding more TTG extensions for annotations.

And fixing ppr round-trip tests by being able to blank out in-tree
annotations, as done with SrcSpans.

This is needed for the case of

  class Foo a where

for which current ppr does not print the "where".

Rename AA to AddApiAnn and AA to AddAnn

Add XConPatIn and XConPatOut

Rebase

----

First pass at bringing in LocatedA for API anns in locations

Treatment of ECP in parsing is provisional at this stage, leads to some
horribly stuff in Parser.y and RdrHsSyn.

It is an extensive but not invasive change. I think (AZ).

Locally it reports some parsing tests using less memory.

Add ApiAnns to the HsExpr data structure.

rebase.

Change HsMatchContext and HsStmtContext to use an id, not a GhcPass
parameter.

Add ApiAnns to Hs/Types

Rebase

Rebased 2020-03-25

WIP on in-tree annotations

Includes updating HsModule

Imports

LocateA ImportDecl so we can hang AnnSemi off it

A whole bunch of stuff more

InjectivityAnn and FamEqn now have annotations in them

Add annotations to context srcspan

----

In-tree annotations: LHsDecl and LHsBind LocatedA

----

WIP on in-tree annotations

----

in-tree annotations: LHsType is now LocatedA

----

FunDeps is now also a HS data type

----

WIP.  Added LocatedA to Pat, Expr, Decl

And worked some more through Parser.y

----

LStmt now Located

----

Finished working through Parser.y, tests seem ok

failures relate to annotations.

Adding test infrastructure for check-exact

Like check-ppr, but checking for an exact reproduction of the parsed
source file.

Starting to work on actual exact printer

Bring in ApiAnnName

As an alternative for LocatedA, to be used for names only.

Carrying extra name adornments, such as locations of backticks,
parens, etc.

Working on changing ApiAnnName to accurately reflect actual usage

Get rid of AnnApiName in favour of LocatedN

Working on check-exact. Making progress

Working on the ghc-exact bit

Progress, can reproduce the first Test.hs file.

Move API Annotations out of the extensions to annotations

Remove LHsLocalBinds

Fix up after rebasing to bring in XRec

Main thing is to make

    type instance XRec (GhcPass p) a = GenLocated (Anno a) a

    type family Anno a = b

But this has massive implications.

- - - - -


20 changed files:

- compiler/GHC.hs
- compiler/GHC/Data/BooleanFormula.hs
- compiler/GHC/Data/OrdList.hs
- compiler/GHC/Driver/Backpack.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Ppr.hs
- compiler/GHC/Driver/Types.hs
- compiler/GHC/Hs.hs
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Dump.hs
- + compiler/GHC/Hs/Exact.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Expr.hs-boot
- compiler/GHC/Hs/Extension.hs
- compiler/GHC/Hs/ImpExp.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Pat.hs
- compiler/GHC/Hs/Pat.hs-boot
- compiler/GHC/Hs/Stats.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ccd9aa3ba98a6a376492852e77911243a470b224

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ccd9aa3ba98a6a376492852e77911243a470b224
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20201009/ddf5004c/attachment.html>


More information about the ghc-commits mailing list