From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=DNS_FROM_RFC_POST,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 79131BBC4 for ; Sat, 7 Mar 2009 12:23:51 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmUCAFvosUnRVduukWdsb2JhbACUUz8BAQEBCQkMBw+uX4EHj0EBAwEDhAIGgwo X-IronPort-AV: E=Sophos;i="4.38,318,1233529200"; d="scan'208";a="22190663" Received: from mail-ew0-f174.google.com ([209.85.219.174]) by mail2-smtp-roc.national.inria.fr with ESMTP; 07 Mar 2009 12:23:51 +0100 Received: by ewy22 with SMTP id 22so469986ewy.27 for ; Sat, 07 Mar 2009 03:23:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:content-transfer-encoding:mime-version:subject:date :x-mailer; bh=4ON+DgFOvVHHwZRNwYICWmGYv0iohyhdF8OqR9w0oxo=; b=iFj7eqDvkvrUChUc3k4f74sCCcR9MDNsd3fQklpiM0ScR6iO+qgJQ/rhDEY/vkGdX0 Jlbf7TZKuC0Y3Y/VOpV7NqPdvYbFibvxtSERlEMWDzNPdp6+dzyGfz8AlfE8OoCyOorA Kg37zPC1U/lS+sG8ELb+EHw+gwNr7hDrpjmfg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:content-transfer-encoding :mime-version:subject:date:x-mailer; b=wQpahWw2MMH82UVDQRf4yMG8s+ZB3ABHB/miDOfQg1v+17dk/sK7RgsaUvQzP1roM6 BWGCVHnSZhjW068gqyeLhM3y76/v89mGS4FUZiqnMCEpeRfexE+cArp4RWZkaz60AV1s ORu/a+xZpaxIsi9ctAbn4r/yLHppuzVOQyDQo= Received: by 10.210.57.12 with SMTP id f12mr1790271eba.85.1236425030745; Sat, 07 Mar 2009 03:23:50 -0800 (PST) Received: from ?10.10.30.14? (171.Red-88-3-3.dynamicIP.rima-tde.net [88.3.3.171]) by mx.google.com with ESMTPS id 5sm3843781nfv.61.2009.03.07.03.23.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 07 Mar 2009 03:23:50 -0800 (PST) Message-Id: From: Joel Reymont To: O'Caml Mailing List Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: camlp4 stream parser and reporting error location Date: Sat, 7 Mar 2009 11:23:47 +0000 X-Mailer: Apple Mail (2.930.3) X-Spam: no; 0.00; camlp:01 parser:01 camlp:01 parser:01 ocamllex:01 lexer:01 'int:01 'string:01 bool:01 bool:01 ocaml:01 token:01 token:01 rec:01 int:01 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