From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 25CBE7FA5C for ; Sat, 14 May 2016 21:51:10 +0200 (CEST) IronPort-PHdr: 9a23:YU8lgBAyEXVjN0rx5/qiUyQJP3N1i/DPJgcQr6AfoPdwSP7+pcbcNUDSrc9gkEXOFd2CrakU2qyM6Ou5BTZIyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4Ov7yUtaLyZ/nhqbooNaKP18ArQH+SI0xBS3+lR/WuMgSjNkqAYcK4TyNnEF1ff9Lz3hjP1OZkkW0zM6x+Jl+73YY4Kp5pIYTGZn9Kq8xSLgdCDU9L0g04tfqvF/NV1ih/HwZB0MXmR1MChONyxP3Up65mCLg/r572SKdOcTtC7c2VDirqa1iUjfshTcGOT9/+2bS3J8jxJlHqQ6s8kQsi7XfZ5uYYaJz Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=nicolas.ojeda.bar@lexifi.com; spf=None smtp.mailfrom=nicolas.ojeda.bar@lexifi.com; spf=None smtp.helo=postmaster@mx20.yaziba.net Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of nicolas.ojeda.bar@lexifi.com) identity=pra; client-ip=85.233.204.164; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="nicolas.ojeda.bar@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of nicolas.ojeda.bar@lexifi.com) identity=mailfrom; client-ip=85.233.204.164; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="nicolas.ojeda.bar@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mx20.yaziba.net) identity=helo; client-ip=85.233.204.164; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="postmaster@mx20.yaziba.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DZAQCLgDdXkKTM6VVehRCnFoICAYtOhnuHLgc8EAEBAQEBAQEBEQEBAQEJCwkJIS+CLYIuEQRxAQY3AiQSAQUBFicaiA0Eon2CB4ExPjGLO5EUj32CNIJZAQSTMIR3iHaFKI8ZjgMSHoEMAjeBbVWBV4hyAQEB X-IPAS-Result: A0DZAQCLgDdXkKTM6VVehRCnFoICAYtOhnuHLgc8EAEBAQEBAQEBEQEBAQEJCwkJIS+CLYIuEQRxAQY3AiQSAQUBFicaiA0Eon2CB4ExPjGLO5EUj32CNIJZAQSTMIR3iHaFKI8ZjgMSHoEMAjeBbVWBV4hyAQEB X-IronPort-AV: E=Sophos;i="5.24,619,1454972400"; d="scan'208,217";a="177830177" Received: from mx20.yaziba.net ([85.233.204.164]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 14 May 2016 21:51:09 +0200 Received: from mta20.int.yaziba.net (mta20.int.yaziba.net [10.4.20.31]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx20.yaziba.net (mx10.yaziba.net) with ESMTPS id 3B7F61A746A for ; Sat, 14 May 2016 21:51:08 +0200 (CEST) Received: from mta20.int.yaziba.net (localhost [127.0.0.1]) by mta20.int.yaziba.net (Postfix) with ESMTPS id 53B3ACA657 for ; Sat, 14 May 2016 21:51:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mta20.int.yaziba.net (Postfix) with ESMTP id 431B3CA796 for ; Sat, 14 May 2016 21:51:08 +0200 (CEST) X-Virus-Scanned: amavisd-new at mta20.int.yaziba.net Received: from mta20.int.yaziba.net ([127.0.0.1]) by localhost (mta20.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Q2zlhaewGrvt for ; Sat, 14 May 2016 21:51:08 +0200 (CEST) Received: from mail-vk0-f47.google.com (mail-vk0-f47.google.com [209.85.213.47]) by mta20.int.yaziba.net (Postfix) with ESMTPSA id DE985CA657 for ; Sat, 14 May 2016 21:51:07 +0200 (CEST) Received: by mail-vk0-f47.google.com with SMTP id c189so20875735vkb.1 for ; Sat, 14 May 2016 12:51:07 -0700 (PDT) X-Gm-Message-State: AOPr4FX7d4SdhLYskGAAwEEPcIoY1MbvHML5WHdzy/tgKqVcP68+zruJGwSUhepXDt86gqIyCjiYm57XPmr4EQ== X-Received: by 10.31.5.144 with SMTP id 138mr11473549vkf.43.1463255466722; Sat, 14 May 2016 12:51:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.159.41.103 with HTTP; Sat, 14 May 2016 12:50:47 -0700 (PDT) From: Nicolas Ojeda Bar Date: Sat, 14 May 2016 21:50:47 +0200 X-Gmail-Original-Message-ID: Message-ID: To: caml-list@inria.fr Content-Type: multipart/alternative; boundary=001a1143ef624f50c40532d2b67d X-DRWEB-SCAN: ok X-VRSPAM-SCORE: 0 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrfeekledrvdefgddugedvucetufdoteggodetrfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdgjtegkkfeuteenuceurghilhhouhhtmecufedttdenucenucfjughrpefhfffkuffvtgesrgdtreertddtjeenucfhrhhomheppfhitgholhgrshcuqfhjvggurgcuuegrrhcuoehnihgtohhlrghsrdhojhgvuggrrdgsrghrsehlvgigihhfihdrtghomheqnecukfhppedvtdelrdekhedrvddufedrgeejnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhht X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht Subject: [Caml-list] ocamllex and polymorphic recursion --001a1143ef624f50c40532d2b67d Content-Type: text/plain; charset=UTF-8 Hi list, I am trying to write a parser using ocamllex for a language for which the usual character -> token -> ast does not make sense and instead one needs to produce the ast directly from the character level. Even though this is not its intended use case, it actually works quite well! Except that, while I can define higher-order rules, such as rule sp item = parse | ' ' { item lexbuf } I cannot actually use such a rule for 'item's which return different types. As far as I can see this is because the set of all rules is translated into a set of recursively defined functions and using 'sp' with 'items' of different types would require the function corresponding to 'sp' to have some explicit polymorphism annotation. Is there a way to twist ocamllex a little more to make this work ? Or if not, would it make sense to expose a way for the user to provide these annotations herself ? Thanks! - Nicolas --001a1143ef624f50c40532d2b67d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi list,

I am trying to write a parser = using ocamllex for a language for which the usual character -> token -&g= t; ast does not make sense and instead one needs to produce the ast directl= y from the character level.

Even though this is no= t its intended use case, it actually works quite well! Except that, while I= can define higher-order rules, such as

=C2=A0= rule sp item =3D parse
=C2=A0 | ' ' { item lexbuf }

I cannot actually use such a rule for 'item's = which return different types.=C2=A0 As far as I can see this is because the= set of all rules is translated into a set of recursively defined functions= and using 'sp' with 'items' of different types would requi= re the function corresponding to 'sp' to have some explicit polymor= phism annotation.

Is there a way to twist ocamllex= a little more to make this work ?=C2=A0 Or if not, would it make sense to = expose a way for the user to provide these annotations herself ?
=
Thanks!

- Nicolas
--001a1143ef624f50c40532d2b67d--