[Rd] parse():ing a unclosed string

Henrik Bengtsson
Sun, 14 Aug 2005 09:42:12 -0000

When parse():ing R code from *file* with a unclosed string, that is, a
string that has an open quoation mark, but not a ending one, the string
seems to be closed automagically.  Is this a "bug"?

Example:

 > code <- "x <- '123";
 > parse(text=code)           # Gives an error as expected
Error in parse(file, n, text, prompt) : parse error

 > cat(file="foo.R", code)
 > expr <- parse("foo.R")     # Closes the open string
 > print(expr)
expression(x <- "123\n")

Parsing from stdin(), that is parse(), gives an error too.

Platform: Windows XP Pro SP2, R Version 2.1.1 Patched (2005-07-20) as
well as R Version 2.2.0 Under development (unstable) (2005-07-19 r34991).

Best

Henrik Bengtsson