caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] ocaml-re library, partial match semantics
@ 2014-09-30 12:35 Tom Ridge
  2014-10-01 11:53 ` Jérôme Vouillon
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Ridge @ 2014-09-30 12:35 UTC (permalink / raw)
  To: caml-list

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

Dear All,

I am using the ocaml-re library

https://github.com/ocaml/ocaml-re

I have the following code:

open Re;

let a = char 'a'
let b = char 'b'

let re = seq[a;b] |> compile

let rs = exec re "caba"

let [|(1,3)|] = get_all_ofs rs

let true = execp re "cab"

let _ = assert (exec_partial re "a" = `Mismatch)

I was expecting that the exec_partial in the final line would return
`Partial, indicating that a prefix of a match was found. However, a
`Mismatch was returned instead. What is the meaning/behaviour of
exec_partial? Can I use it to perform a partial match?

Thanks

Tom

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

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

* Re: [Caml-list] ocaml-re library, partial match semantics
  2014-09-30 12:35 [Caml-list] ocaml-re library, partial match semantics Tom Ridge
@ 2014-10-01 11:53 ` Jérôme Vouillon
  0 siblings, 0 replies; 2+ messages in thread
From: Jérôme Vouillon @ 2014-10-01 11:53 UTC (permalink / raw)
  To: Tom Ridge, caml-list

Hi,

On 09/30/2014 14:35, Tom Ridge wrote:
> I am using the ocaml-re library
> 
> https://github.com/ocaml/ocaml-re
> 
> I have the following code:
> 
> open Re;
> 
> let a = char 'a'
> let b = char 'b'
> 
> let re = seq[a;b] |> compile
[...]
> let _ = assert (exec_partial re "a" = `Mismatch)
> 
> I was expecting that the exec_partial in the final line would return
> `Partial, indicating that a prefix of a match was found. However, a
> `Mismatch was returned instead. What is the meaning/behaviour of
> exec_partial? Can I use it to perform a partial match?

There was a bug in exec_partial, which is fixed in version 1.2.2.
Now, you get the correct result:

# exec_partial re "a";;
- : [ `Full | `Mismatch | `Partial ] = `Partial

-- Jérôme

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

end of thread, other threads:[~2014-10-01 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-30 12:35 [Caml-list] ocaml-re library, partial match semantics Tom Ridge
2014-10-01 11:53 ` Jérôme Vouillon

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).