| Crates.io | oak-erlang |
| lib.rs | oak-erlang |
| version | 0.0.1 |
| created_at | 2025-10-20 16:36:17.502162+00 |
| updated_at | 2026-01-23 04:27:55.377826+00 |
| description | Erlang language parser with support for concurrent programming and OTP features. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1892307 |
| size | 88,002 |
High-performance incremental Erlang parser for the oak ecosystem with flexible configuration, optimized for static analysis and code generation.
Oak Erlang is a robust parser for Erlang, designed to handle complete Erlang syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for static analysis and code generation.
Basic example:
use oak_erlang::{Parser, ErlangLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
-module(hello).
-export([greet/0]).
greet() ->
io:format("Hello, Erlang!~n").
"#);
let result = parser.parse(&source);
println!("Parsed Erlang successfully.");
Ok(())
}
use oak_erlang::{Parser, ErlangLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
-module(math).
-export([add/2, factorial/1]).
add(A, B) ->
A + B.
factorial(0) ->
1;
factorial(N) when N > 0 ->
N * factorial(N - 1).
"#);
let result = parser.parse(&source);
println!("Function parsed successfully.");
use oak_erlang::{Parser, ErlangLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
-module(calculator).
-export([new/0, add/2, subtract/2, get_result/1]).
new() ->
0.
add(Acc, Value) ->
Acc + Value.
subtract(Acc, Value) ->
Acc - Value.
get_result(Acc) ->
Acc.
"#);
let result = parser.parse(&source);
println!("Module parsed successfully.");
use oak_erlang::{Parser, ErlangLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("X = 42.");
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_erlang::{Parser, ErlangLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
-module(broken).
-export([broken_function/0]).
broken_function() ->
io:format("Hello"
% Missing closing parenthesis
"#);
let result = parser.parse(&source);
if let Some(errors) = result.result.err() {
println!("Parse errors found: {:?}", errors);
} else {
println!("Parsed successfully.");
}
The parser generates a comprehensive AST with the following main structures:
Oak Erlang 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.