caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: "Milan Stanojević" <milanst@gmail.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] scanf question
Date: Sat, 21 Feb 2015 10:55:42 +0100	[thread overview]
Message-ID: <CAPFanBFCGeCw60Uy2WzioLVa1FwsRG9=YwH1-AssaXd7i0hNbA@mail.gmail.com> (raw)
In-Reply-To: <CAKR7PS96P6TZAt26VZzw-yxKWYVq9reF5xW5ExvAE97OF+NJ3g@mail.gmail.com>

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

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ć <milanst@gmail.com> 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 = ("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 = ("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
>

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

  reply	other threads:[~2015-02-21  9:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-20 19:28 Milan Stanojević
2015-02-21  9:55 ` Gabriel Scherer [this message]
2015-02-21 20:08   ` Benoit Vaugon
2015-02-23 19:08     ` Milan Stanojević

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPFanBFCGeCw60Uy2WzioLVa1FwsRG9=YwH1-AssaXd7i0hNbA@mail.gmail.com' \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=milanst@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).