From rowe at muxspace.com  Mon Jan 14 02:43:51 2013
From: rowe at muxspace.com (Brian Lee Yung Rowe)
Date: Sun, 13 Jan 2013 20:43:51 -0500
Subject: [Rd] Issue with getParserData in R3.0.0
Message-ID: <A40C54F1-6BE4-4469-BF23-DB094A214A88@muxspace.com>

Hello,

I am migrating my package lambda.r to R3.0.0 and am experiencing some issues with the getParserData function (which replaces the parser package). Basically the function works in the R shell but fails when either called from RUnit or from R CMD check. 

I've narrowed it down to the function getSrcfile, which is returning different values depending on the code path. From the command line (works okay):

debug: srcfile <- getSrcfile(x)
Browse[2]> 
debug: if (is.null(srcfile)) return(NULL) else data <- srcfile$parseData
Browse[2]> srcfile
<text> 

When running from the Runit script I get this instead:
debug: srcfile <- getSrcfile(x)
Browse[3]> 
debug: if (is.null(srcfile)) return(NULL) else data <- srcfile$parseData
Browse[3]> srcfile
NULL


Below is an example calling the getParserData from the command line:
> text <- "abs_max(a, b) %::% numeric:numeric:numeric"
> parse(text=text)
expression(abs_max(a, b) %::% numeric:numeric:numeric)
> getParseData(parse(text=text))
   line1 col1 line2 col2 id parent                token terminal    text
27     1    1     1   42 27      0                 expr    FALSE        
14     1    1     1   13 14     27                 expr    FALSE        
1      1    1     1    7  1      3 SYMBOL_FUNCTION_CALL     TRUE abs_max
3      1    1     1    7  3     14                 expr    FALSE        
2      1    8     1    8  2     14                  '('     TRUE       (
4      1    9     1    9  4      6               SYMBOL     TRUE       a
... 

The RUnit call from the command line is
  runTestFile('/home/brian/workspace/lambda.r/inst/unitTests/runit.dispatching.4.R')

and fails because of the NULL value of srcfile. The first line of the runit test file is
  abs_max(a, b) %::% numeric:numeric:numeric

Any insights are appreciated.

Brian



[Rd] Issue with getParserData in R3.0.0
Brian Lee Yung Rowe