On Mon, Apr 13, 2020 at 9:23 AM Gabriel Becker <gabembec...@gmail.com> wrote:
[...]
> This means the only feasible way to detect it, which a few projects do I 
> believe, is process the code while it is still raw text, before it goes into 
> the parser, and have clever enough regular expressions.

Well, especially considering R's news raw strings with user defined
delimiters, regular expressions are not the best here, I think. OTOH
the source references do keep the right assignment. So if you can
re-parse the data, you can detect them:

❯ x <- parse(text = "A -> B", keep.source=FALSE)
❯ x
expression(B <- A)

❯ x <- parse(text = "A -> B")
❯ x
expression(A -> B)

❯ getParseData(x)
  line1 col1 line2 col2 id parent        token terminal text
7     1    1     1    6  7      0         expr    FALSE
1     1    1     1    1  1      3       SYMBOL     TRUE    A
3     1    1     1    1  3      7         expr    FALSE
2     1    3     1    4  2      7 RIGHT_ASSIGN     TRUE   ->
4     1    6     1    6  4      6       SYMBOL     TRUE    B
6     1    6     1    6  6      7         expr    FALSE

Gabor

[...]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to