From c@@rd|@g@bor @end|ng |rom gm@||@com  Mon Apr 13 10:32:16 2020
From: c@@rd|@g@bor @end|ng |rom gm@||@com (=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=)
Date: Mon, 13 Apr 2020 09:32:16 +0100
Subject: [Rd] detect ->
In-Reply-To: <CAD4oTHFUe+W+bBtC-e9uhOGkJUMTV317xPETXS+7iW-v9m7iNg@mail.gmail.com>
References: <6DB118E2-8C9A-4C5D-BC82-12B689C872FF@gmail.com>
 <CABtg=KmifDz6DbufPoBX0j4Suepm3pG6K=6PoPHJ4cCXAVYafg@mail.gmail.com>
 <CAD4oTHFUe+W+bBtC-e9uhOGkJUMTV317xPETXS+7iW-v9m7iNg@mail.gmail.com>
Message-ID: <CABtg=KkwE5msPb1PyV3Lo1LgpkOtuiEv_BFEwZmswG-7Fa4ADA@mail.gmail.com>

On Mon, Apr 13, 2020 at 9:23 AM Gabriel Becker <gabembecker at 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

[...]



[Rd] detect ->
=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=