Changes between Version 2 and Version 3 of ImplementingTreesThatGrow/IdeSupport


Ignore:
Timestamp:
May 10, 2018 9:23:52 PM (19 months ago)
Author:
alanz
Comment:

Change the name of the Parsed subphase to reflect that Api Annotations are kept or not.

Legend:

Unmodified
Added
Removed
Modified
  • ImplementingTreesThatGrow/IdeSupport

    v2 v3  
    1818The existing API Annotations are only kept if requested, as they impose a space penalty which need not be paid under all circumstances, especially when simply compiling code to generate a library / exe.
    1919
    20 A way to avoid this penalty, and to allow the additional information stored to grow relatively freely without having to worry too much about optimising the straight compilation process, is to have two variants of the AST, one for the straight (batch) compilation, and one for the interactive one.
     20A way to avoid this penalty, and to allow the additional information stored to grow relatively freely without having to worry too much about optimising the straight compilation process, is to have two variants of the AST, one for compiling with Api Annotations, one for without, as selected by using the `Opt_KeepRawTokenStream` dynamic flag, as used at present.
    2121
    2222This can be achieved by making use of the mechanics listed below. If it turns out that the penalty is moderate, and the additional complexity of having two variants is not worth it, this step need not be taken.
     
    3636data Pass = Parsed Process | Renamed | Typechecked
    3737
    38 data Process = Batch | Interactive
     38data Process = WithApiAnnotations | WithoutApiAnnotations
    3939
    40 type GhcPs   = GhcPass ('Parsed 'Batch)
    41 type GhcPsI  = GhcPass ('Parsed 'Interactive)
     40type GhcPs   = GhcPass ('Parsed 'WithoutApiAnnotations)
     41type GhcPsI  = GhcPass ('Parsed 'WithApiAnnotations)
    4242}}}
    4343
    44 So the current `GhcPs` synonym would still indicate the (normal) batch compilation process, and the new one `GhcPsI` reflects the compiler invoked in interactive mode.
     44So the current `GhcPs` synonym would still indicate the (normal) batch compilation process without Api Annotations, and the new one `GhcPsI` reflects the compiler invoked to generate the Api Annotations.
    4545
    4646Since the key feature of Trees that Grow is that different extensions to the AST can be defined based on the index type used, it means that a set of extension types capturing the requirements for the `ghc-exactprint` capable Api Annotations can be defined.
    4747
    48 This means the relevant information is stored directly in the AST, making modification of the AST while preserving layout and comments by tooling much simpler.
     48This means the relevant information is stored directly in the AST, making modification of the AST while preserving layout and comments by tooling much simpler.
     49
     50There would still be a single parser definition in `Parser.y`, which would make use of functions to add the additional info to the generated source tree, which would be NOPs if the information was not being kept. This is similar to what happens at present with the Api Annotations.
    4951
    5052== Phasing ==