| Crates.io | oak-valkyrie |
| lib.rs | oak-valkyrie |
| version | 0.0.1 |
| created_at | 2025-10-21 08:17:49.578726+00 |
| updated_at | 2026-01-23 05:21:14.190876+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 | 1893426 |
| size | 357,948 |
High-performance incremental Valkyrie parser for the oak ecosystem with flexible configuration, optimized for modern systems programming with advanced type safety and concurrency features.
Oak Valkyrie is a robust parser for the Valkyrie programming language, designed to handle complete Valkyrie syntax including modern language features and advanced type system. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for Valkyrie analysis and tooling.
Basic example:
use oak_valkyrie::{ValkyrieParser, ValkyrieLanguage};
use oak_core::{Parser, source::SourceText, parser::ParseSession};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let language = ValkyrieLanguage::default();
let parser = ValkyrieParser::new(&language);
let source = SourceText::new(r#"
namespace main {
fn add(a: i32, b: i32) -> i32 {
a + b
}
}
"#);
let mut cache = ParseSession::default();
let result = parser.parse(&source, &[], &mut cache);
println!("Parsed Valkyrie module successfully.");
Ok(())
}
use oak_valkyrie::{ValkyrieParser, ValkyrieLanguage};
use oak_core::{Parser, source::SourceText, parser::ParseSession};
let language = ValkyrieLanguage::default();
let parser = ValkyrieParser::new(&language);
let source = SourceText::new(r#"
namespace math {
pub struct Point {
x: f64,
y: f64,
}
impl Point {
pub fn new(x: f64, y: f64) -> Self {
Self { x, y }
}
pub fn distance(&self, other: &Point) -> f64 {
((self.x - other.x).powi(2) + (self.y - other.y).powi(2)).sqrt()
}
}
}
"#);
let mut cache = ParseSession::default();
let result = parser.parse(&source, &[], &mut cache);
println!("Parsed Valkyrie module successfully.");
use oak_valkyrie::{ValkyrieParser, ValkyrieLanguage};
use oak_core::{Parser, source::SourceText, parser::ParseSession};
let language = ValkyrieLanguage::default();
let parser = ValkyrieParser::new(&language);
let source = SourceText::new(r#"
pub trait Drawable {
fn draw(&self);
fn area(&self) -> f64;
fn describe(&self) -> String {
format!("Shape with area: {}", self.area())
}
}
pub struct Circle {
radius: f64,
}
impl Drawable for Circle {
fn draw(&self) {
println!("Drawing circle with radius: {}", self.radius);
}
fn area(&self) -> f64 {
3.14159 * self.radius * self.radius
}
}
"#);
let mut cache = ParseSession::default();
let result = parser.parse(&source, &[], &mut cache);
println!("Parsed Valkyrie module successfully.");
use oak_valkyrie::{ValkyrieParser, ValkyrieLanguage};
use oak_core::{Parser, source::SourceText, parser::ParseSession};
let language = ValkyrieLanguage::default();
let parser = ValkyrieParser::new(&language);
let source = SourceText::new("fn main() { let x = 42; println!(\"{}\", x); }");
let mut cache = ParseSession::default();
let result = parser.parse(&source, &[], &mut cache);
// Token information is available in the parse result
use oak_valkyrie::{ValkyrieParser, ValkyrieLanguage};
use oak_core::{Parser, source::SourceText, parser::ParseSession};
let language = ValkyrieLanguage::default();
let parser = ValkyrieParser::new(&language);
let source = SourceText::new(r#"
fn broken_function() -> i32 {
let x: i32 = "not a number"; // Type mismatch
return x; // Type mismatch in return
}
fn invalid_syntax() { // Missing return type
let y = 1 // Missing semicolon
}
"#);
let mut cache = ParseSession::default();
let result = parser.parse(&source, &[], &mut cache);
if let Err(e) = result.result {
println!("Parse error: {:?}", e);
}
The parser generates a comprehensive AST with the following main structures:
Oak-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.