similar to: Recursively parsing srcrefs

Displaying 20 results from an estimated 300 matches similar to: "Recursively parsing srcrefs"

2013 Dec 13
1
Proper way to drop 'srcref' from an expression created via substitute(function() ...)?
First, why does this expression have a 'srcref' element: > exprA <- substitute(function(x) a*x, list(a=2)) > print(exprA) function(x) 2 * x > str(as.list(exprA)) List of 4 $ : symbol function $ :Dotted pair list of 1 ..$ x: symbol $ : language 2 * x $ :Class 'srcref' atomic [1:8] 1 20 1 34 20 34 1 1 .. ..- attr(*, "srcfile")=Classes
2024 May 28
1
Segfault when parsing UTF-8 text with srcrefs
On 5/28/24 19:35, Hadley Wickham wrote: > Hi all, > > When I run the following code, R segfaults: > > text <- "?" > srcfile <- srcfilecopy("test.r", text) > parse(textConnection(text), srcfile = srcfile) > > It doesn't segfault if text is ASCII, or it's not wrapped in > textConnection, or srcfile isn't set. Thanks, this is
2024 May 28
2
Segfault when parsing UTF-8 text with srcrefs
Hi all, When I run the following code, R segfaults: text <- "?" srcfile <- srcfilecopy("test.r", text) parse(textConnection(text), srcfile = srcfile) It doesn't segfault if text is ASCII, or it's not wrapped in textConnection, or srcfile isn't set. Hadley -- http://hadley.nz [[alternative HTML version deleted]]
2024 Mar 01
1
capture "->"
Dear Duncan, On Fri, Mar 1, 2024 at 11:30?AM Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > ... > If you parse it with srcrefs, you could look at the source. The parser > doesn't record whether it was A -> B or B <- A anywhere else. > Thank you, this gets me closer but it still needs a little push: > foo <- function(x) { x <- substitute(x)
2024 May 30
1
[External] Re: Segfault when parsing UTF-8 text with srcrefs
I get an R error and no segfault: > parse(textConnection(text), srcfile = srcfile) Error in parse(textConnection(text), srcfile = srcfile) : test.r:1:1: unexpected $end 1: ? ^ This is R 4.3.0, so maybe the bug has been introduced since then... Version and system info: > version _ platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system
2024 Mar 01
1
capture "->"
On 01/03/2024 5:25 a.m., Dmitri Popavenko wrote: > Dear?Duncan, > > On Fri, Mar 1, 2024 at 11:30?AM Duncan Murdoch <murdoch.duncan at gmail.com > <mailto:murdoch.duncan at gmail.com>> wrote: > > ... > If you parse it with srcrefs, you could look at the source.? The parser > doesn't record whether it was A -> B or B <- A anywhere else.
2024 Mar 01
1
capture "->"
On Fri, Mar 1, 2024 at 1:00?PM Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > ... > I was thinking more of you doing something like > > parse(text = "A -> B", keep.source = TRUE) > > I forget what the exact rules are for attaching srcrefs to arguments of > functions, but I do remember they are a little strange, because not > every possible
2024 Mar 01
1
capture "->"
On 01/03/2024 8:51 a.m., Dmitri Popavenko wrote: > On Fri, Mar 1, 2024 at 1:00?PM Duncan Murdoch <murdoch.duncan at gmail.com > <mailto:murdoch.duncan at gmail.com>> wrote: > > ... > I was thinking more of you doing something like > > ? parse(text = "A -> B", keep.source = TRUE) > > I forget what the exact rules are for
2024 Mar 01
1
capture "->"
I am wondering what the specific need for this is or is it just an exercise? Where does it matter if a chunk of code assigns using "<-" beforehand or "->" after hand, or for that matter assigns indirectly without a symbol? And whatever you come up with, will it also support the global assignment of "->>" as compared to ""<<-" too? I
2024 Mar 01
1
capture "->"
I would also be interested in that. For me, this is interesting for my QCA package, over which Dmitri and I have exchanged a couple of messages. The "<-" operator is used to denote necessity, and the "->" is used for sufficiency. Users often make use of Boolean expressions such as A*B + C -> Y (to calculate if the expression A*B + C is sufficient for the outcome Y)
2016 Mar 10
2
getParseData() for installed packages
On 10.03.2016 15:49, Duncan Murdoch wrote: > On 10/03/2016 8:27 AM, Kirill M?ller wrote: >> I can't seem to reliably obtain parse data via getParseData() for >> functions from installed packages. The parse data seems to be available >> only for the *last* file in the package. >> >> See [1] for a small example package with just two functions f and g in >>
2015 Oct 12
2
identical(..., ignore.environment=TRUE)
On 11/10/2015 10:36 PM, Duncan Murdoch wrote: > On 11/10/2015 8:05 PM, Ben Bolker wrote: >> >> It seems odd/inconvenient to me that the "ignore.environment" argument >> of identical() only applies to closures (which I read as 'functions' -- >> someone can enlighten me about the technical differences between >> functions and closures if they like
2015 Oct 12
2
identical(..., ignore.environment=TRUE)
On 12/10/2015 9:51 AM, Ben Bolker wrote: > Duncan Murdoch <murdoch.duncan <at> gmail.com> writes: > > BB> >>>> It seems odd/inconvenient to me that the "ignore.environment" argument >>>> of identical() only applies to closures (which I read as 'functions' -- >>>> someone can enlighten me about the technical differences
2010 Mar 12
1
problem with parse(text=quote(name))
Calling parse(text=quote(name)) or text=as.name("name") makes parse() prompt for input from the command line and then it returns a parse of the initial characters of 'name' (depending on how many characters were typed at the prompt). E.g., > parse(text=quote(myName)) ?1/3 expression(myN) attr(,"srcfile") <text> >
2024 Mar 01
1
capture "->"
On 01/03/2024 4:17 a.m., Dmitri Popavenko wrote: > Hi everyone, > > I am aware this is a parser issue, but is there any possibility to capture > the use of the inverse assignment operator into a formula? > > Something like: > >> foo <- function(x) substitute(x) > > gives: > >> foo(A -> B) > B <- A > > I wonder if there is any
2020 Sep 02
3
sys.call() 's srcref doesn't match the language
Dear R-devel, I found this behavior disturbing, if `1 + f()` is called, `sys.call()` called inside of `f` will return a quoted `f()` with a "srcref" that prints "1 + f()". I don't know which one is good but I don't think they can be correct at the same time. Here's a reproducible example: f <- function(){ sc <- sys.call() print(sc) attr(sc,
2018 Jun 18
2
incomplete results from as.character.srcref() in some cases involving quote()
Hi, The result of as,character() on 'srcref' objects doesn't have the closing ')' in some cases involving 'quote': > e4 <- quote({2+2}) > class(attr(e4, "wholeSrcref")) [1] "srcref" > as.character(attr(e4, "wholeSrcref")) [1] "e4 <- quote({2+2}" As a result printing the object also lacks it and gives an
2015 Oct 13
1
identical(..., ignore.environment=TRUE)
MM> but I don't think we'd want to MM> change all.equal.language() at this point in time Although it would be nice if all.equal looked at least at attributes of formulas so we did not get results like > form <- y ~ x1 %in% x2 > all.equal(form, terms(form)) [1] TRUE > all.equal(terms(y~x1+x2+Error(x3/x2), specials="Error"), terms(y~x1+x2+Error(x3/x2)))
2009 Feb 12
1
Why is srcref of length 6 and not 4 ?
Hello, Consider this file (/tmp/test.R) : <file> f <- function( x, y = 2 ){ z <- x + y print( z ) } </file> I get this in R 2.7.2 : > p <- parse( "/tmp/test.R" ) > str( attr( p, "srcref" ) ) List of 1 $ :Class 'srcref' atomic [1:4] 1 1 4 1 .. ..- attr(*, "srcfile")=Class 'srcfile' length 4 <environment>
2012 Jul 05
1
Extracting srcref for S4 methods
Hi, on R version 2.15.1 (2012-06-22) (Platform: i686-pc-linux-gnu (32-bit)) sourced functions have srcref attached as an attribute. Are such data also available for S4 generics and methods? How? (See sample code below) Thank you. Bests, Renaud f <- textConnection( " f <- function(){} setGeneric('myfun', function(x, ...) standardGeneric('myfun'))