From hadley at rice.edu  Sun May 15 15:04:56 2011
From: hadley at rice.edu (Hadley Wickham)
Date: Sun, 15 May 2011 08:04:56 -0500
Subject: [Rd] Recursively parsing srcrefs
In-Reply-To: <4DCC7247.8030903@gmail.com>
References: <BANLkTikpgh27=EJGnmfrmuQ7QBh1vV-Qkw@mail.gmail.com>
	<4DCC28F6.2090502@gmail.com>
	<BANLkTimkrQ3AXViGgnxB6hgVN90abXcL5Q@mail.gmail.com>
	<4DCC7247.8030903@gmail.com>
Message-ID: <BANLkTi=S=AxnBkOP=9eiCDCo+rYG2eQNYQ@mail.gmail.com>

>> findLineNum doesn't quite do what I want - it works on the text of the
>> srcref, not on the parse tree.
>
> It searches through the parse tree for the smallest source ref that contains
> a given line. ?So for example,
>
> if(condition) {
> ?blah
> ?blah
> ?blah
> }
>
> is a single statement, and there will be a srcref stored in its container
> that goes from line N to line N+4. ?But it also contains the compound
> statement
>
> {
> ?blah
> ?blah
> ?blah
> }
>
> and there will be srcrefs attached to that for each of the statements in it.
> ?(I forget right now whether there are 3 or 4 statements there: ?R treats
> braces in a funny way, and I'd have to look at an example to check.) ?Each
> of the "blah"'s will get a srcref spanning one line, and it will be stored
> in the container.

I'm clearly missing something obvious because I don't see how to
access these lower-level srcrefs.  Would you mind providing a small
example?

Thanks!

Hadley


-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



[Rd] Recursively parsing srcrefs
Hadley Wickham