parse
Parse Expressions

Description

Returns an object of class "expression" that is the parsed version of the input.

Usage

parse(file = "", n = NULL, text = NULL, prompt = "?",
      keep.source = getOption("keep.source"),
      srcfile = NULL, encoding = "unknown") 

Arguments

file the file or connection object from which input to the parser should be read.
n the number of expressions to parse. If this number is negative, parsing continues to the end of the file. By default, parse reads to the end of the file or text.
text an object coerced to a character vector to use as input to the parser.
prompt any object, as the prompt for standard input. In TIBCO Enterprise Runtime for R, this argument is not implemented, and a warning is generated if it is specified.
keep.source a logical value. If TRUE, the file location information is stored with parsed expressions. This is used to print the source code for functions with the original formatting.
srcfile an object of class "srcfile". By default is NULL. In TIBCO Enterprise Runtime for R, this argument is not implemented, and a warning is generated if it is specified.
encoding the string encoding (see Encoding) to use for newly-created strings. In TIBCO Enterprise Runtime for R, this argument is not implemented. If this argument is specified, a warning is generated.

Details

Value
returns an object of mode expression containing the parsed expression(s) read.
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
See Also
eval, options, srcfile, scan, Encoding.
Examples
my.file <- tempfile("my.file")
cat("x <- 1\n y <- 2; max(x,y)\n", file = my.file)

# parse everything in my.file parse(file = my.file)

# parse the first expression in my.file parse(n=1, file = my.file)

# parse from a text string parse(text = "x <- 1\n y <- 2; max(x,y)\n")

unlink(my.file) # clean up

Package base version 4.0.0-28
Package Index