Problem with parseData

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

Problem with parseData

Barbara Lerner
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]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem with parseData

Tomas Kalibera
Dear Barbara,

thank you for the report. This is something to be fixed in R - I am now
testing a patch that adds the extra node for the equality assignment
expression.

Best,
Tomas

On 07/30/2018 05:35 PM, Barbara Lerner wrote:

> 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
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem with parseData

Tomas Kalibera
The fix is now in R-devel, 75386. I have not ported to R-patched,
because the fix breaks two packages which are working around this bug
(and to my knowledge without having reported it before). So thanks again
for the report!

Best
Tomas

On 08/16/2018 10:06 AM, Tomas Kalibera wrote:

> Dear Barbara,
>
> thank you for the report. This is something to be fixed in R - I am
> now testing a patch that adds the extra node for the equality
> assignment expression.
>
> Best,
> Tomas
>
> On 07/30/2018 05:35 PM, Barbara Lerner wrote:
>> 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
>>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem with parseData

Barbara Lerner
Thanks!  Please let us know when it is in the released version of R.

Barbara

Tomas Kalibera wrote on 10/2/18 6:37 AM:

> The fix is now in R-devel, 75386. I have not ported to R-patched,
> because the fix breaks two packages which are working around this bug
> (and to my knowledge without having reported it before). So thanks
> again for the report!
>
> Best
> Tomas
>
> On 08/16/2018 10:06 AM, Tomas Kalibera wrote:
>> Dear Barbara,
>>
>> thank you for the report. This is something to be fixed in R - I am
>> now testing a patch that adds the extra node for the equality
>> assignment expression.
>>
>> Best,
>> Tomas
>>
>> On 07/30/2018 05:35 PM, Barbara Lerner wrote:
>>> 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]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel