[Rd] Recursively parsing srcrefs

Hadley Wickham hadley at rice.edu
Sun May 15 15:04:56 CEST 2011


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



More information about the R-devel mailing list