Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

parse_safely

Save parsing from text


Description

Parses text safely, i.e. throws an informative error if EOL style does not match LF or indicates the exact position where the parsing failed. Note that we can only detect wrong EOL style if it occurs on the first line already.

Usage

parse_safely(text, ...)

Arguments

text

Text to parse.

...

Parameters passed to base::parse()

Examples

## Not run: 
styler:::parse_safely("a + 3 -4 -> x\r\n glück + 1")
# This cannot be detected as a EOL style problem because the first
# line ends as expected with \n
styler:::parse_safely("a + 3 -4 -> x\nx + 2\r\n glück + 1")

## End(Not run)
styler:::parse_safely("a + 3 -4 -> \n glück + 1")

styler

Non-Invasive Pretty Printing of R Code

v1.4.1
MIT + file LICENSE
Authors
Kirill Müller [aut], Lorenz Walthert [cre, aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.