Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sogaiu/janet-unwrap
https://github.com/sogaiu/janet-unwrap
editor janet source
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/sogaiu/janet-unwrap
- Owner: sogaiu
- Created: 2023-07-21T08:27:49.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-06T13:59:09.000Z (4 months ago)
- Last Synced: 2024-09-06T16:18:32.266Z (4 months ago)
- Topics: editor, janet, source
- Language: Janet
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# janet-unwrap
Code for determining bounds for unwrapping forms in strings of Janet
source code.## Demo
Given the file `data/unwrap-input.txt` with content:
```
Name: tracev
Line: 2
Column: 10(def a
(tracev (+ 3
(- 1 2))))```
To determine the bounds of a `(tracev ...)` form wrapping the location
line 2, column 10:```
cat data/unwrap-input.txt | janet janet-unwrap/unwrap.janet
```The result should be:
```
2 3 3 23 2 11 3 22
```The first four numbers refer to the bounds of the whole `(tracev ...)`
form:```
start: line 2, column 3
end: line 3, column 23
```while the next four numbers refer to the bounds of the "wrapped" form
`(+ 3 (- 1 2))`:```
start: line 2, column 11
end: line 3, column 22
```## Usages
Below are some usages of a provided function named `find-wrap-info`.
```janet
(find-wrap-info
``
(def a
(tracev (+ 3
(- 1 2))))
``
2 10 "def")
# =>
[[1 1 3 24] [1 6 3 23]](find-wrap-info
``
(comment(+ 1 1)
# =>
2)
``
3 3 "comment")
# =>
[[1 1 7 4] [3 3 5 4]]
```## Use
The code is currently used via Emacs Lisp code in
[janet-editor-elf](https://github.com/sogaiu/janet-editor-elf) via
process invocation to aid in unwrapping content within `comment` and
`tracev` forms.