[Rd] parse():ing a unclosed string

Henrik Bengtsson hb at maths.lth.se
Sun Aug 14 11:42:12 CEST 2005

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"?


 > 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).


Henrik Bengtsson

More information about the R-devel mailing list