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 #> 2 1 3 1 4 2 7 LEFT_ASSIGN TRUE <- #> 4 1 6 1 24 4 6 STR_CONST TRUE "hello, "world") #> 6 1 6 1 24 6 7 expr FALSE Note that for STR_CONST, the opening delimiter is not included, but the paren from the closing delimiter is. Best, Gabor
iuke-tier@ey m@iii@g oii uiow@@edu
2020-Apr-22 14:31 UTC
[Rd] [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 opening quote probably should not be there either. More likely to get fixed sooner if someone can provide a patch. Best, luke On Wed, 22 Apr 2020, G?bor Cs?rdi wrote:> 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 > #> 2 1 3 1 4 2 7 LEFT_ASSIGN TRUE <- > #> 4 1 6 1 24 4 6 STR_CONST TRUE "hello, "world") > #> 6 1 6 1 24 6 7 expr FALSE > > Note that for STR_CONST, the opening delimiter is not included, but > the paren from the closing delimiter is. > > Best, > Gabor > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics and Fax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tierney at uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
Gábor Csárdi
2020-Apr-22 14:38 UTC
[Rd] [External] parse data wrong for R 4.0. raw strings
I don't know, maybe it would make sense to keep the whole expression, that's the text of the tag after all. Also, if we don't keep the whole expression, then it is not a valid string literal any more, because it does 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 0 expr FALSE > > The opening quote probably should not be there either. > > More likely to get fixed sooner if someone can provide a patch. > > Best, > > luke > > On Wed, 22 Apr 2020, G?bor Cs?rdi wrote: > > > 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 > > #> 2 1 3 1 4 2 7 LEFT_ASSIGN TRUE <- > > #> 4 1 6 1 24 4 6 STR_CONST TRUE "hello, "world") > > #> 6 1 6 1 24 6 7 expr FALSE > > > > Note that for STR_CONST, the opening delimiter is not included, but > > the paren from the closing delimiter is. > > > > Best, > > Gabor > > > > ______________________________________________ > > R-devel at r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > > > > -- > Luke Tierney > Ralph E. Wareham Professor of Mathematical Sciences > University of Iowa Phone: 319-335-3386 > Department of Statistics and Fax: 319-335-3017 > Actuarial Science > 241 Schaeffer Hall email: luke-tierney at uiowa.edu > Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu