Skip to content

should the text for RIGHT_ASSIGN be -> in getParseData()?

4 messages · Yihui Xie, Peter Dalgaard, Duncan Murdoch

#
Hi,

The text column for '->' becomes '<-' in the data frame returned by
getParseData():
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     1    3  3      7 RIGHT_ASSIGN     TRUE   <-
4     1    4     1    4  4      6       SYMBOL     TRUE    x
6     1    4     1    4  6      7         expr    FALSE

Is that expected?
R version 3.0.1 (2013-05-16)
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=C                 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

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 206-667-4385 Web: http://yihui.name
Fred Hutchinson Cancer Research Center, Seattle
#
On 13-07-05 3:31 AM, Yihui Xie wrote:
It's by design, but I agree it's not ideal.  The reason for it is that 
"1 -> x" is parsed as `<-`(x, 1).  I think the parser only does 
translations like this for -> and ->>.  Currently the parser shows the 
name of the binary operator as the text.

I'll look into adding special handling for translations like this.  We 
will still parse the assignment in the same way, but the getParseData 
text could be the true text.

Duncan Murdoch
#
On Jul 5, 2013, at 13:29 , Duncan Murdoch wrote:

            
Just watch out for potential complications, e.g.
Error: could not find function "->"

so one needs to be sure that nothing will assume that the text column is a function name.
#
On 13-07-05 7:40 AM, peter dalgaard wrote:
R itself doesn't make use of the text column, it's for display of code 
by highlighters etc.  So if anyone does assume text is a function name, 
it's their bug, not ours.  In fact, the bug is already there, because 
there is actually one other example which was being parsed properly, 
"**" is translated to "^".  There's no `**` function, but 2**3 works.

Duncan Murdoch

Duncan