caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Joel Reymont <joelr1@gmail.com>
To: O'Caml Mailing List <caml-list@yquem.inria.fr>
Subject: camlp4 stream parser and reporting error location
Date: Sat, 7 Mar 2009 11:23:47 +0000	[thread overview]
Message-ID: <D455E7DE-077E-49B0-8DFD-63468D90BC5D@gmail.com> (raw)

Assuming a simple Camlp4 parser that uses a ocamllex lexer wrapped in  
a stream,

let rec parse_primary = parser

   | [< 'INT n >] -> Int n
   | [< 'FLOAT n >] -> Float n
   | [< 'STRING n >] -> Str n
   | [< 'TRUE >] -> Bool true
   | [< 'FALSE >] -> Bool false

   | [< >] -> raise (Stream.Error "unknown token when expecting an  
expression.")

How do I report the error location?

Do I need to pass loc in with every token?

Then what happens in the error case where there's no token available?

	Thanks, Joel

---
http://tinyco.de
Mac, C++, OCaml




                 reply	other threads:[~2009-03-07 11:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=D455E7DE-077E-49B0-8DFD-63468D90BC5D@gmail.com \
    --to=joelr1@gmail.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).