| Crates.io | oak-idl |
| lib.rs | oak-idl |
| version | 0.0.1 |
| created_at | 2025-10-21 01:30:22.653011+00 |
| updated_at | 2026-01-23 04:29:27.900705+00 |
| description | Interface Definition Language (IDL) parser with support for CORBA and COM interface specifications. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1893099 |
| size | 99,919 |
High-performance incremental Bash parser for the oak ecosystem with flexible configuration, optimized for script analysis and automation.
Oak-bash is a robust parser for Bash, designed to handle complete Bash syntax including modern features like conditionals, loops, and functions. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for script analysis and automation.
Basic example:
use oak_bash::BashParser;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = BashParser::new();
let bash_code = r#"
#!/bin/bash
NAME="World"
echo "Hello, $NAME!"
if [ "$NAME" == "World" ]; then
echo "It's a small world."
fi
"#;
let script = parser.parse_script(bash_code)?;
println!("Parsed Bash script successfully.");
Ok(())
}
use oak_bash::{BashParser, ast::Script};
let parser = BashParser::new();
let bash_code = r#"
#!/bin/bash
echo "Hello"
"#;
let script = parser.parse_script(bash_code)?;
println!("Script contains {} commands.", script.commands.len());
use oak_bash::{BashParser, ast::Command};
let parser = BashParser::new();
let bash_code = r#"
ls -la /tmp
grep "error" /var/log/syslog
"#;
let script = parser.parse_script(bash_code)?;
for command in &script.commands {
if let Command::Simple(simple_cmd) = command {
println!("Command: {}", simple_cmd.name);
}
}
use oak_bash::{BashParser, lexer::Token};
let parser = BashParser::new();
let tokens = parser.tokenize("echo \"Hello World\"")?;
for token in tokens {
println!("{:?}", token.kind);
}
use oak_bash::BashParser;
let parser = BashParser::new();
let invalid_bash = r#"
if [ -f /tmp/file ]; then
echo "File exists"
else
echo "File does not exist"
fi_invalid
"#;
match parser.parse_script(invalid_bash) {
Ok(script) => println!("Parsed Bash script successfully."),
Err(e) => {
println!("Parse error at line {} column {}: {}",
e.line(), e.column(), e.message());
if let Some(context) = e.context() {
println!("Error context: {}", context);
}
}
}
The parser generates a comprehensive AST with the following main structures:
Oak-bash integrates seamlessly with:
Check out the examples directory for comprehensive examples:
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.