non-terminal token lacking children from utils::getParseData

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

non-terminal token lacking children from utils::getParseData

Benjamin Tyner
Hi,

I have run across a source file for which the return value
of getParseData() includes a record having FALSE for $terminal, yet it is
not the parent of any other tokens. Before I spend time constructing a
reproducible example, I wanted to verify that this is in fact unexpected
behavior (under R 3.1.2)?

Thanks,
Ben

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: non-terminal token lacking children from utils::getParseData

Duncan Murdoch-2
On 19/02/2015 6:31 PM, B Tyner wrote:
> Hi,
>
> I have run across a source file for which the return value
> of getParseData() includes a record having FALSE for $terminal, yet it is
> not the parent of any other tokens. Before I spend time constructing a
> reproducible example, I wanted to verify that this is in fact unexpected
> behavior (under R 3.1.2)?

Before I spend the time thinking about that, I'd like to see a
reproducible example.

Duncan Murdoch

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: non-terminal token lacking children from utils::getParseData

Benjamin Tyner
I tried to reduce the offending portion as best I could to a
more-or-less minimal example (1136 bytes), which can be downloaded via:

    wget https://www.dropbox.com/s/74rgxr5x2aalr99/badstring.R

then once in R,

    > b <- parse(file = "~/badstring.R", keep.source = TRUE)
    > d <- getParseData(b, includeText = FALSE)
    > subset(d, line1 == 2L)
       line1 col1 line2 col2 id parent token terminal
    10     2    5    24    1 10     21  expr    FALSE
    > subset(d, parent == 10)
    [1] line1    col1     line2    col2     id       parent   token  
terminal
    <0 rows> (or 0-length row.names)
   
here is my

    > sessionInfo()
    R version 3.0.2 (2013-09-25)
    Platform: x86_64-pc-linux-gnu (64-bit)
   
    locale:
     [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C            
     [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8  
     [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8  
     [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                
     [9] LC_ADDRESS=C               LC_TELEPHONE=C          
    [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C      
   
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base

note that while it says R version 3.0.2 above, I have seen the same
behaviour under version 3.1.2 as well.

Regards
Ben

On 02/19/2015 06:34 PM, Duncan Murdoch wrote:

> On 19/02/2015 6:31 PM, B Tyner wrote:
>> Hi,
>>
>> I have run across a source file for which the return value
>> of getParseData() includes a record having FALSE for $terminal, yet it is
>> not the parent of any other tokens. Before I spend time constructing a
>> reproducible example, I wanted to verify that this is in fact unexpected
>> behavior (under R 3.1.2)?
> Before I spend the time thinking about that, I'd like to see a
> reproducible example.
>
> Duncan Murdoch
>
>


______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: non-terminal token lacking children from utils::getParseData

Benjamin Tyner
Thank you Yihui for also reporting the bug here:

https://bugs.r-project.org/bugzilla/show_bug.cgi?id=16354

and thank you Duncan for finding the issue and fixing it! I definitely
like your idea to report a summary message instead of the long text string.

Regards
Ben

> I tried to reduce the offending portion as best I could to a
> more-or-less minimal example (1136 bytes), which can be downloaded via:
>
>     wget https://www.dropbox.com/s/74rgxr5x2aalr99/badstring.R
>
> then once in R,
>
>     > b <- parse(file = "~/badstring.R", keep.source = TRUE)
>     > d <- getParseData(b, includeText = FALSE)
>     > subset(d, line1 == 2L)
>        line1 col1 line2 col2 id parent token terminal
>     10     2    5    24    1 10     21  expr    FALSE
>     > subset(d, parent == 10)
>     [1] line1    col1     line2    col2     id       parent   token  
> terminal
>     <0 rows> (or 0-length row.names)
>    
> here is my
>
>     > sessionInfo()
>     R version 3.0.2 (2013-09-25)
>     Platform: x86_64-pc-linux-gnu (64-bit)
>    
>     locale:
>      [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C            
>      [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8  
>      [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8  
>      [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                
>      [9] LC_ADDRESS=C               LC_TELEPHONE=C          
>     [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C      
>    
>     attached base packages:
>     [1] stats     graphics  grDevices utils     datasets  methods   base
>
> note that while it says R version 3.0.2 above, I have seen the same
> behaviour under version 3.1.2 as well.
>
> Regards
> Ben
>
> On 02/19/2015 06:34 PM, Duncan Murdoch wrote:
> >/ On 19/02/2015 6:31 PM, B Tyner wrote:
> />>/ Hi,
> />>/
> />>/ I have run across a source file for which the return value
> />>/ of getParseData() includes a record having FALSE for $terminal, yet it is
> />>/ not the parent of any other tokens. Before I spend time constructing a
> />>/ reproducible example, I wanted to verify that this is in fact unexpected
> />>/ behavior (under R 3.1.2)?
> />/ Before I spend the time thinking about that, I'd like to see a
> />/ reproducible example.
> />/
> />/ Duncan Murdoch
> />/
> />


______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.