[Rd] Problem with parseData

Barbara Lerner blerner @ending from mtholyoke@edu
Mon Jul 30 17:35:10 CEST 2018


Hi,

I have run into a problem with parseData from the utils package.  When 
an assignment is done with = instead of <-, the information provided by 
parseData does not include an entry for the assignment.

For this input, stored in file "BadPosition.R":

y <- 5
foo = 7

And running this code:

parsed <- parse("BadPosition.R", keep.source=TRUE)
parsedData <- utils::getParseData (parsed, includeText=TRUE)
print(paste("parseData =", parsedData))

I get the following output:

[1] "parseData = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2)"
[2] "parseData = c(1, 1, 1, 3, 6, 6, 1, 1, 5, 7, 7)"
[3] "parseData = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2)"
[4] "parseData = c(6, 1, 1, 4, 6, 6, 3, 3, 5, 7, 7)"
[5] "parseData = c(7, 1, 3, 2, 4, 5, 10, 12, 11, 13, 14)"
[6] "parseData = c(0, 3, 7, 7, 5, 7, 12, 0, 0, 14, 0)"
[7] "parseData = c(\"expr\", \"SYMBOL\", \"expr\", \"LEFT_ASSIGN\", 
\"NUM_CONST\", \"expr\", \"SYMBOL\", \"expr\", \"EQ_ASSIGN\", 
\"NUM_CONST\", \"expr\")"
[8] "parseData = c(FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, 
TRUE, TRUE, FALSE)"
[9] "parseData = c(\"y <- 5\", \"y\", \"y\", \"<-\", \"5\", \"5\", 
\"foo\", \"foo\", \"=\", \"7\", \"7\")"

Notice how there is an entry for "y <- 5" beginning on line 1, column 1, 
ending at line 1, column 6, but there is no analogous entry for "foo = 7".

I am running R 3.5.0 on a Mac running 10.12.6.

Thanks for your help and please let me know if you need any further 
information.

Barbara

-- 
<http://www.getpostbox.com>Barbara Lerner
Associate Professor
Computer Science Department
Mount Holyoke College

<http://www.getpostbox.com>

	[[alternative HTML version deleted]]



More information about the R-devel mailing list