2 releases
Uses new Rust 2024
new 0.2.5 | May 4, 2025 |
---|---|
0.2.4 | Apr 29, 2025 |
#1390 in Parser implementations
217 downloads per month
40KB
931 lines
Trees-lang
trees-lang
is the official implementation of the Trees programming language, currently supporting only parsing features. It provides tools to parse and analyze Trees code, including splitting code into characters, finding blocks, and connecting blocks.
Features
- Parse Trees code into structured blocks.
- Support for different character width modes (Mono, Half, Full).
- Error handling for compilation issues like dangling edges or multiple start blocks.
Installation
Add the following to your Cargo.toml
:
[dependencies]
trees-lang = "0.2.5"
Usage
Here is an example of how to use trees-lang
to parse and connect blocks in Trees code:
use trees_lang::compile::{split_code, find_blocks, connect_blocks, CompileConfig};
let code = vec![
" ".to_owned(),
" ┌───────┐".to_owned(),
" │ abc │ ".to_owned(),
" └───┬───┘ ".to_owned(),
" │ ".to_owned(),
" ┌───┴──┐".to_owned(),
" │ def │ ".to_owned(),
" └──────┘ ".to_owned(),
];
let splited_code = split_code(&code, &CompileConfig::DEFAULT);
let mut blocks = find_blocks(&splited_code, &CompileConfig::DEFAULT);
let head = connect_blocks(&splited_code, &mut blocks, &CompileConfig::DEFAULT).unwrap();
assert_eq!(head.proc_name, "abc".to_owned());
Documentation
Comprehensive documentation is available at docs.rs/trees-lang.
There are also wiki of Trees languages ... but in Japanese.
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests on the GitHub repository.
Author
Developed by Snowman-s.
Dependencies
~1.5MB
~22K SLoC