Oh yes, completely forgot about partial parsing. One possible (quick)
solution:
txt <- "print(2); bar <- \"don't ; use semicolons\"; foo <- '3;4'; ls("
sf <- srcfile("txt")
tryit <- tryCatch(parse(text = txt, srcfile = sf), error = identity)
gpd <- getParseData(sf)
pos <- c(0, gpd$col1[gpd$token =
On 19/09/2016 7:59 AM, Adrian Dușa wrote:
On Sun, Sep 18, 2016 at 12:34 AM, Peter Langfelder <
peter.langfel...@gmail.com> wrote:
> On Sat, Sep 17, 2016 at 2:12 PM, David Winsemius
> wrote:
> > Not entirely clear. If you were intending to just get character output
> then you could just use:
> >
On Sun, Sep 18, 2016 at 12:34 AM, Peter Langfelder <
peter.langfel...@gmail.com> wrote:
> On Sat, Sep 17, 2016 at 2:12 PM, David Winsemius
> wrote:
> > Not entirely clear. If you were intending to just get character output
> then you could just use:
> >
> > strsplit(txt, ";")
>
> You would want t
On Sat, Sep 17, 2016 at 2:12 PM, David Winsemius wrote:
>
>
> Not entirely clear. If you were intending to just get character output then
> you could just use:
>
> strsplit(txt, ";")
>
> If you wanted parsing to an R expression to occur you could pass through
> sapply and get a full accounting o
> On Sep 17, 2016, at 8:28 AM, Adrian Dușa wrote:
>
> There is one minor problem with parse(): if any of the individual commands
> has an error, the entire text will be parsed in a single error.
>
> For example, in a normal R console:
>
>> print(2); ls(
> [1] 2
> +
>
> So first print(2) is ex
There is one minor problem with parse(): if any of the individual commands
has an error, the entire text will be parsed in a single error.
For example, in a normal R console:
> print(2); ls(
[1] 2
+
So first print(2) is executed, and only after the console expects the user
to continue the comman
On Thu, Sep 15, 2016 at 10:28 PM, William Dunlap wrote:
> The most reliable way to split such lines is with parse(text=x).
> Regular expressions don't do well with context-free grammars.
>
Oh, that's right of course.
> as.character(parse(text = x))
[1] "foo <- \"3;4\"""bar <-
The most reliable way to split such lines is with parse(text=x).
Regular expressions don't do well with context-free grammars.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Sep 15, 2016 at 12:08 PM, Adrian Dușa wrote:
> Dear R-helpers,
>
> When parsing a text, I would like to separate co
Dear R-helpers,
When parsing a text, I would like to separate commands written on the same
line, by a semicolon.
Something like:
x <- "foo <- '3;4'; bar <- \"don't ; use semicolons\""
Ideally, that would translate to these two commands in a character vector
of length 2:
foo <- '3;4'
bar <- "don'
9 matches
Mail list logo