| Crates.io | oak-vhdl |
| lib.rs | oak-vhdl |
| version | 0.0.1 |
| created_at | 2025-10-21 08:19:08.994555+00 |
| updated_at | 2026-01-23 05:21:35.749445+00 |
| description | VHDL language parser with support for hardware description and digital circuit design. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1893429 |
| size | 91,629 |
High-performance incremental VHDL parser for the oak ecosystem with flexible configuration, optimized for hardware description and digital circuit design.
Oak VHDL is a robust parser for VHDL, designed to handle complete VHDL syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for hardware description and digital circuit design.
Basic example:
use oak_core::{Parser, source::SourceText, ParseSession};
use oak_vhdl::{VhdlParser, VhdlLanguage};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let language = VhdlLanguage::default();
let parser = VhdlParser::new(&language);
let mut session = ParseSession::<VhdlLanguage>::default();
let source = SourceText::new(r#"
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity counter is
Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
count : out STD_LOGIC_VECTOR (3 downto 0));
end counter;
architecture Behavioral of counter is
signal internal_count : unsigned(3 downto 0) := (others => '0');
begin
process(clk, reset)
begin
if reset = '1' then
internal_count <= (others => '0');
elsif rising_edge(clk) then
internal_count <= internal_count + 1;
end if;
end process;
count <= std_logic_vector(internal_count);
end Behavioral;
"#);
let result = parser.parse(&source, &[], &mut session);
println!("Parsed VHDL successfully.");
Ok(())
}
use oak_core::{Parser, source::SourceText, ParseSession};
use oak_vhdl::{VhdlParser, VhdlLanguage};
let language = VhdlLanguage::default();
let parser = VhdlParser::new(&language);
let mut session = ParseSession::<VhdlLanguage>::default();
let source = SourceText::new(r#"
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity full_adder is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
cin : in STD_LOGIC;
sum : out STD_LOGIC;
cout : out STD_LOGIC);
end full_adder;
"#);
let result = parser.parse(&source, &[], &mut session);
println!("Entity parsed successfully.");
use oak_core::{Parser, source::SourceText, ParseSession};
use oak_vhdl::{VhdlParser, VhdlLanguage};
let language = VhdlLanguage::default();
let parser = VhdlParser::new(&language);
let mut session = ParseSession::<VhdlLanguage>::default();
let source = SourceText::new(r#"
architecture Structural of full_adder is
begin
sum <= a xor b xor cin;
cout <= (a and b) or (cin and (a xor b));
end Structural;
"#);
let result = parser.parse(&source, &[], &mut session);
println!("Architecture parsed successfully.");
use oak_core::{Parser, source::SourceText, parser::session::ParseSession};
use oak_vhdl::{VhdlParser, VhdlLanguage};
let language = VhdlLanguage::default();
let parser = VhdlParser::new(&language);
let mut session = ParseSession::<VhdlLanguage>::default();
let source = SourceText::new(r#"
package my_types is
type state_type is (IDLE, READ, WRITE, DONE);
constant MAX_COUNT : integer := 255;
end my_types;
"#);
let result = parser.parse(&source, &[], &mut session);
println!("Package parsed successfully.");
use oak_core::{Parser, source::SourceText, parser::session::ParseSession};
use oak_vhdl::{VhdlParser, VhdlLanguage};
let language = VhdlLanguage::default();
let parser = VhdlParser::new(&language);
let mut session = ParseSession::<VhdlLanguage>::default();
let source = SourceText::new("entity Test is end Test;");
let result = parser.parse(&source, &[], &mut session);
// Token information is available in the parse result
use oak_core::{Parser, source::SourceText, parser::session::ParseSession};
use oak_vhdl::{VhdlParser, VhdlLanguage};
let language = VhdlLanguage::default();
let parser = VhdlParser::new(&language);
let mut session = ParseSession::<VhdlLanguage>::default();
let source = SourceText::new(r#"
entity Broken is
Port ( clk : in STD_LOGIC -- Missing semicolon
end Broken;
"#);
let result = parser.parse(&source, &[], &mut session);
if let Err(e) = result.result {
println!("Parse error: {:?}", e);
}
The parser generates a comprehensive AST with the following main structures:
Oak VHDL 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.