caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <mottl@miss.wu-wien.ac.at>
To: Laurent Reveillere <Laurent.Reveillere@labri.u-bordeaux.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Problem when parsing
Date: Fri, 2 Mar 2001 14:21:28 +0100	[thread overview]
Message-ID: <20010302142128.A23707@miss.wu-wien.ac.at> (raw)
In-Reply-To: <3A9F79EC.56C757EA@labri.fr>; from Laurent.Reveillere@labri.u-bordeaux.fr on Fri, Mar 02, 2001 at 11:46:04 +0100

On Fri, 02 Mar 2001, Laurent Reveillere wrote:
> I wrote a small parser for iso C which does nothing (for now).
> The lexer and parser files are well compiled by ocamllex and ocamlyacc.
> But when I run the generated program, I have the following error :
> 
> Fatal error: uncaught exception Failure(lexing: empty token)
[snip]

The problem is that your parser rules are recursive, and you do not
handle EOF (end-of-file) in the lexer.

This means that the parser will demand a new token, because the recursive
parser rule says that there could be more of them. The lexer, however,
doesn't return further ones, because it doesn't know how to handle EOF.

There is a special pattern called "eof" (without the double-quotes) that
you can use in the lexer to match EOF. You can introduce a new token
"EOF" in the parser and return this one from the scanner when required.
You'll need parser rules that handle the EOF-token, of course.  Then your
problem should go away.

Regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


      parent reply	other threads:[~2001-03-02 13:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-02 10:46 Laurent Reveillere
2001-03-02 13:02 ` Jean-Christophe Filliatre
2001-03-02 13:07   ` Laurent Reveillere
2001-03-02 13:21 ` Markus Mottl [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=20010302142128.A23707@miss.wu-wien.ac.at \
    --to=mottl@miss.wu-wien.ac.at \
    --cc=Laurent.Reveillere@labri.u-bordeaux.fr \
    --cc=caml-list@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).