| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/string.R |
| 3 |
\name{valid_syntax} |
| 4 |
\alias{valid_syntax} |
| 5 |
\title{Check if the syntax of the code is valid} |
| 6 |
\usage{ |
| 7 |
valid_syntax(code, silent = TRUE) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{code}{A character vector of R source code.} |
| 11 |
|
| 12 |
\item{silent}{Whether to suppress the error message when the code is not |
| 13 |
valid.} |
| 14 |
} |
| 15 |
\value{ |
| 16 |
\code{TRUE} if the code could be parsed, otherwise \code{FALSE}. |
| 17 |
} |
| 18 |
\description{ |
| 19 |
Try to \code{\link[=parse]{parse()}} the code and see if an error occurs. |
| 20 |
} |
| 21 |
\examples{ |
| 22 |
xfun::valid_syntax("1+1") |
| 23 |
xfun::valid_syntax("1+") |
| 24 |
xfun::valid_syntax(c("if(T){1+1}", "else {2+2}"), silent = FALSE) |
| 25 |
} |