| Crates.io | oak-vlang |
| lib.rs | oak-vlang |
| version | 0.0.1 |
| created_at | 2026-01-23 05:21:52.145842+00 |
| updated_at | 2026-01-23 05:21:52.145842+00 |
| description | Valkyrie language parser with support for modern Valkyrie syntax and features. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 2063527 |
| size | 54,627 |
High-performance incremental Valkyrie parser for the oak ecosystem with flexible configuration, optimized for modern Valkyrie syntax and features.
Oak of valkyrie is a robust parser for Valkyrie, designed to handle complete Valkyrie syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for Valkyrie language processing.
Basic example:
use oak_valkyrie::ValkyrieParser;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = ValkyrieParser::new();
let valkyrie_code = r#"
module Main {
data List a = Nil | Cons a (List a)
length : List a -> Int
length Nil = 0
length (Cons _ xs) = 1 + length xs
main : IO ()
main = print (length (Cons 1 (Cons 2 (Cons 3 Nil))))
}
"#;
let module = parser.parse_module(valkyrie_code)?;
println!("Parsed Valkyrie module successfully.");
Ok(())
}
use oak_valkyrie::{ValkyrieParser, ast::Module};
let parser = ValkyrieParser::new();
let valkyrie_code = r#"
module Math {
data Nat = Zero | Succ Nat
add : Nat -> Nat -> Nat
add Zero n = n
add (Succ m) n = Succ (add m n)
multiply : Nat -> Nat -> Nat
multiply Zero _ = Zero
multiply (Succ m) n = add (multiply m n) n
}
"#;
let module = parser.parse_module(valkyrie_code)?;
println!("Declarations: {}", module.declarations.len());
println!("Functions: {}", module.functions.len());
use oak_valkyrie::{ValkyrieParser, ast::Expression};
let parser = ValkyrieParser::new();
let expression_code = r#"
let x = 42 in
let y = x * 2 in
if y > 80 then "large" else "small"
"#;
let expression = parser.parse_expression(expression_code)?;
println!("Expression type: {:?}", expression.kind);
use oak_valkyrie::{ValkyrieParser, lexer::Token};
let parser = ValkyrieParser::new();
let tokens = parser.tokenize("data List a = Nil | Cons a (List a)")?;
for token in tokens {
println!("{:?}", token.kind);
}
use oak_valkyrie::ValkyrieParser;
let parser = ValkyrieParser::new();
let invalid_valkyrie = r#"
module Broken {
data List a = Nil | Cons a List a -- Missing parentheses
bad_function : Int -> String
bad_function x = x ++ "hello" -- Type mismatch
}
"#;
match parser.parse_module(invalid_valkyrie) {
Ok(module) => println!("Parsed Valkyrie module 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 of valkyrie 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.