caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Nicolas Pouillard <nicolas.pouillard@inria.fr>
To: jean-david hsu <jhsu1@email.sjsu.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] I don t get the lexer
Date: Tue, 14 Feb 2006 08:55:28 +0100	[thread overview]
Message-ID: <cd67f63a0602132355j4630e433wc995981a9e1ae969@mail.gmail.com> (raw)
In-Reply-To: <43EF7152.6080307@email.sjsu.edu>

On 2/12/06, jean-david hsu <jhsu1@email.sjsu.edu> wrote:
> Hello everyone
Hi,

> how come my lexer does not break "?!" both defined as keywords but puts
> "." aside?

Because the lexer of Genlex is not really generated but parametrized
by a keyword table.

Concerned rules are:
 | Some
        ('!' | '%' | '&' | '$' | '#' | '+' | '/' | ':' | '<' | '=' | '>' |
         '?' | '@' | '\\' | '~' | '^' | '|' | '*' as c) ->
        Stream.junk strm__;
        let s = strm__ in reset_buffer (); store c; ident2 s
[...]
| Some c -> Stream.junk strm__; Some (keyword_or_error c)
[...]
  and ident2 (strm__ : _ Stream.t) =
    match Stream.peek strm__ with
      Some
        ('!' | '%' | '&' | '$' | '#' | '+' | '-' | '/' | ':' | '<' | '=' |
         '>' | '?' | '@' | '\\' | '~' | '^' | '|' | '*' as c) ->
        Stream.junk strm__; let s = strm__ in store c; ident2 s

In short '?' and '!' are in the same character class but '.' is
treated by the default case. Since the lexer search the longest token
that matches, "?!" are packed together but not with a '.' .

--
Nicolas Pouillard

      reply	other threads:[~2006-02-14  7:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-12 17:33 jean-david hsu
2006-02-14  7:55 ` Nicolas Pouillard [this message]

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=cd67f63a0602132355j4630e433wc995981a9e1ae969@mail.gmail.com \
    --to=nicolas.pouillard@inria.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=jhsu1@email.sjsu.edu \
    /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).