fix assign item parsing

This commit is contained in:
NotAFile 2022-01-17 15:54:16 +01:00
parent 839287ec51
commit edab641506
2 changed files with 25 additions and 6 deletions

View File

@ -164,11 +164,6 @@ mod test {
use super::*; use super::*;
use nom::combinator::all_consuming; use nom::combinator::all_consuming;
#[test]
fn test_decl() {
declaration("reg abcd".into()).unwrap();
}
#[test] #[test]
fn test_operation() { fn test_operation() {
operation(" a | b ".into()).unwrap(); operation(" a | b ".into()).unwrap();

View File

@ -73,7 +73,7 @@ fn assign_item(input: Span) -> IResult<Span, Assign> {
fn module_item(input: Span) -> IResult<Span, ModuleItem> { fn module_item(input: Span) -> IResult<Span, ModuleItem> {
alt(( alt((
map(assign_statement, ModuleItem::Assign), map(assign_item, ModuleItem::Assign),
map(proc_block, ModuleItem::Proc), map(proc_block, ModuleItem::Proc),
))(input) ))(input)
} }
@ -97,3 +97,27 @@ pub fn module(input: Span) -> IResult<Span, Module> {
), ),
)(input) )(input)
} }
#[cfg(test)]
mod test {
use super::*;
use nom::combinator::all_consuming;
#[test]
fn test_decl() {
declaration("reg abcd".into()).unwrap();
}
#[test]
fn test_assignment_item() {
all_consuming(assign_item)(" assign a = b ; ".into()).unwrap();
all_consuming(assign_item)(" assign a = b | c ; ".into()).unwrap();
}
#[test]
fn test_module_item() {
all_consuming(module_item)(" assign a = b ;".into()).unwrap();
}
}