Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jimhester/altparsers
https://github.com/jimhester/altparsers
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jimhester/altparsers
- Owner: jimhester
- Created: 2018-06-19T20:11:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-05T14:55:51.000Z (about 6 years ago)
- Last Synced: 2024-06-12T18:18:08.092Z (7 months ago)
- Language: C
- Size: 268 KB
- Stars: 19
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# altparsers
The `altparsers` package allows the user or package developer to use
alternative parsers for R code. It provides helpers for parsing and evaluating
code and for starting a REPL with a non-standard R parser.[Ex](https://github.com/jimhester/ex) is an example package which contains code
to be used by the example parsers defined in the altparser package.The expressions returned by the parsers are valid R expressions and are
evaluated in the same way as normal R code.```{r}
library(altparsers)
repl(parser = tidy_parse_text)
#> [1, 2, 3] |> head(n = 1)
``````{r}
repl(parser = sexp_parse_text)
(= x 5)
(== x 5)
#> [1] TRUE
(+ x (* 3 5))
#> [1] 20
```## Within packages
`tidyparsers::src()` can be used within a package to source and evaluate code
written for alternative parsers. Generally this code needs to be in a
installed directory, such as `inst/r2`.```{r}
.onLoad <- function(libname, pkgname) {
altparsers::src("r2", parser = altparsers::tidy_parse_file)
}