caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] menhir types cannot be open polymorphic variant
@ 2014-02-13 20:55 Ashish Agarwal
  2014-02-13 22:06 ` Gabriel Scherer
  0 siblings, 1 reply; 4+ messages in thread
From: Ashish Agarwal @ 2014-02-13 20:55 UTC (permalink / raw)
  To: Caml List

[-- Attachment #1: Type: text/plain, Size: 288 bytes --]

$ cat parser.mly
%token INT
%start <[> `Got_int]> main
%%
main: INT {`Got_int}

$ menhir parser.mly
File "parser.mly", line 2, characters 11-11:
Error: unexpected character(s).

If I make the type exact [`Got_int], it works fine. Is there any way to get
around this? I need an open type.

[-- Attachment #2: Type: text/html, Size: 478 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] menhir types cannot be open polymorphic variant
  2014-02-13 20:55 [Caml-list] menhir types cannot be open polymorphic variant Ashish Agarwal
@ 2014-02-13 22:06 ` Gabriel Scherer
  2014-02-14 12:20   ` Francois Pottier
  0 siblings, 1 reply; 4+ messages in thread
From: Gabriel Scherer @ 2014-02-13 22:06 UTC (permalink / raw)
  To: Ashish Agarwal; +Cc: Caml List

Workaround 1: in another file (this won't work in the menhir header)

  type 'a start = [> `Got_int ] as 'a

then use ('a start) instead of [> `Got_int ].

Workaround 2: apply the patch below to the most recent menhir sources

diff -ru menhir-20130911.old/src/lexer.mll menhir-20130911.new/src/lexer.mll
--- menhir-20130911.old/src/lexer.mll    2013-09-11 08:58:39.000000000 +0200
+++ menhir-20130911.new/src/lexer.mll    2014-02-13 23:05:19.240180035 +0100
@@ -344,7 +344,7 @@
    of O'Caml variant types, but we ignore that possibility for the moment. *)

 and ocamltype openingpos = parse
-| "->"
+| "->" | "[>"
     { ocamltype openingpos lexbuf }
 | '>'
     { OCAMLTYPE (Stretch.Declared (mk_stretch true openingpos
(lexeme_start_p lexbuf) [])) }

On Thu, Feb 13, 2014 at 9:55 PM, Ashish Agarwal <agarwal1975@gmail.com> wrote:
> $ cat parser.mly
> %token INT
> %start <[> `Got_int]> main
> %%
> main: INT {`Got_int}
>
> $ menhir parser.mly
> File "parser.mly", line 2, characters 11-11:
> Error: unexpected character(s).
>
> If I make the type exact [`Got_int], it works fine. Is there any way to get
> around this? I need an open type.
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] menhir types cannot be open polymorphic variant
  2014-02-13 22:06 ` Gabriel Scherer
@ 2014-02-14 12:20   ` Francois Pottier
  2014-02-14 13:30     ` Ashish Agarwal
  0 siblings, 1 reply; 4+ messages in thread
From: Francois Pottier @ 2014-02-14 12:20 UTC (permalink / raw)
  To: Gabriel Scherer; +Cc: Ashish Agarwal, Caml List


Thanks for reporting this and thanks to Gabriel for the patch suggestion.
This will be fixed in the next release of Menhir.

-- 
François Pottier
Francois.Pottier@inria.fr
http://gallium.inria.fr/~fpottier/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] menhir types cannot be open polymorphic variant
  2014-02-14 12:20   ` Francois Pottier
@ 2014-02-14 13:30     ` Ashish Agarwal
  0 siblings, 0 replies; 4+ messages in thread
From: Ashish Agarwal @ 2014-02-14 13:30 UTC (permalink / raw)
  To: Francois.Pottier; +Cc: Gabriel Scherer, Caml List

[-- Attachment #1: Type: text/plain, Size: 343 bytes --]

Thanks Gabriel!


On Fri, Feb 14, 2014 at 7:20 AM, Francois Pottier <Francois.Pottier@inria.fr
> wrote:

>
> Thanks for reporting this and thanks to Gabriel for the patch suggestion.
> This will be fixed in the next release of Menhir.
>
> --
> François Pottier
> Francois.Pottier@inria.fr
> http://gallium.inria.fr/~fpottier/
>

[-- Attachment #2: Type: text/html, Size: 827 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-14 13:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-13 20:55 [Caml-list] menhir types cannot be open polymorphic variant Ashish Agarwal
2014-02-13 22:06 ` Gabriel Scherer
2014-02-14 12:20   ` Francois Pottier
2014-02-14 13:30     ` Ashish Agarwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).