Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006221OCamlCamlp4public2013-11-02 23:552014-02-19 16:38
Reporterkosik 
Assigned To 
PrioritylowSeverityminorReproducibilityalways
StatusnewResolutionopen 
PlatformOSOS Version
Product Version3.12.1 
Target VersionFixed in Version 
Summary0006221: Spurious (?) camlp4 error
DescriptionBy looking at:

   http://brion.inria.fr/gallium/index.php/Abstract_Syntax_Tree#Types [^]

there is a line:

     <:ctyp< t : t >> ....... Field declaration
                        ........ TyCol of Loc.t and ctyp and ctyp

so it seems that it should also be somehow posible to get a quote for "field declaration", i.e.:

   <:ctyp<foo1:bar1>>


However, if I try that, I get an error:

  While expanding quotation "ctyp" in a position of "expr":
    Parse error: "->" expected after [ctyp level star] (in [ctyp]

That might not be the expected camlp4 behavior.
Instead, it should expand that quotation to something like:

  Ast.TyCol (_loc,
             (Ast.TyId (_loc, (Ast.IdLid (_loc, "foo1")))),
             (Ast.TyId (_loc, (Ast.IdLid (_loc, "bar1")))))
Tagspatch
Attached Filespatch file icon field_parsing.patch [^] (813 bytes) 2013-11-04 10:19 [Show Content]

- Relationships

-  Notes
(0010563)
hongboz (developer)
2013-11-03 01:29

I think the documentation may be incorrect. where do you expect 'foo1:bar' appear?
If it appears in record, then it should be recognized as type representation, not type expression.
(0010564)
kosik (reporter)
2013-11-03 09:36

Hi,

This suggestion:

  <:ctyp< t : t >>

I have found here:

  http://brion.inria.fr/gallium/index.php/Abstract_Syntax_Tree#Types [^]

It appears on the line that contains

  TyCol

.
(0010568)
yallop (developer)
2013-11-04 10:19

It looks like camlp4 is committing to parsing x:y as a labeled argument rather than a record field as soon as it's seen the colon. I've attached a patch that changes the parser so that it waits until it's seen the function arrow before committing.

Examples:
   $ cat labeled_arg.ml
   let _ = <:ctyp< x:y -> int >>

   $ cat record_field.ml
   let _ = <:ctyp< x:y >>

Without the patch:

   $ camlp4of labeled_arg.ml
   Ast.TyArr (_loc,
     Ast.TyLab (_loc, "x", Ast.TyId (_loc, Ast.IdLid (_loc, "y"))),
     Ast.TyId (_loc, Ast.IdLid (_loc, "int")))

   $ camlp4of record_field.ml
   File "record_field.ml", line 1, characters 20-21:
   While expanding quotation "ctyp" in a position of "expr":
     Parse error: [ctyp level star] expected after [lident_colon] (in [ctyp])

With the patch:

   $ camlp4of labeled_arg.ml
   Ast.TyArr (_loc,
     (Ast.TyLab (_loc, "x", (Ast.TyId (_loc, (Ast.IdLid (_loc, "y")))))),
     (Ast.TyId (_loc, (Ast.IdLid (_loc, "int")))))

   $ camlp4of record_field.ml
   Ast.TyCol (_loc, (Ast.TyId (_loc, (Ast.IdLid (_loc, "x")))),
     (Ast.TyId (_loc, (Ast.IdLid (_loc, "y")))))

- Issue History
Date Modified Username Field Change
2013-11-02 23:55 kosik New Issue
2013-11-03 01:29 hongboz Note Added: 0010563
2013-11-03 09:36 kosik Note Added: 0010564
2013-11-04 10:19 yallop Note Added: 0010568
2013-11-04 10:19 yallop File Added: field_parsing.patch
2014-02-19 16:38 doligez Tag Attached: patch


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker