From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA16828; Thu, 18 Sep 2003 21:01:48 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA20869 for ; Thu, 18 Sep 2003 21:01:47 +0200 (MET DST) Received: from mail3.tpgi.com.au (mail.tpgi.com.au [203.12.160.59]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h8IJ1j503526 for ; Thu, 18 Sep 2003 21:01:45 +0200 (MET DST) Received: from 203-219-234-45-syd-ts25-2600.tpgi.com.au (203-219-234-45-syd-ts25-2600.tpgi.com.au [203.219.234.45]) by mail3.tpgi.com.au (8.11.6/8.11.6) with ESMTP id h8IJ1X717687; Fri, 19 Sep 2003 05:01:34 +1000 Subject: Re: [Caml-list] line number information in abstract syntax trees From: skaller Reply-To: skaller@ozemail.com.au To: Christian Lindig Cc: "Rafael 'Dido' Sevilla" , Caml Mailing List In-Reply-To: <20030917084448.GD8771@st> References: <20030915075339.GA20719@imperium.ph> <20030917084448.GD8771@st> Content-Type: text/plain Message-Id: <1063911675.19351.7.camel@pelican> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 19 Sep 2003 05:01:16 +1000 Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 ozemail:01 44,:01 lindig:01 rafael:01 'dido':01 expr:01 expr:01 int:01 sep:01 syntax:02 ast:02 nodes:02 rewriting:02 rewriting:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 2003-09-17 at 18:44, Christian Lindig wrote: > On Mon, Sep 15, 2003 at 03:53:39PM +0800, Rafael 'Dido' Sevilla wrote: > and expr = > ExprAt of (expr * region) (* <--- *) > | Int of (StdPrims.std_string * ty option) > This > representation comes in handy when you create an AST not by parsing, > but directly. In this case you don't have to invent line numbers because > you simply never would generate ExprAt nodes. This is a false sense of security. Synthesised terms may also contain errors (for example type errors). Therefore the error reporting needs to reflect where the error occurred, which means you need to synthesise an appropriate source reference. The advantage of mandatory source references (as opposed to the above style) is that you're *forced* as a programmer to consider the issue at all times. I sometimes 'cheat' a bit, and dont give a precise enough reference, but that's better than omiting one: for every expression, mandatory source references *guarrantee* the presence of a source reference -- and that assurance is useful in a product which is 90% error reporting, all of which *should* relate back to the input source. In particular this means that term rewriting rules must attempt to preserve source location data in some sensible way, which is often somewhat more diffiult than the logic of the rewriting rules themselves. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners