pub mod adt; pub mod comb; pub mod declaration; pub mod error; pub mod expression; mod literals; pub mod module; pub mod proc; pub mod tokens; use nom_locate::LocatedSpan; use nom::branch::alt; // custom span type for nom_locate pub type Span<'a> = LocatedSpan<&'a str>; pub type IErr = error::Error; // custom IResult type for VerboseError pub type IResult> = nom::IResult; pub use crate::parser::declaration::{ assign_statement, declaration, typename, Assign, NetDecl, TypeName, }; pub use crate::parser::expression::{expression, Call, Expression, Operation}; pub use crate::parser::module::{module, Module, ModuleItem, PortDirection}; use crate::parser::tokens::TokenSpan; pub fn parse(input: TokenSpan) -> IResult { module(input) } #[cfg(test)] mod test { use super::*; use nom::combinator::all_consuming; #[test] fn test_operation() { operation(" a | b ".into()).unwrap(); operation(" a & b ".into()).unwrap(); } #[test] fn test_expression() { expression(" a ".into()).unwrap(); expression(" a | b ".into()).unwrap(); expression(" a | b | c ".into()).unwrap(); } #[test] fn test_assignment() { // TODO: make wrapper and use for all tests all_consuming(assign_statement)(" a = b ".into()).unwrap(); all_consuming(assign_statement)(" a = b | c ".into()).unwrap(); } #[test] fn test_call() { call_item("thing ( )".into()).unwrap(); call_item("thing ( a , b , c )".into()).unwrap(); call_item("thing(a,b,c)".into()).unwrap(); } }