https://github.com/dgkf/rfmt
R parsing, formatting and linting
https://github.com/dgkf/rfmt
Last synced: about 1 month ago
JSON representation
R parsing, formatting and linting
- Host: GitHub
- URL: https://github.com/dgkf/rfmt
- Owner: dgkf
- License: gpl-3.0
- Created: 2024-09-08T23:16:03.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-09-08T23:24:04.000Z (9 months ago)
- Last Synced: 2025-03-26T12:46:08.993Z (about 2 months ago)
- Language: Rust
- Size: 17.6 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# `rfmt`
_R parsing, linting and formatting_
## Try it out
For now, we just handle the parsing of code into tokens. These tokens are
only what is emitted by the parser and might not map conveniently into R-like
_S-Expressions_.Future work may map these into a more R-like representation of the syntax tree
to make it more paletable to work with for R folks.```sh
cargo run --example parsing
```For now, you'll see a deeply nested syntax tree of parsing rules. It will
look something like this:```
Ok(
[
Pair {
rule: expr,
span: Span {
str: "f <- function(a, b = 2, c = { expression }) {\n if (a + b) {\n \"hello, world\" # return something\n } else {\n \"fizzbuzz\" # or return something else\n }\n}",
start: 122,
end: 299,
},
inner: [
Pair {
rule: prefixed,
span: Span {
str: "f ",
start: 122,
end: 124,
}
```And continues far longer than you probably care to scroll!