caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* camlp4 stream parser and reporting error location
@ 2009-03-07 11:23 Joel Reymont
  0 siblings, 0 replies; only message in thread
From: Joel Reymont @ 2009-03-07 11:23 UTC (permalink / raw)
  To: O'Caml Mailing List

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




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-07 11:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-07 11:23 camlp4 stream parser and reporting error location Joel Reymont

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