Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] line number information in abstract syntax trees
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@o...>
Subject: Re: [Caml-list] line number information in abstract syntax trees
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