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: Christian Lindig <lindig@c...>
Subject: Re: [Caml-list] line number information in abstract syntax trees
On Fri, Sep 19, 2003 at 05:01:16AM +1000, skaller wrote:
> 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). 

I should have made my example more precise. In the Quick C-- compiler we
have a pretty printer for the AST. An AST is normally produced by the
parser where we record line number information in *At nodes; in
addition, we can translate back our intermediate representation to
source code, via the AST and pretty printer. When we do so, we don't
bother with line number information because it is for debugging only. I
still consider this appropriate.

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

Line number information become a dynamic property, and of course, they
are less secure than statically enforced line numbers. I guess everybody
here recognizes this as an instance of the familiar static vs. dynamic
discussion.

-- Christian

-- 
Christian Lindig         http://www.st.cs.uni-sb.de/~lindig/

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