[wg-camlp4] Changes to the parsetree

Hongbo Zhang hongboz at seas.upenn.edu
Wed Apr 10 20:32:36 BST 2013


On Wed, Apr 10, 2013 at 3:21 PM, Leo White <lpw25 at cam.ac.uk> wrote:

> > I think we should keep the Parsetree type as close as possible (at
> reasonable costs) to the set of ASTs that can be
> > produced by the parser. This will reduce the risk of generating
> Parsetree fragments which cannot be pretty-printed (as
> > source code) faithfully.
>
> In general I agree with this, however there are always going to be
> places where the Parsetree accepts more values than the parser.
>
Actually, that's the value of polymorphic variants,  you can make the type
definitions
as precise as the parser while not complicate the type definitions too much

>
> > So, if we want to move from "string loc list" to "core_type list" (which
> will give attributes for free on parameters),
> > we should accept arbitrary types in the parser and fail in the
> type-checker.  (There is no real drawback for the
> > end-user.)  The problem is that this  introduces conflicts in the
> grammar.  The simpler way I've found to address them
> > without changing the parser too much is to add the variance prefixes (+
> and -) as new constructors in core_type (with
> > corresponding grammar rules), but this is not very nice.
>
> Adding variance constructors to core_type seems like it will create more
> problems than it solves.  I think it would be simpler to have type
> parameters only accept Ptyp_any, Ptyp_var and Ptyp_extension.
> _______________________________________________
> wg-camlp4 mailing list
> wg-camlp4 at lists.ocaml.org
> http://lists.ocaml.org/listinfo/wg-camlp4
>



-- 
-- Regards, Hongbo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/wg-camlp4/attachments/20130410/d8cc3d55/attachment.html>


More information about the wg-camlp4 mailing list