[Rd] parser does not catch strings without closing quote

From: William Dunlap <wdunlap_at_tibco.com>
Date: Thu, 01 Sep 2011 22:24:19 +0000

Shouldn't the parser complain about unfinished strings in files? It doesn't and will tack on a newline if there isn't one there.

> withOption <- function(optionList, expr) {

  +     oldOption <- options(optionList)
  +     on.exit(options(oldOption))
  +     expr
  + }

> cat(file=tf<-tempfile(), "\"string without closing quote\n")
> p <- withOption(list(keep.source=FALSE), parse(tf))
> p

  expression("string without closing quote\n")

> cat(file=tf<-tempfile(), "\"string with no closing quote nor newline")
> p <- withOption(list(keep.source=FALSE), parse(tf))
> p

  expression("string with no closing quote nor newline\n")

It does complain when parsing a character string with the same problem.
> p <- withOption(list(keep.source=FALSE), parse(text="\"unfinished string"))
  Error in parse(text = "\"unfinished string") :     2:0: unexpected end of input

  1. "unfinished string ^

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 01 Sep 2011 - 22:32:43 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 02 Sep 2011 - 16:00:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive