caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Jake Donham" <jake.donham@skydeck.com>
To: caml-list@yquem.inria.fr
Subject: ocamllex regexp problem
Date: Tue, 18 Mar 2008 19:03:25 -0700	[thread overview]
Message-ID: <c7e4e9f0803181903p49ab284h8ad74e8021be2ccd@mail.gmail.com> (raw)

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

Hi list,

I am trying to parse an RSS feed using OCaml-RSS, which uses XML-Light,
which however does not support CDATA blocks. So I added support in the
ocamllex-based lexer as follows:

  let ends_sq = [^']']* ']'
  let ends_sq_sq = ends_sq ([^']'] ends_sq)* ']'+
  let ends_sq_sq_ang = ends_sq_sq ([^'>'] ends_sq_sq)* '>'

or expanded:

  let ends_sq_sq_ang = (([^']']*']') ([^']'] ([^']']*']'))* ']'+) ([^'>']
(([^']']*']') ([^']'] ([^']']*']'))* ']'+))* '>'

  rule token = parse
  [...]
          | "<![CDATA[" (ends_sq_sq_ang as data)
  [...]

Here ends_sq_sq_ang is supposed to match strings ending in ]]> which may
contain ] and >. If I give it an input like "foo]]]>bar]]>" (note the extra
square bracket after foo), ocamllex matches the whole input instead of just
"foo]]]>" as I would expect. But Micmatch, when given the same regexp, does
the right thing. (The ']'+ bits are supposed to handle the "]]]>" case.)

I have probably done something stupid and am embarrassing myself by
advertising it to the list, but I did check it carefully. Any idea why this
doesn't work? Thanks,

Jake

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

             reply	other threads:[~2008-03-19  2:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-19  2:03 Jake Donham [this message]
2008-03-19  9:00 ` [Caml-list] " Michael Wohlwend
2008-03-19 15:21 ` Martin Jambon
2008-03-19 16:39 ` Jake Donham

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=c7e4e9f0803181903p49ab284h8ad74e8021be2ccd@mail.gmail.com \
    --to=jake.donham@skydeck.com \
    --cc=caml-list@yquem.inria.fr \
    /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).