search for: getparsedata

Displaying 20 results from an estimated 33 matches for "getparsedata".

2016 Mar 10
2
getParseData() for installed packages
I can't seem to reliably obtain parse data via getParseData() for functions from installed packages. The parse data seems to be available only for the *last* file in the package. See [1] for a small example package with just two functions f and g in two files a.R and b.R. See [2] for a documented test run on installed package (Ubuntu 15.10, UTF-8 local...
2015 Jul 29
2
Mapping parse tree elements to tokens
I would like to map the parsed tokens obtained from utils::getParseData() to the parse tree and elements obtained by base::parse(). It looks like back when this code was in the parser package the parse() function annotated the elements in the tree with their id, which would allow you to perform this mapping. However when the code was included in R this functionality...
2013 Sep 18
1
getParseData() for imaginary numbers
Hi, The imaginary unit is gone in the 'text' column in the returned data frame from getParseData(), e.g. in the example below, perhaps the text should be 1i instead of 1: > p=parse(text='1i') > getParseData(p) line1 col1 line2 col2 id parent token terminal text 1 1 1 1 2 1 2 NUM_CONST TRUE 1 2 1 1 1 2 2 0 expr FALSE &g...
2014 Jun 12
1
regression bug with getParseData and/or parse in R-3.1.0
Hi, With R-3.1.0 I get: > getParseData(parse(text = "{1}", keep.source = TRUE)) line1 col1 line2 col2 id parent token terminal text 7 1 1 1 3 7 9 expr FALSE 1 1 1 1 1 1 7 '{' TRUE { 2 1 2 1 2 2 3 NUM_CONST TRUE 1 3 1 2...
2015 Jul 29
3
Mapping parse tree elements to tokens
...is often reparsing the text, which just seems redundant and inconvenient. Michael On Wed, Jul 29, 2015 at 9:43 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > On 29/07/2015 12:13 PM, Jim Hester wrote: >> >> I would like to map the parsed tokens obtained from utils::getParseData() >> to the parse tree and elements obtained by base::parse(). >> >> It looks like back when this code was in the parser package the parse() >> function annotated the elements in the tree with their id, which would >> allow you to perform this mapping. However when th...
2015 Jul 29
1
Mapping parse tree elements to tokens
...reference is generated in this case (because it is parsed as a single expression), it is not possible to track each of the clauses separately. While I can get the source reference for the entire statement, in order to extract the if/else clauses I need to either use the tokenized information from getParseData(), or re-parse the entire if / else expression by hand (which seems prone to error to me). Another example of where this would help is linking comments to expressions. While I know this topic has been discussed previously ( https://stat.ethz.ch/pipermail/r-devel/2009-March/052731.html) and I am f...
2013 Jul 05
3
should the text for RIGHT_ASSIGN be -> in getParseData()?
Hi, The text column for '->' becomes '<-' in the data frame returned by getParseData(): > getParseData(parse(text='1->x')) line1 col1 line2 col2 id parent token terminal text 7 1 1 1 4 7 0 expr FALSE 1 1 1 1 1 1 2 NUM_CONST TRUE 1 2 1 1 1 1 2 7 expr FALSE 3 1 2...
2014 Jan 25
0
interpreting the output of getParseData()
Hi, I'm trying to make sense of the output of getParseData(). The "parent" column is supposed to refer to the "id" of the parent of the given item, but there are numbers in the parent column that do not exist in the id column. Example: > p <- parse(text="f<-function(){if(TRUE)1 else 2}") > df <- getParseData(p)...
2016 Mar 10
2
getParseData() for installed packages
On 10.03.2016 15:49, Duncan Murdoch wrote: > On 10/03/2016 8:27 AM, Kirill M?ller wrote: >> I can't seem to reliably obtain parse data via getParseData() for >> functions from installed packages. The parse data seems to be available >> only for the *last* file in the package. >> >> See [1] for a small example package with just two functions f and g in >> two files a.R and b.R. See [2] for a documented test run on inst...
2020 Apr 22
2
parse data wrong for R 4.0. raw strings
This seems like a bug to me: code <- 'x <- r"(hello, "world")"' getParseData(parse(text = code)) #> line1 col1 line2 col2 id parent token terminal text #> 7 1 1 1 24 7 0 expr FALSE #> 1 1 1 1 1 1 3 SYMBOL TRUE x #> 3 1 1 1 1 3 7 expr FALSE #...
2016 Mar 10
0
getParseData() for installed packages
On 10/03/2016 9:53 AM, Kirill M?ller wrote: > > On 10.03.2016 15:49, Duncan Murdoch wrote: > > On 10/03/2016 8:27 AM, Kirill M?ller wrote: > >> I can't seem to reliably obtain parse data via getParseData() for > >> functions from installed packages. The parse data seems to be available > >> only for the *last* file in the package. > >> > >> See [1] for a small example package with just two functions f and g in > >> two files a.R and b.R. See [2] for a do...
2015 Jul 29
2
Mapping parse tree elements to tokens
...> Michael >> >> On Wed, Jul 29, 2015 at 9:43 AM, Duncan Murdoch >> <murdoch.duncan at gmail.com> wrote: >> > On 29/07/2015 12:13 PM, Jim Hester wrote: >> >> >> >> I would like to map the parsed tokens obtained from >> >> utils::getParseData() >> >> to the parse tree and elements obtained by base::parse(). >> >> >> >> It looks like back when this code was in the parser package the parse() >> >> function annotated the elements in the tree with their id, which would >> >> allow...
2015 Jul 29
0
Mapping parse tree elements to tokens
On 29/07/2015 12:13 PM, Jim Hester wrote: > I would like to map the parsed tokens obtained from utils::getParseData() > to the parse tree and elements obtained by base::parse(). > > It looks like back when this code was in the parser package the parse() > function annotated the elements in the tree with their id, which would > allow you to perform this mapping. However when the code was included...
2020 Apr 22
1
[External] parse data wrong for R 4.0. raw strings
...es not have quoting. I can try to look into a patch. This is for 4.1 I believe, so in some sense it is not urgent? Gabor On Wed, Apr 22, 2020 at 3:31 PM <luke-tierney at uiowa.edu> wrote: > > Looks like a bug. Will have a look when I get a chance. > > Simpler version: > > getParseData(parse(text = 'r"-|hello|-"')) > > > > getParseData(parse(text = 'r"(hello)"')) > line1 col1 line2 col2 id parent token terminal text > 1 1 1 1 10 1 3 STR_CONST TRUE "hello) > 3 1 1 1 10 3...
2015 Jul 29
0
Mapping parse tree elements to tokens
...for your purposes? Duncan Murdoch > > Michael > > On Wed, Jul 29, 2015 at 9:43 AM, Duncan Murdoch > <murdoch.duncan at gmail.com> wrote: > > On 29/07/2015 12:13 PM, Jim Hester wrote: > >> > >> I would like to map the parsed tokens obtained from utils::getParseData() > >> to the parse tree and elements obtained by base::parse(). > >> > >> It looks like back when this code was in the parser package the parse() > >> function annotated the elements in the tree with their id, which would > >> allow you to perform this...
2012 Jul 18
1
Changes to parser in R-devel
...t consistent with some things already in R). One reason for the change was that the parser in the parser package was slightly different than the one in R; the hope is that by providing the services in R, it will make maintenance easier for things like code analysis, pretty printing, etc. See ?getParseData for details, and if you are maintaining a package that depends on parser, feel free to ask me for help in the transition, or make suggestions for changes if I've done something that causes you too much trouble. Duncan Murdoch P.S. to Qiang Li: as mentioned privately, the goal for this cha...
2015 Jul 29
0
Mapping parse tree elements to tokens
...t;>> On Wed, Jul 29, 2015 at 9:43 AM, Duncan Murdoch >>> <murdoch.duncan at gmail.com> wrote: >>> > On 29/07/2015 12:13 PM, Jim Hester wrote: >>> >> >>> >> I would like to map the parsed tokens obtained from >>> >> utils::getParseData() >>> >> to the parse tree and elements obtained by base::parse(). >>> >> >>> >> It looks like back when this code was in the parser package the parse() >>> >> function annotated the elements in the tree with their id, which would >>...
2020 Jan 15
4
A bug understanding F relative to FALSE?
Hi all, Is the next behaviour suitable? identical(F,FALSE) ## [1] TRUE utils::getParseData(parse(text = "c(F,FALSE)", keep.so=rce = TRUE)) ## line1 col1 line2 col2 id parent token terminal text ## 14 1 1 1 10 14 0 expr FALSE ## 1 1 1 1 1 1 3 SYMBOL_FUNCTION_CALL TRUE c ## 3 1 1 1...
2014 Dec 24
0
Inconsistent Parse Behavior
...n if I simplify the code to parse in any way.? The code as it is is a much simplified version of the code that first produced the error for me.? I cannot reduce it further without also eliminating the error. Unfortunately, the discrepancy is meaningful.? The problem is the first parse.? Looking at `getParseData` output:```> subset(getParseData(prs1), id %in% c(226, 234)) ??? line1 col1 line2 col2? id parent token terminal text 226???? 6??? 1???? 8??? 3 226??? 234? expr??? FALSE???? 234???? 9??? 5???? 9??? 5 234??? 251?? ','???? TRUE??? ,```Notice how item 226 has for parent item 234 that start...
2020 Apr 22
0
[External] parse data wrong for R 4.0. raw strings
Looks like a bug. Will have a look when I get a chance. Simpler version: getParseData(parse(text = 'r"-|hello|-"')) > getParseData(parse(text = 'r"(hello)"')) line1 col1 line2 col2 id parent token terminal text 1 1 1 1 10 1 3 STR_CONST TRUE "hello) 3 1 1 1 10 3 0 expr FALSE The...