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 5A7217EE48 for ; Sat, 21 Feb 2015 10:56:24 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.213.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.213.173 as permitted sender) identity=mailfrom; client-ip=209.85.213.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ig0-f173.google.com) identity=helo; client-ip=209.85.213.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-ig0-f173.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DOAwCRVehUm63VVdFbg1haBIMEsCiNcoFuhXECgRIHQwEBAQEBARABAQEBAQYLCwkULoQQAQEDARIRBBkBGxILAQMBCwYFBAcaHQICIQEBEQEFAQoSBhMSEId4AQMJCA2uYD4xiy6Ba4J3jVgKGScDClSEWAEBAQEBAQQBAQEBAQEBARQBBQ6LAYJEgiYEB4JogUMFhFwKiHeFTYQfgUaBU4tWA4Q6EiOBDAmCIR+BUT0xgkMBAQE X-IPAS-Result: A0DOAwCRVehUm63VVdFbg1haBIMEsCiNcoFuhXECgRIHQwEBAQEBARABAQEBAQYLCwkULoQQAQEDARIRBBkBGxILAQMBCwYFBAcaHQICIQEBEQEFAQoSBhMSEId4AQMJCA2uYD4xiy6Ba4J3jVgKGScDClSEWAEBAQEBAQQBAQEBAQEBARQBBQ6LAYJEgiYEB4JogUMFhFwKiHeFTYQfgUaBU4tWA4Q6EiOBDAmCIR+BUT0xgkMBAQE X-IronPort-AV: E=Sophos;i="5.09,620,1418079600"; d="scan'208";a="100839241" Received: from mail-ig0-f173.google.com ([209.85.213.173]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 21 Feb 2015 10:56:23 +0100 Received: by mail-ig0-f173.google.com with SMTP id a13so8551647igq.0 for ; Sat, 21 Feb 2015 01:56:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=i/mcym0+cRoaILkedIMxv7g3pvNS/SktWTn+9AaMDkE=; b=WYmRQSHa+Prc0DaaXY+AvXFDK8o2anC7vmSiWrmwWDHYXJQSy3D2MHBPNQAZubwif1 eANzdCI+XFuDYaP4EbZFZLw8CAL2TDQotWPmxyd+ItJsLejQ+bbsvc5WmPggiJxP6I5F EZreCaunJDrTIxm7b3/lzdnfn9EndQ7+4kyesgWA3gOIyj7uUiZ/Jd6tmeYU7aom7qe8 cNW4LI2hPEXxswOzOii6wfrBz5E31e/nramRul7zBo/EFWMZI4i+lwzmLP4qzrcrGCDF spjSh555jT3HEN06RrrKmmT/GWXs/4ccmxm9tU+YIO9tdBYX33Fxy2ZgjDeirW7zPOYV DdJw== X-Received: by 10.50.254.4 with SMTP id ae4mr1850516igd.10.1424512582250; Sat, 21 Feb 2015 01:56:22 -0800 (PST) MIME-Version: 1.0 Received: by 10.36.13.16 with HTTP; Sat, 21 Feb 2015 01:55:42 -0800 (PST) In-Reply-To: References: From: Gabriel Scherer Date: Sat, 21 Feb 2015 10:55:42 +0100 Message-ID: To: =?UTF-8?Q?Milan_Stanojevi=C4=87?= Cc: Caml List Content-Type: multipart/alternative; boundary=001a11343b92719afc050f962e59 Subject: Re: [Caml-list] scanf question --001a11343b92719afc050f962e59 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable This seems to be a regression caused by the reimplementation of format strings in 4.02; some "stop after this character" indications are supported, but some other fail (when they correspond to valid Format specifications). Would you mind opening a but report ( http://caml.inria.fr/mantis/ )? On Fri, Feb 20, 2015 at 8:28 PM, Milan Stanojevi=C4=87 = wrote: > I want to parse a bash like sequence string, for example > "some-thing{1..20}", and extract the string before first { and then > two numbers inside. > > I tried this first > utop # Scanf.sscanf "some-thing{1..3}" "%s{%d..%d}" (fun s n1 n2 -> > s,n1,n2);; > Exception: End_of_file. > > Then I realized %s is special and needs scanning indication (character @). > > So I tried that but I get the same error > utop # Scanf.sscanf "some-thing{1..3}" "%s@{%d..%d}" (fun s n1 n2 -> > s,n1,n2);; > Exception: End_of_file. > > But if I use some other character as end of string indication then it > works. > utop # Scanf.sscanf "some-thingI{1..3}" "%s@I{%d..%d}" (fun s n1 n2 -> > s,n1,n2);; > - : bytes * int * int =3D ("some-thing", 1, 3) > > It seems '{' is somehow special but I can't find anything in the docs > about this. > Can someone explain what is going on here? > > Thanks! > > > p.s. At the end I solved my thing by using a range > > utop # Scanf.sscanf "some-thing{1..3}" "%[a-z-]{%d..%d}" (fun s n1 n2 > -> s,n1,n2);; > - : bytes * int * int =3D ("some-thing", 1, 3) > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > --001a11343b92719afc050f962e59 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
This seems to be a regression caused by the reimplementati= on of format strings in 4.02; some "stop after this character" in= dications are supported, but some other fail (when they correspond to valid= Format specifications). Would you mind opening a but report ( http://caml.inria.fr/mantis/ )?
<= div class=3D"gmail_extra">
On Fri, Feb 20, 20= 15 at 8:28 PM, Milan Stanojevi=C4=87 <milanst@gmail.com> wro= te:
I want to parse a bash like sequence = string, for example
"some-thing{1..20}", and extract the string before first { and th= en
two numbers inside.

I tried this first
utop # Scanf.sscanf "some-thing{1..3}" "%s{%d..%d}" (fu= n s n1 n2 -> s,n1,n2);;
Exception: End_of_file.

Then I realized %s is special and needs scanning indication (character @).<= br>
So I tried that but I get the same error
utop # Scanf.sscanf "some-thing{1..3}" "%s@{%d..%d}" (f= un s n1 n2 -> s,n1,n2);;
Exception: End_of_file.

But if I use some other character as end of string indication then it works= .
utop # Scanf.sscanf "some-thingI{1..3}" "%s@I{%d..%d}" = (fun s n1 n2 ->
s,n1,n2);;
- : bytes * int * int =3D ("some-thing", 1, 3)

It seems '{' is somehow special but I can't find anything in th= e docs
about this.
Can someone explain what is going on here?

Thanks!


p.s. At the end I solved my thing by using a range

utop # Scanf.sscanf "some-thing{1..3}" "%[a-z-]{%d..%d}"= ; (fun s n1 n2
-> s,n1,n2);;
- : bytes * int * int =3D ("some-thing", 1, 3)

--
Caml-list mailing list.=C2=A0 Subscription management and archives:
ht= tps://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--001a11343b92719afc050f962e59--