Skip to content
Prev 62267 / 63424 Next

[External] Re: capture "->"

That's a good suggestion, but if the function accepts strings, the 
problem is fairly easy using the parser.  E.g. compare

 > getParseData( parse(text="x1 + x2 -> a3") )
    line1 col1 line2 col2 id parent        token terminal text
11     1    1     1   13 11      0         expr    FALSE
7      1    1     1    7  7     11         expr    FALSE
1      1    1     1    2  1      3       SYMBOL     TRUE   x1
3      1    1     1    2  3      7         expr    FALSE
2      1    4     1    4  2      7          '+'     TRUE    +
4      1    6     1    7  4      6       SYMBOL     TRUE   x2
6      1    6     1    7  6      7         expr    FALSE
5      1    9     1   10  5     11 RIGHT_ASSIGN     TRUE   ->
8      1   12     1   13  8     10       SYMBOL     TRUE   a3
10     1   12     1   13 10     11         expr    FALSE

 > getParseData( parse(text="a3 <- x1 + x2") )
    line1 col1 line2 col2 id parent       token terminal text
11     1    1     1   13 11      0        expr    FALSE
1      1    1     1    2  1      3      SYMBOL     TRUE   a3
3      1    1     1    2  3     11        expr    FALSE
2      1    4     1    5  2     11 LEFT_ASSIGN     TRUE   <-
10     1    7     1   13 10     11        expr    FALSE
4      1    7     1    8  4      6      SYMBOL     TRUE   x1
6      1    7     1    8  6     10        expr    FALSE
5      1   10     1   10  5     10         '+'     TRUE    +
7      1   12     1   13  7      9      SYMBOL     TRUE   x2
9      1   12     1   13  9     10        expr    FALSE

The expressions produced are the same, but the parse data is different.

Duncan Murdoch
On 04/03/2024 11:51 a.m., Bill Dunlap wrote: