File: valid_syntax.Rd

package info (click to toggle)
r-cran-xfun 0.20-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 680 kB
  • sloc: ansic: 242; sh: 22; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 654 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/string.R
\name{valid_syntax}
\alias{valid_syntax}
\title{Check if the syntax of the code is valid}
\usage{
valid_syntax(code, silent = TRUE)
}
\arguments{
\item{code}{A character vector of R source code.}

\item{silent}{Whether to suppress the error message when the code is not
valid.}
}
\value{
\code{TRUE} if the code could be parsed, otherwise \code{FALSE}.
}
\description{
Try to \code{\link{parse}()} the code and see if an error occurs.
}
\examples{
xfun::valid_syntax("1+1")
xfun::valid_syntax("1+")
xfun::valid_syntax(c("if(T){1+1}", "else {2+2}"), silent = FALSE)
}