https://github.com/x86y/franca
terse rust library
https://github.com/x86y/franca
apl array bqn j k macro macros metaprogramming rust rust-macros terse
Last synced: 23 days ago
JSON representation
terse rust library
- Host: GitHub
- URL: https://github.com/x86y/franca
- Owner: x86y
- Created: 2023-06-28T09:00:24.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-02T12:27:58.000Z (over 1 year ago)
- Last Synced: 2025-02-06T05:44:59.882Z (3 months ago)
- Topics: apl, array, bqn, j, k, macro, macros, metaprogramming, rust, rust-macros, terse
- Language: Rust
- Homepage: https://x86y.github.io/franca/
- Size: 2.14 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Franca
Macros for writing terser Rust code. This crate contains both a library that exports the macros and a binary that transforms any Rust code to Rust code that uses the exported macros.Access the online demo hosted on github pages [here](https://x86y.github.io/franca).
## Example code written using Franca macros:
```rs
use franca::*;
pub struct Program {
pub p: usize,
pub a: Vec,
pub ip: usize,
pub b: Vec,
}
impl Program {
pub fn eval(&mut self, s: Sstr) {
lm!(st, vec![]; b, 0; a, &mut self.a; p, &mut self.p; ip, &mut self.ip);
l!(by, s.as_bytes());
W!(*ip < by.len(), {
l!(c, _c!(by[*ip]));
M!(c; ']', {Ic!(nz!(a[*p]), *ip = st.pop().unwrap()); b = *ip};
'[', {Ic!(z!(a[*p]), *ip = b); st.push(*ip)};
'+', ic!(a[*p]);
'-', dc!(a[*p]);
'>', ic!(*p);
'<', dc!(*p);
'.', self.b.push(a[*p]);
',', {};
_, unreachable!()
);
ic!(*ip);
})
}
}```