Impl nom_locate

This commit is contained in:
dalance 2019-07-09 18:08:24 +09:00
parent 7d4887c669
commit 3f8242d639
65 changed files with 1223 additions and 1091 deletions

View File

@ -12,4 +12,5 @@ edition = "2018"
[dependencies] [dependencies]
nom = "5.0.0" nom = "5.0.0"
nom_locate = { git = "https://github.com/fflorent/nom_locate" }
str-concat = "*" str-concat = "*"

View File

@ -18,3 +18,5 @@ pub use source_text::*;
pub use specify_section::*; pub use specify_section::*;
pub use udp_declaration_and_instantiation::*; pub use udp_declaration_and_instantiation::*;
pub use utils::*; pub use utils::*;
pub type Span<'a> = nom_locate::LocatedSpan<&'a str>;

View File

@ -85,7 +85,7 @@ pub enum AssertTiming {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn assertion_item(s: &str) -> IResult<&str, AssertionItem> { pub fn assertion_item(s: Span) -> IResult<Span, AssertionItem> {
alt(( alt((
map(concurrent_assertion_item, |x| AssertionItem::Concurrent(x)), map(concurrent_assertion_item, |x| AssertionItem::Concurrent(x)),
map(deferred_immediate_assertion_item, |x| { map(deferred_immediate_assertion_item, |x| {
@ -94,13 +94,13 @@ pub fn assertion_item(s: &str) -> IResult<&str, AssertionItem> {
))(s) ))(s)
} }
pub fn deferred_immediate_assertion_item(s: &str) -> IResult<&str, DeferredImmediateAssetionItem> { pub fn deferred_immediate_assertion_item(s: Span) -> IResult<Span, DeferredImmediateAssetionItem> {
let (s, x) = opt(terminated(block_identifier, symbol(":")))(s)?; let (s, x) = opt(terminated(block_identifier, symbol(":")))(s)?;
let (s, y) = deferred_immediate_assertion_statement(s)?; let (s, y) = deferred_immediate_assertion_statement(s)?;
Ok((s, DeferredImmediateAssetionItem { nodes: (x, y) })) Ok((s, DeferredImmediateAssetionItem { nodes: (x, y) }))
} }
pub fn procedural_assertion_statement(s: &str) -> IResult<&str, ProceduralAssertionStatement> { pub fn procedural_assertion_statement(s: Span) -> IResult<Span, ProceduralAssertionStatement> {
alt(( alt((
map(concurrent_assertion_statement, |x| { map(concurrent_assertion_statement, |x| {
ProceduralAssertionStatement::Concurrent(x) ProceduralAssertionStatement::Concurrent(x)
@ -114,7 +114,7 @@ pub fn procedural_assertion_statement(s: &str) -> IResult<&str, ProceduralAssert
))(s) ))(s)
} }
pub fn immediate_assertion_statement(s: &str) -> IResult<&str, ImmediateAssetionStatement> { pub fn immediate_assertion_statement(s: Span) -> IResult<Span, ImmediateAssetionStatement> {
alt(( alt((
map(simple_immediate_assertion_statement, |x| { map(simple_immediate_assertion_statement, |x| {
ImmediateAssetionStatement::Simple(x) ImmediateAssetionStatement::Simple(x)
@ -126,8 +126,8 @@ pub fn immediate_assertion_statement(s: &str) -> IResult<&str, ImmediateAssetion
} }
pub fn simple_immediate_assertion_statement( pub fn simple_immediate_assertion_statement(
s: &str, s: Span,
) -> IResult<&str, SimpleImmediateAssertionStatement> { ) -> IResult<Span, SimpleImmediateAssertionStatement> {
alt(( alt((
map(simple_immediate_assert_statement, |x| { map(simple_immediate_assert_statement, |x| {
SimpleImmediateAssertionStatement::Assert(x) SimpleImmediateAssertionStatement::Assert(x)
@ -141,7 +141,7 @@ pub fn simple_immediate_assertion_statement(
))(s) ))(s)
} }
pub fn simple_immediate_assert_statement(s: &str) -> IResult<&str, SimpleImmediateAssertStatement> { pub fn simple_immediate_assert_statement(s: Span) -> IResult<Span, SimpleImmediateAssertStatement> {
let (s, _) = symbol("assert")(s)?; let (s, _) = symbol("assert")(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
@ -150,7 +150,7 @@ pub fn simple_immediate_assert_statement(s: &str) -> IResult<&str, SimpleImmedia
Ok((s, SimpleImmediateAssertStatement { nodes: (x, y) })) Ok((s, SimpleImmediateAssertStatement { nodes: (x, y) }))
} }
pub fn simple_immediate_assume_statement(s: &str) -> IResult<&str, SimpleImmediateAssumeStatement> { pub fn simple_immediate_assume_statement(s: Span) -> IResult<Span, SimpleImmediateAssumeStatement> {
let (s, _) = symbol("assume")(s)?; let (s, _) = symbol("assume")(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
@ -159,7 +159,7 @@ pub fn simple_immediate_assume_statement(s: &str) -> IResult<&str, SimpleImmedia
Ok((s, SimpleImmediateAssumeStatement { nodes: (x, y) })) Ok((s, SimpleImmediateAssumeStatement { nodes: (x, y) }))
} }
pub fn simple_immediate_cover_statement(s: &str) -> IResult<&str, SimpleImmediateCoverStatement> { pub fn simple_immediate_cover_statement(s: Span) -> IResult<Span, SimpleImmediateCoverStatement> {
let (s, _) = symbol("cover")(s)?; let (s, _) = symbol("cover")(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
@ -169,8 +169,8 @@ pub fn simple_immediate_cover_statement(s: &str) -> IResult<&str, SimpleImmediat
} }
pub fn deferred_immediate_assertion_statement( pub fn deferred_immediate_assertion_statement(
s: &str, s: Span,
) -> IResult<&str, DeferredImmediateAssertionStatement> { ) -> IResult<Span, DeferredImmediateAssertionStatement> {
alt(( alt((
map(deferred_immediate_assert_statement, |x| { map(deferred_immediate_assert_statement, |x| {
DeferredImmediateAssertionStatement::Assert(x) DeferredImmediateAssertionStatement::Assert(x)
@ -185,8 +185,8 @@ pub fn deferred_immediate_assertion_statement(
} }
pub fn deferred_immediate_assert_statement( pub fn deferred_immediate_assert_statement(
s: &str, s: Span,
) -> IResult<&str, DeferredImmediateAssertStatement> { ) -> IResult<Span, DeferredImmediateAssertStatement> {
let (s, _) = symbol("assert")(s)?; let (s, _) = symbol("assert")(s)?;
let (s, x) = assert_timing(s)?; let (s, x) = assert_timing(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
@ -197,8 +197,8 @@ pub fn deferred_immediate_assert_statement(
} }
pub fn deferred_immediate_assume_statement( pub fn deferred_immediate_assume_statement(
s: &str, s: Span,
) -> IResult<&str, DeferredImmediateAssumeStatement> { ) -> IResult<Span, DeferredImmediateAssumeStatement> {
let (s, _) = symbol("assume")(s)?; let (s, _) = symbol("assume")(s)?;
let (s, x) = assert_timing(s)?; let (s, x) = assert_timing(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
@ -209,8 +209,8 @@ pub fn deferred_immediate_assume_statement(
} }
pub fn deferred_immediate_cover_statement( pub fn deferred_immediate_cover_statement(
s: &str, s: Span,
) -> IResult<&str, DeferredImmediateCoverStatement> { ) -> IResult<Span, DeferredImmediateCoverStatement> {
let (s, _) = symbol("cover")(s)?; let (s, _) = symbol("cover")(s)?;
let (s, x) = assert_timing(s)?; let (s, x) = assert_timing(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
@ -220,7 +220,7 @@ pub fn deferred_immediate_cover_statement(
Ok((s, DeferredImmediateCoverStatement { nodes: (x, y, z) })) Ok((s, DeferredImmediateCoverStatement { nodes: (x, y, z) }))
} }
pub fn assert_timing(s: &str) -> IResult<&str, AssertTiming> { pub fn assert_timing(s: Span) -> IResult<Span, AssertTiming> {
alt(( alt((
map(symbol("#0"), |_| AssertTiming::Zero), map(symbol("#0"), |_| AssertTiming::Zero),
map(symbol("final"), |_| AssertTiming::Final), map(symbol("final"), |_| AssertTiming::Final),

View File

@ -111,7 +111,7 @@ pub struct OpenRangeValue<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn case_statement(s: &str) -> IResult<&str, CaseStatement> { pub fn case_statement(s: Span) -> IResult<Span, CaseStatement> {
alt(( alt((
case_statement_normal, case_statement_normal,
case_statement_matches, case_statement_matches,
@ -119,7 +119,7 @@ pub fn case_statement(s: &str) -> IResult<&str, CaseStatement> {
))(s) ))(s)
} }
pub fn case_statement_normal(s: &str) -> IResult<&str, CaseStatement> { pub fn case_statement_normal(s: Span) -> IResult<Span, CaseStatement> {
let (s, x) = opt(unique_priority)(s)?; let (s, x) = opt(unique_priority)(s)?;
let (s, y) = case_keyword(s)?; let (s, y) = case_keyword(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
@ -135,7 +135,7 @@ pub fn case_statement_normal(s: &str) -> IResult<&str, CaseStatement> {
)) ))
} }
pub fn case_statement_matches(s: &str) -> IResult<&str, CaseStatement> { pub fn case_statement_matches(s: Span) -> IResult<Span, CaseStatement> {
let (s, x) = opt(unique_priority)(s)?; let (s, x) = opt(unique_priority)(s)?;
let (s, y) = case_keyword(s)?; let (s, y) = case_keyword(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
@ -152,7 +152,7 @@ pub fn case_statement_matches(s: &str) -> IResult<&str, CaseStatement> {
)) ))
} }
pub fn case_statement_inside(s: &str) -> IResult<&str, CaseStatement> { pub fn case_statement_inside(s: Span) -> IResult<Span, CaseStatement> {
let (s, x) = opt(unique_priority)(s)?; let (s, x) = opt(unique_priority)(s)?;
let (s, y) = case_keyword(s)?; let (s, y) = case_keyword(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
@ -169,7 +169,7 @@ pub fn case_statement_inside(s: &str) -> IResult<&str, CaseStatement> {
)) ))
} }
pub fn case_keyword(s: &str) -> IResult<&str, CaseKeyword> { pub fn case_keyword(s: Span) -> IResult<Span, CaseKeyword> {
alt(( alt((
map(symbol("casez"), |_| CaseKeyword::Casez), map(symbol("casez"), |_| CaseKeyword::Casez),
map(symbol("casex"), |_| CaseKeyword::Casex), map(symbol("casex"), |_| CaseKeyword::Casex),
@ -177,18 +177,18 @@ pub fn case_keyword(s: &str) -> IResult<&str, CaseKeyword> {
))(s) ))(s)
} }
pub fn case_expression(s: &str) -> IResult<&str, Expression> { pub fn case_expression(s: Span) -> IResult<Span, Expression> {
expression(s) expression(s)
} }
pub fn case_item(s: &str) -> IResult<&str, CaseItem> { pub fn case_item(s: Span) -> IResult<Span, CaseItem> {
alt(( alt((
case_item_nondefault, case_item_nondefault,
map(case_item_default, |x| CaseItem::Default(x)), map(case_item_default, |x| CaseItem::Default(x)),
))(s) ))(s)
} }
pub fn case_item_nondefault(s: &str) -> IResult<&str, CaseItem> { pub fn case_item_nondefault(s: Span) -> IResult<Span, CaseItem> {
let (s, x) = separated_nonempty_list(symbol(","), case_item_expression)(s)?; let (s, x) = separated_nonempty_list(symbol(","), case_item_expression)(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
let (s, y) = statement_or_null(s)?; let (s, y) = statement_or_null(s)?;
@ -198,21 +198,21 @@ pub fn case_item_nondefault(s: &str) -> IResult<&str, CaseItem> {
)) ))
} }
pub fn case_item_default(s: &str) -> IResult<&str, CaseItemDefault> { pub fn case_item_default(s: Span) -> IResult<Span, CaseItemDefault> {
let (s, _) = symbol("default")(s)?; let (s, _) = symbol("default")(s)?;
let (s, _) = opt(symbol(":"))(s)?; let (s, _) = opt(symbol(":"))(s)?;
let (s, x) = statement_or_null(s)?; let (s, x) = statement_or_null(s)?;
Ok((s, CaseItemDefault { nodes: (x,) })) Ok((s, CaseItemDefault { nodes: (x,) }))
} }
pub fn case_pattern_item(s: &str) -> IResult<&str, CasePatternItem> { pub fn case_pattern_item(s: Span) -> IResult<Span, CasePatternItem> {
alt(( alt((
case_pattern_item_nondefault, case_pattern_item_nondefault,
map(case_item_default, |x| CasePatternItem::Default(x)), map(case_item_default, |x| CasePatternItem::Default(x)),
))(s) ))(s)
} }
pub fn case_pattern_item_nondefault(s: &str) -> IResult<&str, CasePatternItem> { pub fn case_pattern_item_nondefault(s: Span) -> IResult<Span, CasePatternItem> {
let (s, x) = pattern(s)?; let (s, x) = pattern(s)?;
let (s, y) = opt(preceded(symbol("&&&"), expression))(s)?; let (s, y) = opt(preceded(symbol("&&&"), expression))(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
@ -223,14 +223,14 @@ pub fn case_pattern_item_nondefault(s: &str) -> IResult<&str, CasePatternItem> {
)) ))
} }
pub fn case_inside_item(s: &str) -> IResult<&str, CaseInsideItem> { pub fn case_inside_item(s: Span) -> IResult<Span, CaseInsideItem> {
alt(( alt((
case_inside_item_nondefault, case_inside_item_nondefault,
map(case_item_default, |x| CaseInsideItem::Default(x)), map(case_item_default, |x| CaseInsideItem::Default(x)),
))(s) ))(s)
} }
pub fn case_inside_item_nondefault(s: &str) -> IResult<&str, CaseInsideItem> { pub fn case_inside_item_nondefault(s: Span) -> IResult<Span, CaseInsideItem> {
let (s, x) = open_range_list(s)?; let (s, x) = open_range_list(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
let (s, y) = statement_or_null(s)?; let (s, y) = statement_or_null(s)?;
@ -240,28 +240,28 @@ pub fn case_inside_item_nondefault(s: &str) -> IResult<&str, CaseInsideItem> {
)) ))
} }
pub fn case_item_expression(s: &str) -> IResult<&str, Expression> { pub fn case_item_expression(s: Span) -> IResult<Span, Expression> {
expression(s) expression(s)
} }
pub fn randcase_statement(s: &str) -> IResult<&str, RandcaseStatement> { pub fn randcase_statement(s: Span) -> IResult<Span, RandcaseStatement> {
let (s, _) = symbol("randcase")(s)?; let (s, _) = symbol("randcase")(s)?;
let (s, x) = many1(randcase_item)(s)?; let (s, x) = many1(randcase_item)(s)?;
let (s, _) = symbol("endcase")(s)?; let (s, _) = symbol("endcase")(s)?;
Ok((s, RandcaseStatement { nodes: (x,) })) Ok((s, RandcaseStatement { nodes: (x,) }))
} }
pub fn randcase_item(s: &str) -> IResult<&str, RandcaseItem> { pub fn randcase_item(s: Span) -> IResult<Span, RandcaseItem> {
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
let (s, y) = statement_or_null(s)?; let (s, y) = statement_or_null(s)?;
Ok((s, RandcaseItem { nodes: (x, y) })) Ok((s, RandcaseItem { nodes: (x, y) }))
} }
pub fn open_range_list(s: &str) -> IResult<&str, Vec<ValueRange>> { pub fn open_range_list(s: Span) -> IResult<Span, Vec<ValueRange>> {
separated_nonempty_list(symbol(","), open_value_range)(s) separated_nonempty_list(symbol(","), open_value_range)(s)
} }
pub fn open_value_range(s: &str) -> IResult<&str, ValueRange> { pub fn open_value_range(s: Span) -> IResult<Span, ValueRange> {
value_range(s) value_range(s)
} }

View File

@ -103,11 +103,11 @@ pub enum CycleDelay<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn clocking_declaration(s: &str) -> IResult<&str, ClockingDeclaration> { pub fn clocking_declaration(s: Span) -> IResult<Span, ClockingDeclaration> {
alt((clocking_declaration_local, clocking_declaration_global))(s) alt((clocking_declaration_local, clocking_declaration_global))(s)
} }
pub fn clocking_declaration_local(s: &str) -> IResult<&str, ClockingDeclaration> { pub fn clocking_declaration_local(s: Span) -> IResult<Span, ClockingDeclaration> {
let (s, x) = opt(symbol("default"))(s)?; let (s, x) = opt(symbol("default"))(s)?;
let (s, _) = symbol("clocking")(s)?; let (s, _) = symbol("clocking")(s)?;
let (s, y) = opt(clocking_identifier)(s)?; let (s, y) = opt(clocking_identifier)(s)?;
@ -124,7 +124,7 @@ pub fn clocking_declaration_local(s: &str) -> IResult<&str, ClockingDeclaration>
)) ))
} }
pub fn clocking_declaration_global(s: &str) -> IResult<&str, ClockingDeclaration> { pub fn clocking_declaration_global(s: Span) -> IResult<Span, ClockingDeclaration> {
let (s, _) = opt(symbol("global"))(s)?; let (s, _) = opt(symbol("global"))(s)?;
let (s, _) = symbol("clocking")(s)?; let (s, _) = symbol("clocking")(s)?;
let (s, x) = opt(clocking_identifier)(s)?; let (s, x) = opt(clocking_identifier)(s)?;
@ -138,7 +138,7 @@ pub fn clocking_declaration_global(s: &str) -> IResult<&str, ClockingDeclaration
)) ))
} }
pub fn clocking_event(s: &str) -> IResult<&str, ClockingEvent> { pub fn clocking_event(s: Span) -> IResult<Span, ClockingEvent> {
alt(( alt((
map(preceded(symbol("@"), identifier), |x| { map(preceded(symbol("@"), identifier), |x| {
ClockingEvent::Identifier(x) ClockingEvent::Identifier(x)
@ -149,7 +149,7 @@ pub fn clocking_event(s: &str) -> IResult<&str, ClockingEvent> {
))(s) ))(s)
} }
pub fn clocking_item(s: &str) -> IResult<&str, ClockingItem> { pub fn clocking_item(s: Span) -> IResult<Span, ClockingItem> {
alt(( alt((
clocking_item_default_skew, clocking_item_default_skew,
clocking_item_direction, clocking_item_direction,
@ -157,14 +157,14 @@ pub fn clocking_item(s: &str) -> IResult<&str, ClockingItem> {
))(s) ))(s)
} }
pub fn clocking_item_default_skew(s: &str) -> IResult<&str, ClockingItem> { pub fn clocking_item_default_skew(s: Span) -> IResult<Span, ClockingItem> {
let (s, _) = symbol("default")(s)?; let (s, _) = symbol("default")(s)?;
let (s, x) = default_skew(s)?; let (s, x) = default_skew(s)?;
let (s, _) = symbol(";")(s)?; let (s, _) = symbol(";")(s)?;
Ok((s, ClockingItem::DefaultSkew(x))) Ok((s, ClockingItem::DefaultSkew(x)))
} }
pub fn clocking_item_direction(s: &str) -> IResult<&str, ClockingItem> { pub fn clocking_item_direction(s: Span) -> IResult<Span, ClockingItem> {
let (s, x) = clocking_direction(s)?; let (s, x) = clocking_direction(s)?;
let (s, y) = list_of_clocking_decl_assign(s)?; let (s, y) = list_of_clocking_decl_assign(s)?;
Ok(( Ok((
@ -173,7 +173,7 @@ pub fn clocking_item_direction(s: &str) -> IResult<&str, ClockingItem> {
)) ))
} }
pub fn clocking_item_assertion(s: &str) -> IResult<&str, ClockingItem> { pub fn clocking_item_assertion(s: Span) -> IResult<Span, ClockingItem> {
let (s, x) = many0(attribute_instance)(s)?; let (s, x) = many0(attribute_instance)(s)?;
let (s, y) = assertion_item_declaration(s)?; let (s, y) = assertion_item_declaration(s)?;
Ok(( Ok((
@ -182,7 +182,7 @@ pub fn clocking_item_assertion(s: &str) -> IResult<&str, ClockingItem> {
)) ))
} }
pub fn default_skew(s: &str) -> IResult<&str, DefaultSkew> { pub fn default_skew(s: Span) -> IResult<Span, DefaultSkew> {
alt(( alt((
default_skew_input, default_skew_input,
default_skew_output, default_skew_output,
@ -190,19 +190,19 @@ pub fn default_skew(s: &str) -> IResult<&str, DefaultSkew> {
))(s) ))(s)
} }
pub fn default_skew_input(s: &str) -> IResult<&str, DefaultSkew> { pub fn default_skew_input(s: Span) -> IResult<Span, DefaultSkew> {
let (s, _) = symbol("input")(s)?; let (s, _) = symbol("input")(s)?;
let (s, x) = clocking_skew(s)?; let (s, x) = clocking_skew(s)?;
Ok((s, DefaultSkew::Input(x))) Ok((s, DefaultSkew::Input(x)))
} }
pub fn default_skew_output(s: &str) -> IResult<&str, DefaultSkew> { pub fn default_skew_output(s: Span) -> IResult<Span, DefaultSkew> {
let (s, _) = symbol("output")(s)?; let (s, _) = symbol("output")(s)?;
let (s, x) = clocking_skew(s)?; let (s, x) = clocking_skew(s)?;
Ok((s, DefaultSkew::Output(x))) Ok((s, DefaultSkew::Output(x)))
} }
pub fn default_skew_input_output(s: &str) -> IResult<&str, DefaultSkew> { pub fn default_skew_input_output(s: Span) -> IResult<Span, DefaultSkew> {
let (s, _) = symbol("input")(s)?; let (s, _) = symbol("input")(s)?;
let (s, x) = clocking_skew(s)?; let (s, x) = clocking_skew(s)?;
let (s, _) = symbol("output")(s)?; let (s, _) = symbol("output")(s)?;
@ -210,7 +210,7 @@ pub fn default_skew_input_output(s: &str) -> IResult<&str, DefaultSkew> {
Ok((s, DefaultSkew::InputOutput((x, y)))) Ok((s, DefaultSkew::InputOutput((x, y))))
} }
pub fn clocking_direction(s: &str) -> IResult<&str, ClockingDirection> { pub fn clocking_direction(s: Span) -> IResult<Span, ClockingDirection> {
alt(( alt((
clocking_direction_input, clocking_direction_input,
clocking_direction_output, clocking_direction_output,
@ -219,19 +219,19 @@ pub fn clocking_direction(s: &str) -> IResult<&str, ClockingDirection> {
))(s) ))(s)
} }
pub fn clocking_direction_input(s: &str) -> IResult<&str, ClockingDirection> { pub fn clocking_direction_input(s: Span) -> IResult<Span, ClockingDirection> {
let (s, _) = symbol("input")(s)?; let (s, _) = symbol("input")(s)?;
let (s, x) = opt(clocking_skew)(s)?; let (s, x) = opt(clocking_skew)(s)?;
Ok((s, ClockingDirection::Input(x))) Ok((s, ClockingDirection::Input(x)))
} }
pub fn clocking_direction_output(s: &str) -> IResult<&str, ClockingDirection> { pub fn clocking_direction_output(s: Span) -> IResult<Span, ClockingDirection> {
let (s, _) = symbol("output")(s)?; let (s, _) = symbol("output")(s)?;
let (s, x) = opt(clocking_skew)(s)?; let (s, x) = opt(clocking_skew)(s)?;
Ok((s, ClockingDirection::Output(x))) Ok((s, ClockingDirection::Output(x)))
} }
pub fn clocking_direction_input_output(s: &str) -> IResult<&str, ClockingDirection> { pub fn clocking_direction_input_output(s: Span) -> IResult<Span, ClockingDirection> {
let (s, _) = symbol("input")(s)?; let (s, _) = symbol("input")(s)?;
let (s, x) = opt(clocking_skew)(s)?; let (s, x) = opt(clocking_skew)(s)?;
let (s, _) = symbol("output")(s)?; let (s, _) = symbol("output")(s)?;
@ -239,37 +239,37 @@ pub fn clocking_direction_input_output(s: &str) -> IResult<&str, ClockingDirecti
Ok((s, ClockingDirection::InputOutput((x, y)))) Ok((s, ClockingDirection::InputOutput((x, y))))
} }
pub fn clocking_direction_inout(s: &str) -> IResult<&str, ClockingDirection> { pub fn clocking_direction_inout(s: Span) -> IResult<Span, ClockingDirection> {
let (s, _) = symbol("inout")(s)?; let (s, _) = symbol("inout")(s)?;
Ok((s, ClockingDirection::Inout)) Ok((s, ClockingDirection::Inout))
} }
pub fn list_of_clocking_decl_assign(s: &str) -> IResult<&str, Vec<ClockingDeclAssign>> { pub fn list_of_clocking_decl_assign(s: Span) -> IResult<Span, Vec<ClockingDeclAssign>> {
many1(clocking_decl_assign)(s) many1(clocking_decl_assign)(s)
} }
pub fn clocking_decl_assign(s: &str) -> IResult<&str, ClockingDeclAssign> { pub fn clocking_decl_assign(s: Span) -> IResult<Span, ClockingDeclAssign> {
let (s, x) = signal_identifier(s)?; let (s, x) = signal_identifier(s)?;
let (s, y) = opt(preceded(symbol("="), expression))(s)?; let (s, y) = opt(preceded(symbol("="), expression))(s)?;
Ok((s, ClockingDeclAssign { nodes: (x, y) })) Ok((s, ClockingDeclAssign { nodes: (x, y) }))
} }
pub fn clocking_skew(s: &str) -> IResult<&str, ClockingSkew> { pub fn clocking_skew(s: Span) -> IResult<Span, ClockingSkew> {
alt((clocking_skew_edge, clocking_skew_delay))(s) alt((clocking_skew_edge, clocking_skew_delay))(s)
} }
pub fn clocking_skew_edge(s: &str) -> IResult<&str, ClockingSkew> { pub fn clocking_skew_edge(s: Span) -> IResult<Span, ClockingSkew> {
let (s, x) = edge_identifier(s)?; let (s, x) = edge_identifier(s)?;
let (s, y) = opt(delay_control)(s)?; let (s, y) = opt(delay_control)(s)?;
Ok((s, ClockingSkew::Edge((x, y)))) Ok((s, ClockingSkew::Edge((x, y))))
} }
pub fn clocking_skew_delay(s: &str) -> IResult<&str, ClockingSkew> { pub fn clocking_skew_delay(s: Span) -> IResult<Span, ClockingSkew> {
let (s, x) = delay_control(s)?; let (s, x) = delay_control(s)?;
Ok((s, ClockingSkew::Delay(x))) Ok((s, ClockingSkew::Delay(x)))
} }
pub fn clocking_drive(s: &str) -> IResult<&str, ClockingDrive> { pub fn clocking_drive(s: Span) -> IResult<Span, ClockingDrive> {
let (s, x) = clockvar_expression(s)?; let (s, x) = clockvar_expression(s)?;
let (s, _) = symbol("=")(s)?; let (s, _) = symbol("=")(s)?;
let (s, y) = opt(cycle_delay)(s)?; let (s, y) = opt(cycle_delay)(s)?;
@ -277,7 +277,7 @@ pub fn clocking_drive(s: &str) -> IResult<&str, ClockingDrive> {
Ok((s, ClockingDrive { nodes: (x, y, z) })) Ok((s, ClockingDrive { nodes: (x, y, z) }))
} }
pub fn cycle_delay(s: &str) -> IResult<&str, CycleDelay> { pub fn cycle_delay(s: Span) -> IResult<Span, CycleDelay> {
alt(( alt((
map(preceded(symbol("##"), integral_number), |x| { map(preceded(symbol("##"), integral_number), |x| {
CycleDelay::IntegralNumber(x) CycleDelay::IntegralNumber(x)
@ -291,11 +291,11 @@ pub fn cycle_delay(s: &str) -> IResult<&str, CycleDelay> {
))(s) ))(s)
} }
pub fn clockvar(s: &str) -> IResult<&str, HierarchicalIdentifier> { pub fn clockvar(s: Span) -> IResult<Span, HierarchicalIdentifier> {
hierarchical_identifier(s) hierarchical_identifier(s)
} }
pub fn clockvar_expression(s: &str) -> IResult<&str, (HierarchicalIdentifier, Select)> { pub fn clockvar_expression(s: Span) -> IResult<Span, (HierarchicalIdentifier, Select)> {
pair(clockvar, select)(s) pair(clockvar, select)(s)
} }

View File

@ -47,7 +47,7 @@ pub struct CondPattern<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn conditional_statement(s: &str) -> IResult<&str, ConditionalStatement> { pub fn conditional_statement(s: Span) -> IResult<Span, ConditionalStatement> {
let (s, x) = opt(unique_priority)(s)?; let (s, x) = opt(unique_priority)(s)?;
let (s, _) = symbol("if")(s)?; let (s, _) = symbol("if")(s)?;
let (s, y) = conditional_statement_body(s)?; let (s, y) = conditional_statement_body(s)?;
@ -65,7 +65,7 @@ pub fn conditional_statement(s: &str) -> IResult<&str, ConditionalStatement> {
)) ))
} }
pub fn conditional_statement_body(s: &str) -> IResult<&str, ConditionalStatementBody> { pub fn conditional_statement_body(s: Span) -> IResult<Span, ConditionalStatementBody> {
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = cond_predicate(s)?; let (s, x) = cond_predicate(s)?;
let (s, _) = symbol(")")(s)?; let (s, _) = symbol(")")(s)?;
@ -74,7 +74,7 @@ pub fn conditional_statement_body(s: &str) -> IResult<&str, ConditionalStatement
Ok((s, ConditionalStatementBody { nodes: (x, y) })) Ok((s, ConditionalStatementBody { nodes: (x, y) }))
} }
pub fn unique_priority(s: &str) -> IResult<&str, UniquePriority> { pub fn unique_priority(s: Span) -> IResult<Span, UniquePriority> {
alt(( alt((
map(symbol("unique0"), |_| UniquePriority::Unique0), map(symbol("unique0"), |_| UniquePriority::Unique0),
map(symbol("unique"), |_| UniquePriority::Unique), map(symbol("unique"), |_| UniquePriority::Unique),
@ -82,19 +82,19 @@ pub fn unique_priority(s: &str) -> IResult<&str, UniquePriority> {
))(s) ))(s)
} }
pub fn cond_predicate(s: &str) -> IResult<&str, CondPredicate> { pub fn cond_predicate(s: Span) -> IResult<Span, CondPredicate> {
let (s, x) = separated_nonempty_list(symbol("&&&"), expression_or_cond_pattern)(s)?; let (s, x) = separated_nonempty_list(symbol("&&&"), expression_or_cond_pattern)(s)?;
Ok((s, CondPredicate { nodes: (x,) })) Ok((s, CondPredicate { nodes: (x,) }))
} }
pub fn expression_or_cond_pattern(s: &str) -> IResult<&str, ExpressionOrCondPattern> { pub fn expression_or_cond_pattern(s: Span) -> IResult<Span, ExpressionOrCondPattern> {
alt(( alt((
map(expression, |x| ExpressionOrCondPattern::Expression(x)), map(expression, |x| ExpressionOrCondPattern::Expression(x)),
map(cond_pattern, |x| ExpressionOrCondPattern::CondPattern(x)), map(cond_pattern, |x| ExpressionOrCondPattern::CondPattern(x)),
))(s) ))(s)
} }
pub fn cond_pattern(s: &str) -> IResult<&str, CondPattern> { pub fn cond_pattern(s: Span) -> IResult<Span, CondPattern> {
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
let (s, _) = symbol("matches")(s)?; let (s, _) = symbol("matches")(s)?;
let (s, y) = pattern(s)?; let (s, y) = pattern(s)?;

View File

@ -39,11 +39,11 @@ pub struct NetAssignment<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn continuous_assign(s: &str) -> IResult<&str, ContinuousAssign> { pub fn continuous_assign(s: Span) -> IResult<Span, ContinuousAssign> {
alt((continuous_assign_net, continuous_assign_variable))(s) alt((continuous_assign_net, continuous_assign_variable))(s)
} }
pub fn continuous_assign_net(s: &str) -> IResult<&str, ContinuousAssign> { pub fn continuous_assign_net(s: Span) -> IResult<Span, ContinuousAssign> {
let (s, _) = symbol("assign")(s)?; let (s, _) = symbol("assign")(s)?;
let (s, x) = opt(drive_strength)(s)?; let (s, x) = opt(drive_strength)(s)?;
let (s, y) = opt(delay3)(s)?; let (s, y) = opt(delay3)(s)?;
@ -56,7 +56,7 @@ pub fn continuous_assign_net(s: &str) -> IResult<&str, ContinuousAssign> {
)) ))
} }
pub fn continuous_assign_variable(s: &str) -> IResult<&str, ContinuousAssign> { pub fn continuous_assign_variable(s: Span) -> IResult<Span, ContinuousAssign> {
let (s, _) = symbol("assign")(s)?; let (s, _) = symbol("assign")(s)?;
let (s, x) = opt(delay_control)(s)?; let (s, x) = opt(delay_control)(s)?;
let (s, y) = list_of_variable_assignments(s)?; let (s, y) = list_of_variable_assignments(s)?;
@ -68,15 +68,15 @@ pub fn continuous_assign_variable(s: &str) -> IResult<&str, ContinuousAssign> {
)) ))
} }
pub fn list_of_net_assignments(s: &str) -> IResult<&str, Vec<NetAssignment>> { pub fn list_of_net_assignments(s: Span) -> IResult<Span, Vec<NetAssignment>> {
separated_nonempty_list(symbol(","), net_assignment)(s) separated_nonempty_list(symbol(","), net_assignment)(s)
} }
pub fn list_of_variable_assignments(s: &str) -> IResult<&str, Vec<VariableAssignment>> { pub fn list_of_variable_assignments(s: Span) -> IResult<Span, Vec<VariableAssignment>> {
separated_nonempty_list(symbol(","), variable_assignment)(s) separated_nonempty_list(symbol(","), variable_assignment)(s)
} }
pub fn net_alias(s: &str) -> IResult<&str, NetAlias> { pub fn net_alias(s: Span) -> IResult<Span, NetAlias> {
let (s, _) = symbol("alias")(s)?; let (s, _) = symbol("alias")(s)?;
let (s, x) = net_lvalue(s)?; let (s, x) = net_lvalue(s)?;
let (s, y) = many1(preceded(symbol("="), net_lvalue))(s)?; let (s, y) = many1(preceded(symbol("="), net_lvalue))(s)?;
@ -84,7 +84,7 @@ pub fn net_alias(s: &str) -> IResult<&str, NetAlias> {
Ok((s, NetAlias { nodes: (x, y) })) Ok((s, NetAlias { nodes: (x, y) }))
} }
pub fn net_assignment(s: &str) -> IResult<&str, NetAssignment> { pub fn net_assignment(s: Span) -> IResult<Span, NetAssignment> {
let (s, x) = net_lvalue(s)?; let (s, x) = net_lvalue(s)?;
let (s, _) = symbol("=")(s)?; let (s, _) = symbol("=")(s)?;
let (s, y) = expression(s)?; let (s, y) = expression(s)?;

View File

@ -88,7 +88,7 @@ pub struct LoopVariables<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn loop_statement(s: &str) -> IResult<&str, LoopStatement> { pub fn loop_statement(s: Span) -> IResult<Span, LoopStatement> {
alt(( alt((
loop_statement_forever, loop_statement_forever,
loop_statement_repeat, loop_statement_repeat,
@ -99,7 +99,7 @@ pub fn loop_statement(s: &str) -> IResult<&str, LoopStatement> {
))(s) ))(s)
} }
pub fn loop_statement_forever(s: &str) -> IResult<&str, LoopStatement> { pub fn loop_statement_forever(s: Span) -> IResult<Span, LoopStatement> {
let (s, _) = symbol("forever")(s)?; let (s, _) = symbol("forever")(s)?;
let (s, x) = statement_or_null(s)?; let (s, x) = statement_or_null(s)?;
Ok(( Ok((
@ -108,7 +108,7 @@ pub fn loop_statement_forever(s: &str) -> IResult<&str, LoopStatement> {
)) ))
} }
pub fn loop_statement_repeat(s: &str) -> IResult<&str, LoopStatement> { pub fn loop_statement_repeat(s: Span) -> IResult<Span, LoopStatement> {
let (s, _) = symbol("repeat")(s)?; let (s, _) = symbol("repeat")(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
@ -120,7 +120,7 @@ pub fn loop_statement_repeat(s: &str) -> IResult<&str, LoopStatement> {
)) ))
} }
pub fn loop_statement_while(s: &str) -> IResult<&str, LoopStatement> { pub fn loop_statement_while(s: Span) -> IResult<Span, LoopStatement> {
let (s, _) = symbol("while")(s)?; let (s, _) = symbol("while")(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
@ -132,7 +132,7 @@ pub fn loop_statement_while(s: &str) -> IResult<&str, LoopStatement> {
)) ))
} }
pub fn loop_statement_for(s: &str) -> IResult<&str, LoopStatement> { pub fn loop_statement_for(s: Span) -> IResult<Span, LoopStatement> {
let (s, _) = symbol("for")(s)?; let (s, _) = symbol("for")(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = opt(for_initialization)(s)?; let (s, x) = opt(for_initialization)(s)?;
@ -150,7 +150,7 @@ pub fn loop_statement_for(s: &str) -> IResult<&str, LoopStatement> {
)) ))
} }
pub fn loop_statement_do_while(s: &str) -> IResult<&str, LoopStatement> { pub fn loop_statement_do_while(s: Span) -> IResult<Span, LoopStatement> {
let (s, _) = symbol("do")(s)?; let (s, _) = symbol("do")(s)?;
let (s, x) = statement_or_null(s)?; let (s, x) = statement_or_null(s)?;
let (s, _) = symbol("while")(s)?; let (s, _) = symbol("while")(s)?;
@ -164,7 +164,7 @@ pub fn loop_statement_do_while(s: &str) -> IResult<&str, LoopStatement> {
)) ))
} }
pub fn loop_statement_foreach(s: &str) -> IResult<&str, LoopStatement> { pub fn loop_statement_foreach(s: Span) -> IResult<Span, LoopStatement> {
let (s, _) = symbol("foreach")(s)?; let (s, _) = symbol("foreach")(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = ps_or_hierarchical_array_identifier(s)?; let (s, x) = ps_or_hierarchical_array_identifier(s)?;
@ -179,7 +179,7 @@ pub fn loop_statement_foreach(s: &str) -> IResult<&str, LoopStatement> {
)) ))
} }
pub fn for_initialization(s: &str) -> IResult<&str, ForInitialization> { pub fn for_initialization(s: Span) -> IResult<Span, ForInitialization> {
alt(( alt((
map(list_of_variable_assignments, |x| { map(list_of_variable_assignments, |x| {
ForInitialization::Assignment(x) ForInitialization::Assignment(x)
@ -191,7 +191,7 @@ pub fn for_initialization(s: &str) -> IResult<&str, ForInitialization> {
))(s) ))(s)
} }
pub fn for_variable_declaration(s: &str) -> IResult<&str, ForVariableDeclaration> { pub fn for_variable_declaration(s: Span) -> IResult<Span, ForVariableDeclaration> {
let (s, x) = opt(symbol("var"))(s)?; let (s, x) = opt(symbol("var"))(s)?;
let (s, y) = data_type(s)?; let (s, y) = data_type(s)?;
let (s, z) = separated_nonempty_list( let (s, z) = separated_nonempty_list(
@ -206,11 +206,11 @@ pub fn for_variable_declaration(s: &str) -> IResult<&str, ForVariableDeclaration
)) ))
} }
pub fn for_step(s: &str) -> IResult<&str, Vec<ForStepAssignment>> { pub fn for_step(s: Span) -> IResult<Span, Vec<ForStepAssignment>> {
separated_nonempty_list(symbol(","), for_step_assignment)(s) separated_nonempty_list(symbol(","), for_step_assignment)(s)
} }
pub fn for_step_assignment(s: &str) -> IResult<&str, ForStepAssignment> { pub fn for_step_assignment(s: Span) -> IResult<Span, ForStepAssignment> {
alt(( alt((
map(operator_assignment, |x| ForStepAssignment::Operator(x)), map(operator_assignment, |x| ForStepAssignment::Operator(x)),
map(inc_or_dec_expression, |x| ForStepAssignment::IncOrDec(x)), map(inc_or_dec_expression, |x| ForStepAssignment::IncOrDec(x)),
@ -220,7 +220,7 @@ pub fn for_step_assignment(s: &str) -> IResult<&str, ForStepAssignment> {
))(s) ))(s)
} }
pub fn loop_variables(s: &str) -> IResult<&str, LoopVariables> { pub fn loop_variables(s: Span) -> IResult<Span, LoopVariables> {
let (s, x) = separated_nonempty_list(symbol(","), opt(index_variable_identifier))(s)?; let (s, x) = separated_nonempty_list(symbol(","), opt(index_variable_identifier))(s)?;
Ok((s, LoopVariables { nodes: (x,) })) Ok((s, LoopVariables { nodes: (x,) }))
} }

View File

@ -48,21 +48,21 @@ pub enum JoinKeyword {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn action_block(s: &str) -> IResult<&str, ActionBlock> { pub fn action_block(s: Span) -> IResult<Span, ActionBlock> {
alt(( alt((
map(statement_or_null, |x| ActionBlock::Statement(x)), map(statement_or_null, |x| ActionBlock::Statement(x)),
action_block_else, action_block_else,
))(s) ))(s)
} }
pub fn action_block_else(s: &str) -> IResult<&str, ActionBlock> { pub fn action_block_else(s: Span) -> IResult<Span, ActionBlock> {
let (s, x) = opt(statement)(s)?; let (s, x) = opt(statement)(s)?;
let (s, _) = symbol("else")(s)?; let (s, _) = symbol("else")(s)?;
let (s, y) = statement_or_null(s)?; let (s, y) = statement_or_null(s)?;
Ok((s, ActionBlock::Else(ActionBlockElse { nodes: (x, y) }))) Ok((s, ActionBlock::Else(ActionBlockElse { nodes: (x, y) })))
} }
pub fn seq_block(s: &str) -> IResult<&str, SeqBlock> { pub fn seq_block(s: Span) -> IResult<Span, SeqBlock> {
let (s, _) = symbol("begin")(s)?; let (s, _) = symbol("begin")(s)?;
let (s, x) = opt(preceded(symbol(":"), block_identifier))(s)?; let (s, x) = opt(preceded(symbol(":"), block_identifier))(s)?;
let (s, y) = many0(block_item_declaration)(s)?; let (s, y) = many0(block_item_declaration)(s)?;
@ -77,7 +77,7 @@ pub fn seq_block(s: &str) -> IResult<&str, SeqBlock> {
)) ))
} }
pub fn par_block(s: &str) -> IResult<&str, ParBlock> { pub fn par_block(s: Span) -> IResult<Span, ParBlock> {
let (s, _) = symbol("fork")(s)?; let (s, _) = symbol("fork")(s)?;
let (s, x) = opt(preceded(symbol(":"), block_identifier))(s)?; let (s, x) = opt(preceded(symbol(":"), block_identifier))(s)?;
let (s, y) = many0(block_item_declaration)(s)?; let (s, y) = many0(block_item_declaration)(s)?;
@ -92,7 +92,7 @@ pub fn par_block(s: &str) -> IResult<&str, ParBlock> {
)) ))
} }
pub fn join_keyword(s: &str) -> IResult<&str, JoinKeyword> { pub fn join_keyword(s: Span) -> IResult<Span, JoinKeyword> {
alt(( alt((
map(symbol("join_any"), |_| JoinKeyword::JoinAny), map(symbol("join_any"), |_| JoinKeyword::JoinAny),
map(symbol("join_none"), |_| JoinKeyword::JoinNone), map(symbol("join_none"), |_| JoinKeyword::JoinNone),

View File

@ -71,7 +71,7 @@ pub struct AssignmentPatternVariableLvalue<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn pattern(s: &str) -> IResult<&str, Pattern> { pub fn pattern(s: Span) -> IResult<Span, Pattern> {
alt(( alt((
map(preceded(symbol("."), variable_identifier), |x| { map(preceded(symbol("."), variable_identifier), |x| {
Pattern::VariableIdentifier(Box::new(x)) Pattern::VariableIdentifier(Box::new(x))
@ -98,7 +98,7 @@ pub fn pattern(s: &str) -> IResult<&str, Pattern> {
))(s) ))(s)
} }
pub fn assignment_pattern(s: &str) -> IResult<&str, AssignmentPattern> { pub fn assignment_pattern(s: Span) -> IResult<Span, AssignmentPattern> {
alt(( alt((
map( map(
apostrophe_brace(separated_nonempty_list(symbol(","), expression)), apostrophe_brace(separated_nonempty_list(symbol(","), expression)),
@ -128,7 +128,7 @@ pub fn assignment_pattern(s: &str) -> IResult<&str, AssignmentPattern> {
))(s) ))(s)
} }
pub fn structure_pattern_key(s: &str) -> IResult<&str, StructurePatternKey> { pub fn structure_pattern_key(s: Span) -> IResult<Span, StructurePatternKey> {
alt(( alt((
map(member_identifier, |x| StructurePatternKey::Identifier(x)), map(member_identifier, |x| StructurePatternKey::Identifier(x)),
map(assignment_pattern_key, |x| { map(assignment_pattern_key, |x| {
@ -137,29 +137,29 @@ pub fn structure_pattern_key(s: &str) -> IResult<&str, StructurePatternKey> {
))(s) ))(s)
} }
pub fn array_pattern_key(s: &str) -> IResult<&str, ArrayPatternKey> { pub fn array_pattern_key(s: Span) -> IResult<Span, ArrayPatternKey> {
alt(( alt((
map(constant_expression, |x| ArrayPatternKey::Expression(x)), map(constant_expression, |x| ArrayPatternKey::Expression(x)),
map(assignment_pattern_key, |x| ArrayPatternKey::PatternKey(x)), map(assignment_pattern_key, |x| ArrayPatternKey::PatternKey(x)),
))(s) ))(s)
} }
pub fn assignment_pattern_key(s: &str) -> IResult<&str, AssignmentPatternKey> { pub fn assignment_pattern_key(s: Span) -> IResult<Span, AssignmentPatternKey> {
alt(( alt((
map(simple_type, |x| AssignmentPatternKey::SimpleType(x)), map(simple_type, |x| AssignmentPatternKey::SimpleType(x)),
map(symbol("default"), |_| AssignmentPatternKey::Default), map(symbol("default"), |_| AssignmentPatternKey::Default),
))(s) ))(s)
} }
pub fn assignment_pattern_expression(s: &str) -> IResult<&str, AssignmentPatternExpression> { pub fn assignment_pattern_expression(s: Span) -> IResult<Span, AssignmentPatternExpression> {
let (s, x) = opt(assignment_pattern_expression_type)(s)?; let (s, x) = opt(assignment_pattern_expression_type)(s)?;
let (s, y) = assignment_pattern(s)?; let (s, y) = assignment_pattern(s)?;
Ok((s, AssignmentPatternExpression { nodes: (x, y) })) Ok((s, AssignmentPatternExpression { nodes: (x, y) }))
} }
pub fn assignment_pattern_expression_type( pub fn assignment_pattern_expression_type(
s: &str, s: Span,
) -> IResult<&str, AssignmentPatternExpressionType> { ) -> IResult<Span, AssignmentPatternExpressionType> {
alt(( alt((
map(ps_type_identifier, |x| { map(ps_type_identifier, |x| {
AssignmentPatternExpressionType::Type(x) AssignmentPatternExpressionType::Type(x)
@ -177,19 +177,19 @@ pub fn assignment_pattern_expression_type(
} }
pub fn constant_assignment_pattern_expression( pub fn constant_assignment_pattern_expression(
s: &str, s: Span,
) -> IResult<&str, AssignmentPatternExpression> { ) -> IResult<Span, AssignmentPatternExpression> {
assignment_pattern_expression(s) assignment_pattern_expression(s)
} }
pub fn assignment_pattern_net_lvalue(s: &str) -> IResult<&str, AssignmentPatternNetLvalue> { pub fn assignment_pattern_net_lvalue(s: Span) -> IResult<Span, AssignmentPatternNetLvalue> {
let (s, x) = apostrophe_brace(separated_nonempty_list(symbol(","), net_lvalue))(s)?; let (s, x) = apostrophe_brace(separated_nonempty_list(symbol(","), net_lvalue))(s)?;
Ok((s, AssignmentPatternNetLvalue { nodes: (x,) })) Ok((s, AssignmentPatternNetLvalue { nodes: (x,) }))
} }
pub fn assignment_pattern_variable_lvalue( pub fn assignment_pattern_variable_lvalue(
s: &str, s: Span,
) -> IResult<&str, AssignmentPatternVariableLvalue> { ) -> IResult<Span, AssignmentPatternVariableLvalue> {
let (s, x) = apostrophe_brace(separated_nonempty_list(symbol(","), variable_lvalue))(s)?; let (s, x) = apostrophe_brace(separated_nonempty_list(symbol(","), variable_lvalue))(s)?;
Ok((s, AssignmentPatternVariableLvalue { nodes: (x,) })) Ok((s, AssignmentPatternVariableLvalue { nodes: (x,) }))
} }

View File

@ -59,7 +59,12 @@ pub struct BlockingAssignmentHierarchicalVariable<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct OperatorAssignment<'a> { pub struct OperatorAssignment<'a> {
pub nodes: (VariableLvalue<'a>, Operator<'a>, Expression<'a>), pub nodes: (VariableLvalue<'a>, AssignmentOperator<'a>, Expression<'a>),
}
#[derive(Debug)]
pub struct AssignmentOperator<'a> {
pub nodes: (Symbol<'a>,),
} }
#[derive(Debug)] #[derive(Debug)]
@ -88,19 +93,19 @@ pub struct VariableAssignment<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn initial_construct(s: &str) -> IResult<&str, InitialConstruct> { pub fn initial_construct(s: Span) -> IResult<Span, InitialConstruct> {
let (s, _) = symbol("initial")(s)?; let (s, _) = symbol("initial")(s)?;
let (s, x) = statement_or_null(s)?; let (s, x) = statement_or_null(s)?;
Ok((s, InitialConstruct { nodes: (x,) })) Ok((s, InitialConstruct { nodes: (x,) }))
} }
pub fn always_construct(s: &str) -> IResult<&str, AlwaysConstruct> { pub fn always_construct(s: Span) -> IResult<Span, AlwaysConstruct> {
let (s, x) = always_keyword(s)?; let (s, x) = always_keyword(s)?;
let (s, y) = statement(s)?; let (s, y) = statement(s)?;
Ok((s, AlwaysConstruct { nodes: (x, y) })) Ok((s, AlwaysConstruct { nodes: (x, y) }))
} }
pub fn always_keyword(s: &str) -> IResult<&str, AlwaysKeyword> { pub fn always_keyword(s: Span) -> IResult<Span, AlwaysKeyword> {
alt(( alt((
map(symbol("always_comb"), |_| AlwaysKeyword::AlwaysComb), map(symbol("always_comb"), |_| AlwaysKeyword::AlwaysComb),
map(symbol("always_latch"), |_| AlwaysKeyword::AlwaysLatch), map(symbol("always_latch"), |_| AlwaysKeyword::AlwaysLatch),
@ -109,13 +114,13 @@ pub fn always_keyword(s: &str) -> IResult<&str, AlwaysKeyword> {
))(s) ))(s)
} }
pub fn final_construct(s: &str) -> IResult<&str, FinalConstruct> { pub fn final_construct(s: Span) -> IResult<Span, FinalConstruct> {
let (s, _) = symbol("final")(s)?; let (s, _) = symbol("final")(s)?;
let (s, x) = function_statement(s)?; let (s, x) = function_statement(s)?;
Ok((s, FinalConstruct { nodes: (x,) })) Ok((s, FinalConstruct { nodes: (x,) }))
} }
pub fn blocking_assignment(s: &str) -> IResult<&str, BlockingAssignment> { pub fn blocking_assignment(s: Span) -> IResult<Span, BlockingAssignment> {
alt(( alt((
blocking_assignment_variable, blocking_assignment_variable,
blocking_assignment_nonrange_variable, blocking_assignment_nonrange_variable,
@ -124,7 +129,7 @@ pub fn blocking_assignment(s: &str) -> IResult<&str, BlockingAssignment> {
))(s) ))(s)
} }
pub fn blocking_assignment_variable(s: &str) -> IResult<&str, BlockingAssignment> { pub fn blocking_assignment_variable(s: Span) -> IResult<Span, BlockingAssignment> {
let (s, x) = variable_lvalue(s)?; let (s, x) = variable_lvalue(s)?;
let (s, _) = symbol("=")(s)?; let (s, _) = symbol("=")(s)?;
let (s, y) = delay_or_event_control(s)?; let (s, y) = delay_or_event_control(s)?;
@ -135,7 +140,7 @@ pub fn blocking_assignment_variable(s: &str) -> IResult<&str, BlockingAssignment
)) ))
} }
pub fn blocking_assignment_nonrange_variable(s: &str) -> IResult<&str, BlockingAssignment> { pub fn blocking_assignment_nonrange_variable(s: Span) -> IResult<Span, BlockingAssignment> {
let (s, x) = nonrange_variable_lvalue(s)?; let (s, x) = nonrange_variable_lvalue(s)?;
let (s, _) = symbol("=")(s)?; let (s, _) = symbol("=")(s)?;
let (s, y) = dynamic_array_new(s)?; let (s, y) = dynamic_array_new(s)?;
@ -145,7 +150,7 @@ pub fn blocking_assignment_nonrange_variable(s: &str) -> IResult<&str, BlockingA
)) ))
} }
pub fn blocking_assignment_hierarchical_variable(s: &str) -> IResult<&str, BlockingAssignment> { pub fn blocking_assignment_hierarchical_variable(s: Span) -> IResult<Span, BlockingAssignment> {
let (s, x) = opt(implicit_class_handle_or_class_scope_or_package_scope)(s)?; let (s, x) = opt(implicit_class_handle_or_class_scope_or_package_scope)(s)?;
let (s, y) = hierarchical_variable_identifier(s)?; let (s, y) = hierarchical_variable_identifier(s)?;
let (s, z) = select(s)?; let (s, z) = select(s)?;
@ -159,32 +164,32 @@ pub fn blocking_assignment_hierarchical_variable(s: &str) -> IResult<&str, Block
)) ))
} }
pub fn operator_assignment(s: &str) -> IResult<&str, OperatorAssignment> { pub fn operator_assignment(s: Span) -> IResult<Span, OperatorAssignment> {
let (s, x) = variable_lvalue(s)?; let (s, x) = variable_lvalue(s)?;
let (s, y) = assignment_operator(s)?; let (s, y) = assignment_operator(s)?;
let (s, z) = expression(s)?; let (s, z) = expression(s)?;
Ok((s, OperatorAssignment { nodes: (x, y, z) })) Ok((s, OperatorAssignment { nodes: (x, y, z) }))
} }
pub fn assignment_operator(s: &str) -> IResult<&str, Operator> { pub fn assignment_operator(s: Span) -> IResult<Span, AssignmentOperator> {
alt(( alt((
map(symbol("="), |x| Operator { nodes: (x,) }), map(symbol("="), |x| AssignmentOperator { nodes: (x,) }),
map(symbol("+="), |x| Operator { nodes: (x,) }), map(symbol("+="), |x| AssignmentOperator { nodes: (x,) }),
map(symbol("-="), |x| Operator { nodes: (x,) }), map(symbol("-="), |x| AssignmentOperator { nodes: (x,) }),
map(symbol("*="), |x| Operator { nodes: (x,) }), map(symbol("*="), |x| AssignmentOperator { nodes: (x,) }),
map(symbol("/="), |x| Operator { nodes: (x,) }), map(symbol("/="), |x| AssignmentOperator { nodes: (x,) }),
map(symbol("%="), |x| Operator { nodes: (x,) }), map(symbol("%="), |x| AssignmentOperator { nodes: (x,) }),
map(symbol("&="), |x| Operator { nodes: (x,) }), map(symbol("&="), |x| AssignmentOperator { nodes: (x,) }),
map(symbol("|="), |x| Operator { nodes: (x,) }), map(symbol("|="), |x| AssignmentOperator { nodes: (x,) }),
map(symbol("^="), |x| Operator { nodes: (x,) }), map(symbol("^="), |x| AssignmentOperator { nodes: (x,) }),
map(symbol("<<<="), |x| Operator { nodes: (x,) }), map(symbol("<<<="), |x| AssignmentOperator { nodes: (x,) }),
map(symbol(">>>="), |x| Operator { nodes: (x,) }), map(symbol(">>>="), |x| AssignmentOperator { nodes: (x,) }),
map(symbol("<<="), |x| Operator { nodes: (x,) }), map(symbol("<<="), |x| AssignmentOperator { nodes: (x,) }),
map(symbol(">>="), |x| Operator { nodes: (x,) }), map(symbol(">>="), |x| AssignmentOperator { nodes: (x,) }),
))(s) ))(s)
} }
pub fn nonblocking_assignment(s: &str) -> IResult<&str, NonblockingAssignment> { pub fn nonblocking_assignment(s: Span) -> IResult<Span, NonblockingAssignment> {
let (s, x) = variable_lvalue(s)?; let (s, x) = variable_lvalue(s)?;
let (s, _) = symbol("<=")(s)?; let (s, _) = symbol("<=")(s)?;
let (s, y) = opt(delay_or_event_control)(s)?; let (s, y) = opt(delay_or_event_control)(s)?;
@ -192,7 +197,7 @@ pub fn nonblocking_assignment(s: &str) -> IResult<&str, NonblockingAssignment> {
Ok((s, NonblockingAssignment { nodes: (x, y, z) })) Ok((s, NonblockingAssignment { nodes: (x, y, z) }))
} }
pub fn procedural_continuous_assignment(s: &str) -> IResult<&str, ProceduralContinuousAssignment> { pub fn procedural_continuous_assignment(s: Span) -> IResult<Span, ProceduralContinuousAssignment> {
alt(( alt((
map(preceded(symbol("assign"), variable_assignment), |x| { map(preceded(symbol("assign"), variable_assignment), |x| {
ProceduralContinuousAssignment::Assign(x) ProceduralContinuousAssignment::Assign(x)
@ -215,7 +220,7 @@ pub fn procedural_continuous_assignment(s: &str) -> IResult<&str, ProceduralCont
))(s) ))(s)
} }
pub fn variable_assignment(s: &str) -> IResult<&str, VariableAssignment> { pub fn variable_assignment(s: Span) -> IResult<Span, VariableAssignment> {
let (s, x) = variable_lvalue(s)?; let (s, x) = variable_lvalue(s)?;
let (s, _) = symbol("=")(s)?; let (s, _) = symbol("=")(s)?;
let (s, y) = expression(s)?; let (s, y) = expression(s)?;

View File

@ -100,7 +100,7 @@ pub struct RsCaseItemNondefault<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn randsequence_statement(s: &str) -> IResult<&str, RandsequenceStatement> { pub fn randsequence_statement(s: Span) -> IResult<Span, RandsequenceStatement> {
let (s, _) = symbol("randsequence")(s)?; let (s, _) = symbol("randsequence")(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = opt(production_identifier)(s)?; let (s, x) = opt(production_identifier)(s)?;
@ -110,7 +110,7 @@ pub fn randsequence_statement(s: &str) -> IResult<&str, RandsequenceStatement> {
Ok((s, RandsequenceStatement { nodes: (x, y) })) Ok((s, RandsequenceStatement { nodes: (x, y) }))
} }
pub fn production(s: &str) -> IResult<&str, Production> { pub fn production(s: Span) -> IResult<Span, Production> {
let (s, x) = opt(data_type_or_void)(s)?; let (s, x) = opt(data_type_or_void)(s)?;
let (s, y) = production_identifier(s)?; let (s, y) = production_identifier(s)?;
let (s, z) = opt(paren(tf_port_list))(s)?; let (s, z) = opt(paren(tf_port_list))(s)?;
@ -125,7 +125,7 @@ pub fn production(s: &str) -> IResult<&str, Production> {
)) ))
} }
pub fn rs_rule(s: &str) -> IResult<&str, RsRule> { pub fn rs_rule(s: Span) -> IResult<Span, RsRule> {
let (s, x) = rs_production_list(s)?; let (s, x) = rs_production_list(s)?;
let (s, y) = opt(preceded( let (s, y) = opt(preceded(
symbol(":="), symbol(":="),
@ -140,16 +140,16 @@ pub fn rs_rule(s: &str) -> IResult<&str, RsRule> {
Ok((s, RsRule { nodes: (x, y, z) })) Ok((s, RsRule { nodes: (x, y, z) }))
} }
pub fn rs_production_list(s: &str) -> IResult<&str, RsProductionList> { pub fn rs_production_list(s: Span) -> IResult<Span, RsProductionList> {
alt((rs_production_list_prod, rs_production_list_join))(s) alt((rs_production_list_prod, rs_production_list_join))(s)
} }
pub fn rs_production_list_prod(s: &str) -> IResult<&str, RsProductionList> { pub fn rs_production_list_prod(s: Span) -> IResult<Span, RsProductionList> {
let (s, x) = many1(rs_prod)(s)?; let (s, x) = many1(rs_prod)(s)?;
Ok((s, RsProductionList::Prod(x))) Ok((s, RsProductionList::Prod(x)))
} }
pub fn rs_production_list_join(s: &str) -> IResult<&str, RsProductionList> { pub fn rs_production_list_join(s: Span) -> IResult<Span, RsProductionList> {
let (s, _) = symbol("rand")(s)?; let (s, _) = symbol("rand")(s)?;
let (s, _) = symbol("join")(s)?; let (s, _) = symbol("join")(s)?;
let (s, x) = opt(paren(expression))(s)?; let (s, x) = opt(paren(expression))(s)?;
@ -163,7 +163,7 @@ pub fn rs_production_list_join(s: &str) -> IResult<&str, RsProductionList> {
Ok((s, RsProductionList::Join((x, y)))) Ok((s, RsProductionList::Join((x, y))))
} }
pub fn weight_specification(s: &str) -> IResult<&str, WeightSpecification> { pub fn weight_specification(s: Span) -> IResult<Span, WeightSpecification> {
alt(( alt((
map(integral_number, |x| WeightSpecification::IntegralNumber(x)), map(integral_number, |x| WeightSpecification::IntegralNumber(x)),
map(ps_identifier, |x| WeightSpecification::PsIdentifier(x)), map(ps_identifier, |x| WeightSpecification::PsIdentifier(x)),
@ -171,7 +171,7 @@ pub fn weight_specification(s: &str) -> IResult<&str, WeightSpecification> {
))(s) ))(s)
} }
pub fn rs_code_block(s: &str) -> IResult<&str, RsCodeBlock> { pub fn rs_code_block(s: Span) -> IResult<Span, RsCodeBlock> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, x) = many0(data_declaration)(s)?; let (s, x) = many0(data_declaration)(s)?;
let (s, y) = many0(statement_or_null)(s)?; let (s, y) = many0(statement_or_null)(s)?;
@ -179,7 +179,7 @@ pub fn rs_code_block(s: &str) -> IResult<&str, RsCodeBlock> {
Ok((s, RsCodeBlock { nodes: (x, y) })) Ok((s, RsCodeBlock { nodes: (x, y) }))
} }
pub fn rs_prod(s: &str) -> IResult<&str, RsProd> { pub fn rs_prod(s: Span) -> IResult<Span, RsProd> {
alt(( alt((
map(production_item, |x| RsProd::Item(x)), map(production_item, |x| RsProd::Item(x)),
map(rs_code_block, |x| RsProd::CodeBlock(x)), map(rs_code_block, |x| RsProd::CodeBlock(x)),
@ -189,13 +189,13 @@ pub fn rs_prod(s: &str) -> IResult<&str, RsProd> {
))(s) ))(s)
} }
pub fn production_item(s: &str) -> IResult<&str, ProductionItem> { pub fn production_item(s: Span) -> IResult<Span, ProductionItem> {
let (s, x) = production_identifier(s)?; let (s, x) = production_identifier(s)?;
let (s, y) = opt(paren(list_of_arguments))(s)?; let (s, y) = opt(paren(list_of_arguments))(s)?;
Ok((s, ProductionItem { nodes: (x, y) })) Ok((s, ProductionItem { nodes: (x, y) }))
} }
pub fn rs_if_else(s: &str) -> IResult<&str, RsIfElse> { pub fn rs_if_else(s: Span) -> IResult<Span, RsIfElse> {
let (s, _) = symbol("if")(s)?; let (s, _) = symbol("if")(s)?;
let (s, x) = paren(expression)(s)?; let (s, x) = paren(expression)(s)?;
let (s, y) = production_item(s)?; let (s, y) = production_item(s)?;
@ -203,25 +203,25 @@ pub fn rs_if_else(s: &str) -> IResult<&str, RsIfElse> {
Ok((s, RsIfElse { nodes: (x, y, z) })) Ok((s, RsIfElse { nodes: (x, y, z) }))
} }
pub fn rs_repeat(s: &str) -> IResult<&str, RsRepeat> { pub fn rs_repeat(s: Span) -> IResult<Span, RsRepeat> {
let (s, _) = symbol("repeat")(s)?; let (s, _) = symbol("repeat")(s)?;
let (s, x) = paren(expression)(s)?; let (s, x) = paren(expression)(s)?;
let (s, y) = production_item(s)?; let (s, y) = production_item(s)?;
Ok((s, RsRepeat { nodes: (x, y) })) Ok((s, RsRepeat { nodes: (x, y) }))
} }
pub fn rs_case(s: &str) -> IResult<&str, RsCase> { pub fn rs_case(s: Span) -> IResult<Span, RsCase> {
let (s, _) = symbol("case")(s)?; let (s, _) = symbol("case")(s)?;
let (s, x) = paren(case_expression)(s)?; let (s, x) = paren(case_expression)(s)?;
let (s, y) = many1(rs_case_item)(s)?; let (s, y) = many1(rs_case_item)(s)?;
Ok((s, RsCase { nodes: (x, y) })) Ok((s, RsCase { nodes: (x, y) }))
} }
pub fn rs_case_item(s: &str) -> IResult<&str, RsCaseItem> { pub fn rs_case_item(s: Span) -> IResult<Span, RsCaseItem> {
alt((rs_case_item_nondefault, rs_case_item_default))(s) alt((rs_case_item_nondefault, rs_case_item_default))(s)
} }
pub fn rs_case_item_nondefault(s: &str) -> IResult<&str, RsCaseItem> { pub fn rs_case_item_nondefault(s: Span) -> IResult<Span, RsCaseItem> {
let (s, x) = separated_nonempty_list(symbol(","), case_item_expression)(s)?; let (s, x) = separated_nonempty_list(symbol(","), case_item_expression)(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
let (s, y) = production_item(s)?; let (s, y) = production_item(s)?;
@ -232,7 +232,7 @@ pub fn rs_case_item_nondefault(s: &str) -> IResult<&str, RsCaseItem> {
)) ))
} }
pub fn rs_case_item_default(s: &str) -> IResult<&str, RsCaseItem> { pub fn rs_case_item_default(s: Span) -> IResult<Span, RsCaseItem> {
let (s, _) = symbol("default")(s)?; let (s, _) = symbol("default")(s)?;
let (s, _) = opt(symbol(":"))(s)?; let (s, _) = opt(symbol(":"))(s)?;
let (s, x) = production_item(s)?; let (s, x) = production_item(s)?;

View File

@ -64,7 +64,7 @@ pub struct VariableIdentifierList<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn statement_or_null(s: &str) -> IResult<&str, StatementOrNull> { pub fn statement_or_null(s: Span) -> IResult<Span, StatementOrNull> {
alt(( alt((
map(statement, |x| StatementOrNull::Statement(x)), map(statement, |x| StatementOrNull::Statement(x)),
map(terminated(many0(attribute_instance), symbol(";")), |x| { map(terminated(many0(attribute_instance), symbol(";")), |x| {
@ -73,14 +73,14 @@ pub fn statement_or_null(s: &str) -> IResult<&str, StatementOrNull> {
))(s) ))(s)
} }
pub fn statement(s: &str) -> IResult<&str, Statement> { pub fn statement(s: Span) -> IResult<Span, Statement> {
let (s, x) = opt(terminated(block_identifier, symbol(":")))(s)?; let (s, x) = opt(terminated(block_identifier, symbol(":")))(s)?;
let (s, y) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, z) = statement_item(s)?; let (s, z) = statement_item(s)?;
Ok((s, Statement { nodes: (x, y, z) })) Ok((s, Statement { nodes: (x, y, z) }))
} }
pub fn statement_item(s: &str) -> IResult<&str, StatementItem> { pub fn statement_item(s: Span) -> IResult<Span, StatementItem> {
alt(( alt((
map(terminated(blocking_assignment, symbol(";")), |x| { map(terminated(blocking_assignment, symbol(";")), |x| {
StatementItem::BlockingAssignment(Box::new(x)) StatementItem::BlockingAssignment(Box::new(x))
@ -140,12 +140,12 @@ pub fn statement_item(s: &str) -> IResult<&str, StatementItem> {
))(s) ))(s)
} }
pub fn function_statement(s: &str) -> IResult<&str, FunctionStatement> { pub fn function_statement(s: Span) -> IResult<Span, FunctionStatement> {
let (s, x) = statement(s)?; let (s, x) = statement(s)?;
Ok((s, FunctionStatement { nodes: (x,) })) Ok((s, FunctionStatement { nodes: (x,) }))
} }
pub fn function_statement_or_null(s: &str) -> IResult<&str, FunctionStatementOrNull> { pub fn function_statement_or_null(s: Span) -> IResult<Span, FunctionStatementOrNull> {
alt(( alt((
map(function_statement, |x| { map(function_statement, |x| {
FunctionStatementOrNull::Statement(x) FunctionStatementOrNull::Statement(x)
@ -156,7 +156,7 @@ pub fn function_statement_or_null(s: &str) -> IResult<&str, FunctionStatementOrN
))(s) ))(s)
} }
pub fn variable_identifier_list(s: &str) -> IResult<&str, VariableIdentifierList> { pub fn variable_identifier_list(s: Span) -> IResult<Span, VariableIdentifierList> {
let (s, x) = separated_nonempty_list(symbol(","), variable_identifier)(s)?; let (s, x) = separated_nonempty_list(symbol(","), variable_identifier)(s)?;
Ok((s, VariableIdentifierList { nodes: (x,) })) Ok((s, VariableIdentifierList { nodes: (x,) }))
} }

View File

@ -14,7 +14,7 @@ pub enum SubroutineCallStatement<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn subroutine_call_statement(s: &str) -> IResult<&str, SubroutineCallStatement> { pub fn subroutine_call_statement(s: Span) -> IResult<Span, SubroutineCallStatement> {
alt(( alt((
map(terminated(subroutine_call, symbol(";")), |x| { map(terminated(subroutine_call, symbol(";")), |x| {
SubroutineCallStatement::SubroutineCall(x) SubroutineCallStatement::SubroutineCall(x)

View File

@ -126,14 +126,14 @@ pub enum DisableStatement<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn procedural_timing_control_statement( pub fn procedural_timing_control_statement(
s: &str, s: Span,
) -> IResult<&str, ProceduralTimingControlStatement> { ) -> IResult<Span, ProceduralTimingControlStatement> {
let (s, x) = procedural_timing_control(s)?; let (s, x) = procedural_timing_control(s)?;
let (s, y) = statement_or_null(s)?; let (s, y) = statement_or_null(s)?;
Ok((s, ProceduralTimingControlStatement { nodes: (x, y) })) Ok((s, ProceduralTimingControlStatement { nodes: (x, y) }))
} }
pub fn delay_or_event_control(s: &str) -> IResult<&str, DelayOrEventControl> { pub fn delay_or_event_control(s: Span) -> IResult<Span, DelayOrEventControl> {
alt(( alt((
map(delay_control, |x| DelayOrEventControl::Delay(x)), map(delay_control, |x| DelayOrEventControl::Delay(x)),
map(event_control, |x| DelayOrEventControl::Event(x)), map(event_control, |x| DelayOrEventControl::Event(x)),
@ -141,7 +141,7 @@ pub fn delay_or_event_control(s: &str) -> IResult<&str, DelayOrEventControl> {
))(s) ))(s)
} }
pub fn delay_or_event_control_repeat(s: &str) -> IResult<&str, DelayOrEventControl> { pub fn delay_or_event_control_repeat(s: Span) -> IResult<Span, DelayOrEventControl> {
let (s, _) = symbol("repeat")(s)?; let (s, _) = symbol("repeat")(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
@ -153,17 +153,17 @@ pub fn delay_or_event_control_repeat(s: &str) -> IResult<&str, DelayOrEventContr
)) ))
} }
pub fn delay_control(s: &str) -> IResult<&str, DelayControl> { pub fn delay_control(s: Span) -> IResult<Span, DelayControl> {
alt((delay_control_delay, delay_control_mintypmax))(s) alt((delay_control_delay, delay_control_mintypmax))(s)
} }
pub fn delay_control_delay(s: &str) -> IResult<&str, DelayControl> { pub fn delay_control_delay(s: Span) -> IResult<Span, DelayControl> {
let (s, _) = symbol("#")(s)?; let (s, _) = symbol("#")(s)?;
let (s, x) = delay_value(s)?; let (s, x) = delay_value(s)?;
Ok((s, DelayControl::Delay(x))) Ok((s, DelayControl::Delay(x)))
} }
pub fn delay_control_mintypmax(s: &str) -> IResult<&str, DelayControl> { pub fn delay_control_mintypmax(s: Span) -> IResult<Span, DelayControl> {
let (s, _) = symbol("#")(s)?; let (s, _) = symbol("#")(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = mintypmax_expression(s)?; let (s, x) = mintypmax_expression(s)?;
@ -171,7 +171,7 @@ pub fn delay_control_mintypmax(s: &str) -> IResult<&str, DelayControl> {
Ok((s, DelayControl::Mintypmax(x))) Ok((s, DelayControl::Mintypmax(x)))
} }
pub fn event_control(s: &str) -> IResult<&str, EventControl> { pub fn event_control(s: Span) -> IResult<Span, EventControl> {
alt(( alt((
event_control_event_identifier, event_control_event_identifier,
event_control_event_expression, event_control_event_expression,
@ -180,13 +180,13 @@ pub fn event_control(s: &str) -> IResult<&str, EventControl> {
))(s) ))(s)
} }
pub fn event_control_event_identifier(s: &str) -> IResult<&str, EventControl> { pub fn event_control_event_identifier(s: Span) -> IResult<Span, EventControl> {
let (s, _) = symbol("@")(s)?; let (s, _) = symbol("@")(s)?;
let (s, x) = hierarchical_event_identifier(s)?; let (s, x) = hierarchical_event_identifier(s)?;
Ok((s, EventControl::EventIdentifier(x))) Ok((s, EventControl::EventIdentifier(x)))
} }
pub fn event_control_event_expression(s: &str) -> IResult<&str, EventControl> { pub fn event_control_event_expression(s: Span) -> IResult<Span, EventControl> {
let (s, _) = symbol("@")(s)?; let (s, _) = symbol("@")(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = event_expression(s)?; let (s, x) = event_expression(s)?;
@ -194,18 +194,18 @@ pub fn event_control_event_expression(s: &str) -> IResult<&str, EventControl> {
Ok((s, EventControl::EventExpression(x))) Ok((s, EventControl::EventExpression(x)))
} }
pub fn event_control_asterisk(s: &str) -> IResult<&str, EventControl> { pub fn event_control_asterisk(s: Span) -> IResult<Span, EventControl> {
let (s, _) = alt((symbol("@*"), preceded(symbol("@"), symbol("(*)"))))(s)?; let (s, _) = alt((symbol("@*"), preceded(symbol("@"), symbol("(*)"))))(s)?;
Ok((s, EventControl::Asterisk)) Ok((s, EventControl::Asterisk))
} }
pub fn event_control_sequence_identifier(s: &str) -> IResult<&str, EventControl> { pub fn event_control_sequence_identifier(s: Span) -> IResult<Span, EventControl> {
let (s, _) = symbol("@")(s)?; let (s, _) = symbol("@")(s)?;
let (s, x) = ps_or_hierarchical_sequence_identifier(s)?; let (s, x) = ps_or_hierarchical_sequence_identifier(s)?;
Ok((s, EventControl::SequenceIdentifier(x))) Ok((s, EventControl::SequenceIdentifier(x)))
} }
pub fn event_expression(s: &str) -> IResult<&str, EventExpression> { pub fn event_expression(s: Span) -> IResult<Span, EventExpression> {
alt(( alt((
event_expression_expression, event_expression_expression,
event_expression_sequence, event_expression_sequence,
@ -215,7 +215,7 @@ pub fn event_expression(s: &str) -> IResult<&str, EventExpression> {
))(s) ))(s)
} }
pub fn event_expression_expression(s: &str) -> IResult<&str, EventExpression> { pub fn event_expression_expression(s: Span) -> IResult<Span, EventExpression> {
let (s, x) = opt(edge_identifier)(s)?; let (s, x) = opt(edge_identifier)(s)?;
let (s, y) = expression(s)?; let (s, y) = expression(s)?;
let (s, z) = opt(preceded(symbol("iff"), expression))(s)?; let (s, z) = opt(preceded(symbol("iff"), expression))(s)?;
@ -225,7 +225,7 @@ pub fn event_expression_expression(s: &str) -> IResult<&str, EventExpression> {
)) ))
} }
pub fn event_expression_sequence(s: &str) -> IResult<&str, EventExpression> { pub fn event_expression_sequence(s: Span) -> IResult<Span, EventExpression> {
let (s, x) = sequence_instance(s)?; let (s, x) = sequence_instance(s)?;
let (s, y) = opt(preceded(symbol("iff"), expression))(s)?; let (s, y) = opt(preceded(symbol("iff"), expression))(s)?;
Ok(( Ok((
@ -234,28 +234,28 @@ pub fn event_expression_sequence(s: &str) -> IResult<&str, EventExpression> {
)) ))
} }
pub fn event_expression_or(s: &str) -> IResult<&str, EventExpression> { pub fn event_expression_or(s: Span) -> IResult<Span, EventExpression> {
let (s, x) = event_expression(s)?; let (s, x) = event_expression(s)?;
let (s, _) = symbol("or")(s)?; let (s, _) = symbol("or")(s)?;
let (s, y) = event_expression(s)?; let (s, y) = event_expression(s)?;
Ok((s, EventExpression::Or(Box::new((x, y))))) Ok((s, EventExpression::Or(Box::new((x, y)))))
} }
pub fn event_expression_comma(s: &str) -> IResult<&str, EventExpression> { pub fn event_expression_comma(s: Span) -> IResult<Span, EventExpression> {
let (s, x) = event_expression(s)?; let (s, x) = event_expression(s)?;
let (s, _) = symbol(",")(s)?; let (s, _) = symbol(",")(s)?;
let (s, y) = event_expression(s)?; let (s, y) = event_expression(s)?;
Ok((s, EventExpression::Comma(Box::new((x, y))))) Ok((s, EventExpression::Comma(Box::new((x, y)))))
} }
pub fn event_expression_paren(s: &str) -> IResult<&str, EventExpression> { pub fn event_expression_paren(s: Span) -> IResult<Span, EventExpression> {
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = event_expression(s)?; let (s, x) = event_expression(s)?;
let (s, _) = symbol(")")(s)?; let (s, _) = symbol(")")(s)?;
Ok((s, EventExpression::Paren(Box::new(x)))) Ok((s, EventExpression::Paren(Box::new(x))))
} }
pub fn procedural_timing_control(s: &str) -> IResult<&str, ProceduralTimingControl> { pub fn procedural_timing_control(s: Span) -> IResult<Span, ProceduralTimingControl> {
alt(( alt((
map(delay_control, |x| ProceduralTimingControl::DelayControl(x)), map(delay_control, |x| ProceduralTimingControl::DelayControl(x)),
map(event_control, |x| ProceduralTimingControl::EventControl(x)), map(event_control, |x| ProceduralTimingControl::EventControl(x)),
@ -263,7 +263,7 @@ pub fn procedural_timing_control(s: &str) -> IResult<&str, ProceduralTimingContr
))(s) ))(s)
} }
pub fn jump_statement(s: &str) -> IResult<&str, JumpStatement> { pub fn jump_statement(s: Span) -> IResult<Span, JumpStatement> {
alt(( alt((
jump_statement_return, jump_statement_return,
jump_statement_break, jump_statement_break,
@ -271,7 +271,7 @@ pub fn jump_statement(s: &str) -> IResult<&str, JumpStatement> {
))(s) ))(s)
} }
pub fn jump_statement_return(s: &str) -> IResult<&str, JumpStatement> { pub fn jump_statement_return(s: Span) -> IResult<Span, JumpStatement> {
let (s, _) = symbol("return")(s)?; let (s, _) = symbol("return")(s)?;
let (s, x) = opt(expression)(s)?; let (s, x) = opt(expression)(s)?;
let (s, _) = symbol(";")(s)?; let (s, _) = symbol(";")(s)?;
@ -281,19 +281,19 @@ pub fn jump_statement_return(s: &str) -> IResult<&str, JumpStatement> {
)) ))
} }
pub fn jump_statement_break(s: &str) -> IResult<&str, JumpStatement> { pub fn jump_statement_break(s: Span) -> IResult<Span, JumpStatement> {
let (s, _) = symbol("break")(s)?; let (s, _) = symbol("break")(s)?;
let (s, _) = symbol(";")(s)?; let (s, _) = symbol(";")(s)?;
Ok((s, JumpStatement::Break)) Ok((s, JumpStatement::Break))
} }
pub fn jump_statement_continue(s: &str) -> IResult<&str, JumpStatement> { pub fn jump_statement_continue(s: Span) -> IResult<Span, JumpStatement> {
let (s, _) = symbol("continue")(s)?; let (s, _) = symbol("continue")(s)?;
let (s, _) = symbol(";")(s)?; let (s, _) = symbol(";")(s)?;
Ok((s, JumpStatement::Continue)) Ok((s, JumpStatement::Continue))
} }
pub fn wait_statement(s: &str) -> IResult<&str, WaitStatement> { pub fn wait_statement(s: Span) -> IResult<Span, WaitStatement> {
alt(( alt((
wait_statement_wait, wait_statement_wait,
wait_statement_fork, wait_statement_fork,
@ -301,21 +301,21 @@ pub fn wait_statement(s: &str) -> IResult<&str, WaitStatement> {
))(s) ))(s)
} }
pub fn wait_statement_wait(s: &str) -> IResult<&str, WaitStatement> { pub fn wait_statement_wait(s: Span) -> IResult<Span, WaitStatement> {
let (s, _) = symbol("wait")(s)?; let (s, _) = symbol("wait")(s)?;
let (s, x) = paren(expression)(s)?; let (s, x) = paren(expression)(s)?;
let (s, y) = statement_or_null(s)?; let (s, y) = statement_or_null(s)?;
Ok((s, WaitStatement::Wait(WaitStatementWait { nodes: (x, y) }))) Ok((s, WaitStatement::Wait(WaitStatementWait { nodes: (x, y) })))
} }
pub fn wait_statement_fork(s: &str) -> IResult<&str, WaitStatement> { pub fn wait_statement_fork(s: Span) -> IResult<Span, WaitStatement> {
let (s, _) = symbol("wait")(s)?; let (s, _) = symbol("wait")(s)?;
let (s, _) = symbol("fork")(s)?; let (s, _) = symbol("fork")(s)?;
let (s, _) = symbol(";")(s)?; let (s, _) = symbol(";")(s)?;
Ok((s, WaitStatement::Fork)) Ok((s, WaitStatement::Fork))
} }
pub fn wait_statement_order(s: &str) -> IResult<&str, WaitStatement> { pub fn wait_statement_order(s: Span) -> IResult<Span, WaitStatement> {
let (s, _) = symbol("wait_order")(s)?; let (s, _) = symbol("wait_order")(s)?;
let (s, x) = paren(separated_nonempty_list( let (s, x) = paren(separated_nonempty_list(
symbol(","), symbol(","),
@ -328,18 +328,18 @@ pub fn wait_statement_order(s: &str) -> IResult<&str, WaitStatement> {
)) ))
} }
pub fn event_trigger(s: &str) -> IResult<&str, EventTrigger> { pub fn event_trigger(s: Span) -> IResult<Span, EventTrigger> {
alt((event_trigger_named, event_trigger_nonblocking))(s) alt((event_trigger_named, event_trigger_nonblocking))(s)
} }
pub fn event_trigger_named(s: &str) -> IResult<&str, EventTrigger> { pub fn event_trigger_named(s: Span) -> IResult<Span, EventTrigger> {
let (s, _) = symbol("->")(s)?; let (s, _) = symbol("->")(s)?;
let (s, x) = hierarchical_event_identifier(s)?; let (s, x) = hierarchical_event_identifier(s)?;
let (s, _) = symbol(";")(s)?; let (s, _) = symbol(";")(s)?;
Ok((s, EventTrigger::Named(EventTriggerNamed { nodes: (x,) }))) Ok((s, EventTrigger::Named(EventTriggerNamed { nodes: (x,) })))
} }
pub fn event_trigger_nonblocking(s: &str) -> IResult<&str, EventTrigger> { pub fn event_trigger_nonblocking(s: Span) -> IResult<Span, EventTrigger> {
let (s, _) = symbol("->>")(s)?; let (s, _) = symbol("->>")(s)?;
let (s, x) = opt(delay_or_event_control)(s)?; let (s, x) = opt(delay_or_event_control)(s)?;
let (s, y) = hierarchical_event_identifier(s)?; let (s, y) = hierarchical_event_identifier(s)?;
@ -350,7 +350,7 @@ pub fn event_trigger_nonblocking(s: &str) -> IResult<&str, EventTrigger> {
)) ))
} }
pub fn disable_statement(s: &str) -> IResult<&str, DisableStatement> { pub fn disable_statement(s: Span) -> IResult<Span, DisableStatement> {
alt(( alt((
disable_statement_task, disable_statement_task,
disable_statement_block, disable_statement_block,
@ -358,21 +358,21 @@ pub fn disable_statement(s: &str) -> IResult<&str, DisableStatement> {
))(s) ))(s)
} }
pub fn disable_statement_task(s: &str) -> IResult<&str, DisableStatement> { pub fn disable_statement_task(s: Span) -> IResult<Span, DisableStatement> {
let (s, _) = symbol("disable")(s)?; let (s, _) = symbol("disable")(s)?;
let (s, x) = hierarchical_task_identifier(s)?; let (s, x) = hierarchical_task_identifier(s)?;
let (s, _) = symbol(";")(s)?; let (s, _) = symbol(";")(s)?;
Ok((s, DisableStatement::Task(x))) Ok((s, DisableStatement::Task(x)))
} }
pub fn disable_statement_block(s: &str) -> IResult<&str, DisableStatement> { pub fn disable_statement_block(s: Span) -> IResult<Span, DisableStatement> {
let (s, _) = symbol("disable")(s)?; let (s, _) = symbol("disable")(s)?;
let (s, x) = hierarchical_block_identifier(s)?; let (s, x) = hierarchical_block_identifier(s)?;
let (s, _) = symbol(";")(s)?; let (s, _) = symbol(";")(s)?;
Ok((s, DisableStatement::Block(x))) Ok((s, DisableStatement::Block(x)))
} }
pub fn disable_statement_fork(s: &str) -> IResult<&str, DisableStatement> { pub fn disable_statement_fork(s: Span) -> IResult<Span, DisableStatement> {
let (s, _) = symbol("disable")(s)?; let (s, _) = symbol("disable")(s)?;
let (s, _) = symbol("fork")(s)?; let (s, _) = symbol("fork")(s)?;
let (s, _) = symbol(";")(s)?; let (s, _) = symbol(";")(s)?;

View File

@ -583,168 +583,168 @@ pub struct AssertionVariableDeclaration<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn concurrent_assertion_item(s: &str) -> IResult<&str, ConcurrentAssertionItem> { pub fn concurrent_assertion_item(s: Span) -> IResult<Span, ConcurrentAssertionItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn concurrent_assertion_statement(s: &str) -> IResult<&str, ConcurrentAssertionStatement> { pub fn concurrent_assertion_statement(s: Span) -> IResult<Span, ConcurrentAssertionStatement> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn assert_property_statement(s: &str) -> IResult<&str, AssertPropertyStatement> { pub fn assert_property_statement(s: Span) -> IResult<Span, AssertPropertyStatement> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn assume_property_statement(s: &str) -> IResult<&str, AssumePropertyStatement> { pub fn assume_property_statement(s: Span) -> IResult<Span, AssumePropertyStatement> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn cover_property_statement(s: &str) -> IResult<&str, CoverPropertyStatement> { pub fn cover_property_statement(s: Span) -> IResult<Span, CoverPropertyStatement> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn expect_property_statement(s: &str) -> IResult<&str, ExpectPropertyStatement> { pub fn expect_property_statement(s: Span) -> IResult<Span, ExpectPropertyStatement> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn cover_sequence_statement(s: &str) -> IResult<&str, CoverSequenceStatement> { pub fn cover_sequence_statement(s: Span) -> IResult<Span, CoverSequenceStatement> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn restrict_property_statement(s: &str) -> IResult<&str, RestrictPropertyStatement> { pub fn restrict_property_statement(s: Span) -> IResult<Span, RestrictPropertyStatement> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn property_instance(s: &str) -> IResult<&str, PropertyInstance> { pub fn property_instance(s: Span) -> IResult<Span, PropertyInstance> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn property_list_of_arguments(s: &str) -> IResult<&str, PropertyListOfArguments> { pub fn property_list_of_arguments(s: Span) -> IResult<Span, PropertyListOfArguments> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn property_actual_arg(s: &str) -> IResult<&str, PropertyActualArg> { pub fn property_actual_arg(s: Span) -> IResult<Span, PropertyActualArg> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn assertion_item_declaration(s: &str) -> IResult<&str, AssertionItemDeclaration> { pub fn assertion_item_declaration(s: Span) -> IResult<Span, AssertionItemDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn property_declaration(s: &str) -> IResult<&str, PropertyDeclaration> { pub fn property_declaration(s: Span) -> IResult<Span, PropertyDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn property_port_list(s: &str) -> IResult<&str, PropertyPortList> { pub fn property_port_list(s: Span) -> IResult<Span, PropertyPortList> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn property_port_item(s: &str) -> IResult<&str, PropertyPortItem> { pub fn property_port_item(s: Span) -> IResult<Span, PropertyPortItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn property_lvar_port_direction(s: &str) -> IResult<&str, PropertyLvarPortDirection> { pub fn property_lvar_port_direction(s: Span) -> IResult<Span, PropertyLvarPortDirection> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn property_formal_type(s: &str) -> IResult<&str, PropertyFormalType> { pub fn property_formal_type(s: Span) -> IResult<Span, PropertyFormalType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn property_spec(s: &str) -> IResult<&str, PropertySpec> { pub fn property_spec(s: Span) -> IResult<Span, PropertySpec> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn property_expr(s: &str) -> IResult<&str, PropertyExpr> { pub fn property_expr(s: Span) -> IResult<Span, PropertyExpr> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn property_case_item(s: &str) -> IResult<&str, PropertyCaseItem> { pub fn property_case_item(s: Span) -> IResult<Span, PropertyCaseItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn sequence_declaration(s: &str) -> IResult<&str, SequenceDeclaration> { pub fn sequence_declaration(s: Span) -> IResult<Span, SequenceDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn sequence_port_list(s: &str) -> IResult<&str, SequencePortList> { pub fn sequence_port_list(s: Span) -> IResult<Span, SequencePortList> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn sequence_port_item(s: &str) -> IResult<&str, SequencePortItem> { pub fn sequence_port_item(s: Span) -> IResult<Span, SequencePortItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn sequence_lvar_port_direction(s: &str) -> IResult<&str, SequenceLvarPortDirection> { pub fn sequence_lvar_port_direction(s: Span) -> IResult<Span, SequenceLvarPortDirection> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn sequence_formal_type(s: &str) -> IResult<&str, SequenceFormalType> { pub fn sequence_formal_type(s: Span) -> IResult<Span, SequenceFormalType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn sequence_expr(s: &str) -> IResult<&str, SequenceExpr> { pub fn sequence_expr(s: Span) -> IResult<Span, SequenceExpr> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn cycle_delay_range(s: &str) -> IResult<&str, CycleDelayRange> { pub fn cycle_delay_range(s: Span) -> IResult<Span, CycleDelayRange> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn sequence_method_call(s: &str) -> IResult<&str, SequenceMethodCall> { pub fn sequence_method_call(s: Span) -> IResult<Span, SequenceMethodCall> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn sequence_match_item(s: &str) -> IResult<&str, SequenceMatchItem> { pub fn sequence_match_item(s: Span) -> IResult<Span, SequenceMatchItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn sequence_instance(s: &str) -> IResult<&str, SequenceInstance> { pub fn sequence_instance(s: Span) -> IResult<Span, SequenceInstance> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn sequence_list_of_arguments(s: &str) -> IResult<&str, SequenceListOfArguments> { pub fn sequence_list_of_arguments(s: Span) -> IResult<Span, SequenceListOfArguments> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn sequence_actual_arg(s: &str) -> IResult<&str, SequenceActualArg> { pub fn sequence_actual_arg(s: Span) -> IResult<Span, SequenceActualArg> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn boolean_abbrev(s: &str) -> IResult<&str, BooleanAbbrev> { pub fn boolean_abbrev(s: Span) -> IResult<Span, BooleanAbbrev> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn sequence_abbrev(s: &str) -> IResult<&str, SequenceAbbrev> { pub fn sequence_abbrev(s: Span) -> IResult<Span, SequenceAbbrev> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn consecutive_repetition(s: &str) -> IResult<&str, ConsecutiveRepetition> { pub fn consecutive_repetition(s: Span) -> IResult<Span, ConsecutiveRepetition> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn non_consecutive_repetition(s: &str) -> IResult<&str, NonConsecutiveRepetition> { pub fn non_consecutive_repetition(s: Span) -> IResult<Span, NonConsecutiveRepetition> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn goto_repetition(s: &str) -> IResult<&str, GotoRepetition> { pub fn goto_repetition(s: Span) -> IResult<Span, GotoRepetition> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn const_or_range_expression(s: &str) -> IResult<&str, ConstOrRangeExpression> { pub fn const_or_range_expression(s: Span) -> IResult<Span, ConstOrRangeExpression> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn cycle_delay_const_range_expression( pub fn cycle_delay_const_range_expression(
s: &str, s: Span,
) -> IResult<&str, CycleDelayConstRangeExpression> { ) -> IResult<Span, CycleDelayConstRangeExpression> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn expression_or_dist(s: &str) -> IResult<&str, ExpressionOrDist> { pub fn expression_or_dist(s: Span) -> IResult<Span, ExpressionOrDist> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn assertion_variable_declaration(s: &str) -> IResult<&str, AssertionVariableDeclaration> { pub fn assertion_variable_declaration(s: Span) -> IResult<Span, AssertionVariableDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -36,6 +36,6 @@ pub struct BlockItemDeclarationLet<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn block_item_declaration(s: &str) -> IResult<&str, BlockItemDeclaration> { pub fn block_item_declaration(s: Span) -> IResult<Span, BlockItemDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -442,134 +442,134 @@ pub struct CovergroupExpression<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn covergroup_declaration(s: &str) -> IResult<&str, CovergroupDeclaration> { pub fn covergroup_declaration(s: Span) -> IResult<Span, CovergroupDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn coverage_spec_or_option(s: &str) -> IResult<&str, CoverageSpecOrOption> { pub fn coverage_spec_or_option(s: Span) -> IResult<Span, CoverageSpecOrOption> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn coverage_option(s: &str) -> IResult<&str, CoverageOption> { pub fn coverage_option(s: Span) -> IResult<Span, CoverageOption> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn coverage_spec(s: &str) -> IResult<&str, CoverageSpec> { pub fn coverage_spec(s: Span) -> IResult<Span, CoverageSpec> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn coverage_event(s: &str) -> IResult<&str, CoverageEvent> { pub fn coverage_event(s: Span) -> IResult<Span, CoverageEvent> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn block_event_expression(s: &str) -> IResult<&str, BlockEventExpression> { pub fn block_event_expression(s: Span) -> IResult<Span, BlockEventExpression> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn hierarchical_btf_identifier(s: &str) -> IResult<&str, HierarchicalBtfIdentifier> { pub fn hierarchical_btf_identifier(s: Span) -> IResult<Span, HierarchicalBtfIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn cover_point(s: &str) -> IResult<&str, CoverPoint> { pub fn cover_point(s: Span) -> IResult<Span, CoverPoint> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn bins_or_empty(s: &str) -> IResult<&str, BinsOrEmpty> { pub fn bins_or_empty(s: Span) -> IResult<Span, BinsOrEmpty> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn bins_or_options(s: &str) -> IResult<&str, BinsOrOptions> { pub fn bins_or_options(s: Span) -> IResult<Span, BinsOrOptions> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn bins_keyword(s: &str) -> IResult<&str, BinsKeyword> { pub fn bins_keyword(s: Span) -> IResult<Span, BinsKeyword> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn trans_list(s: &str) -> IResult<&str, TransList> { pub fn trans_list(s: Span) -> IResult<Span, TransList> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn trans_set(s: &str) -> IResult<&str, TransSet> { pub fn trans_set(s: Span) -> IResult<Span, TransSet> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn trans_range_list(s: &str) -> IResult<&str, TransRangeList> { pub fn trans_range_list(s: Span) -> IResult<Span, TransRangeList> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn trans_item(s: &str) -> IResult<&str, TransItem> { pub fn trans_item(s: Span) -> IResult<Span, TransItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn repeat_range(s: &str) -> IResult<&str, RepeatRange> { pub fn repeat_range(s: Span) -> IResult<Span, RepeatRange> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn cover_cross(s: &str) -> IResult<&str, CoverCross> { pub fn cover_cross(s: Span) -> IResult<Span, CoverCross> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_cross_items(s: &str) -> IResult<&str, ListOfCrossItems> { pub fn list_of_cross_items(s: Span) -> IResult<Span, ListOfCrossItems> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn cross_item(s: &str) -> IResult<&str, CrossItem> { pub fn cross_item(s: Span) -> IResult<Span, CrossItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn cross_body(s: &str) -> IResult<&str, CrossBody> { pub fn cross_body(s: Span) -> IResult<Span, CrossBody> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn cross_body_item(s: &str) -> IResult<&str, CrossBodyItem> { pub fn cross_body_item(s: Span) -> IResult<Span, CrossBodyItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn bins_selection_or_option(s: &str) -> IResult<&str, BinsSelectionOrOption> { pub fn bins_selection_or_option(s: Span) -> IResult<Span, BinsSelectionOrOption> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn bins_selection(s: &str) -> IResult<&str, BinsSelection> { pub fn bins_selection(s: Span) -> IResult<Span, BinsSelection> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn select_expression(s: &str) -> IResult<&str, SelectExpression> { pub fn select_expression(s: Span) -> IResult<Span, SelectExpression> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn select_condition(s: &str) -> IResult<&str, SelectCondition> { pub fn select_condition(s: Span) -> IResult<Span, SelectCondition> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn bins_expression(s: &str) -> IResult<&str, BinsExpression> { pub fn bins_expression(s: Span) -> IResult<Span, BinsExpression> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn covergroup_range_list(s: &str) -> IResult<&str, CovergroupRangeList> { pub fn covergroup_range_list(s: Span) -> IResult<Span, CovergroupRangeList> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn covergroup_value_range(s: &str) -> IResult<&str, CovergroupValueRange> { pub fn covergroup_value_range(s: Span) -> IResult<Span, CovergroupValueRange> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn with_covergroup_expression(s: &str) -> IResult<&str, WithCovergroupExpression> { pub fn with_covergroup_expression(s: Span) -> IResult<Span, WithCovergroupExpression> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn set_covergroup_expression(s: &str) -> IResult<&str, SetCovergroupExpression> { pub fn set_covergroup_expression(s: Span) -> IResult<Span, SetCovergroupExpression> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn integer_covergroup_expression(s: &str) -> IResult<&str, IntegerCovergroupExpression> { pub fn integer_covergroup_expression(s: Span) -> IResult<Span, IntegerCovergroupExpression> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn cross_set_expression(s: &str) -> IResult<&str, CrossSetExpression> { pub fn cross_set_expression(s: Span) -> IResult<Span, CrossSetExpression> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn covergroup_expression(s: &str) -> IResult<&str, CovergroupExpression> { pub fn covergroup_expression(s: Span) -> IResult<Span, CovergroupExpression> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -117,50 +117,50 @@ pub struct DynamicArrayNew<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn defparam_assignment(s: &str) -> IResult<&str, DefparamAssignment> { pub fn defparam_assignment(s: Span) -> IResult<Span, DefparamAssignment> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn net_decl_assignment(s: &str) -> IResult<&str, NetDeclAssignment> { pub fn net_decl_assignment(s: Span) -> IResult<Span, NetDeclAssignment> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn param_assignment(s: &str) -> IResult<&str, ParamAssignment> { pub fn param_assignment(s: Span) -> IResult<Span, ParamAssignment> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn specparam_assignment(s: &str) -> IResult<&str, SpecparamAssignment> { pub fn specparam_assignment(s: Span) -> IResult<Span, SpecparamAssignment> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn type_assignment(s: &str) -> IResult<&str, TypeAssignment> { pub fn type_assignment(s: Span) -> IResult<Span, TypeAssignment> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn pulse_control_specparam(s: &str) -> IResult<&str, PulseControlSpecparam> { pub fn pulse_control_specparam(s: Span) -> IResult<Span, PulseControlSpecparam> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn error_limit_value(s: &str) -> IResult<&str, ErrorLimitValue> { pub fn error_limit_value(s: Span) -> IResult<Span, ErrorLimitValue> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn reject_limit_value(s: &str) -> IResult<&str, RejectLimitValue> { pub fn reject_limit_value(s: Span) -> IResult<Span, RejectLimitValue> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn limit_value(s: &str) -> IResult<&str, LimitValue> { pub fn limit_value(s: Span) -> IResult<Span, LimitValue> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn variable_decl_assignment(s: &str) -> IResult<&str, VariableDeclAssignment> { pub fn variable_decl_assignment(s: Span) -> IResult<Span, VariableDeclAssignment> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn class_new(s: &str) -> IResult<&str, ClassNew> { pub fn class_new(s: Span) -> IResult<Span, ClassNew> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn dynamic_array_new(s: &str) -> IResult<&str, DynamicArrayNew> { pub fn dynamic_array_new(s: Span) -> IResult<Span, DynamicArrayNew> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -85,54 +85,54 @@ pub struct ListOfVariablePortIdentifiers<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn list_of_defparam_assignments(s: &str) -> IResult<&str, ListOfDefparamAssignments> { pub fn list_of_defparam_assignments(s: Span) -> IResult<Span, ListOfDefparamAssignments> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_genvar_identifiers(s: &str) -> IResult<&str, ListOfGenvarIdentifiers> { pub fn list_of_genvar_identifiers(s: Span) -> IResult<Span, ListOfGenvarIdentifiers> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_interface_identifiers(s: &str) -> IResult<&str, ListOfInterfaceIdentifiers> { pub fn list_of_interface_identifiers(s: Span) -> IResult<Span, ListOfInterfaceIdentifiers> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_net_decl_assignments(s: &str) -> IResult<&str, ListOfNetDeclAssignments> { pub fn list_of_net_decl_assignments(s: Span) -> IResult<Span, ListOfNetDeclAssignments> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_param_assignments(s: &str) -> IResult<&str, ListOfParamAssignments> { pub fn list_of_param_assignments(s: Span) -> IResult<Span, ListOfParamAssignments> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_port_identifiers(s: &str) -> IResult<&str, ListOfPortIdentifiers> { pub fn list_of_port_identifiers(s: Span) -> IResult<Span, ListOfPortIdentifiers> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_udp_port_identifiers(s: &str) -> IResult<&str, ListOfUdpPortIdentifiers> { pub fn list_of_udp_port_identifiers(s: Span) -> IResult<Span, ListOfUdpPortIdentifiers> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_specparam_assignments(s: &str) -> IResult<&str, ListOfSpecparamAssignments> { pub fn list_of_specparam_assignments(s: Span) -> IResult<Span, ListOfSpecparamAssignments> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_tf_variable_identifiers(s: &str) -> IResult<&str, ListOfTfVariableIdentifiers> { pub fn list_of_tf_variable_identifiers(s: Span) -> IResult<Span, ListOfTfVariableIdentifiers> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_type_assignments(s: &str) -> IResult<&str, ListOfTypeAssignments> { pub fn list_of_type_assignments(s: Span) -> IResult<Span, ListOfTypeAssignments> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_variable_decl_assignments(s: &str) -> IResult<&str, ListOfVariableDeclAssignments> { pub fn list_of_variable_decl_assignments(s: Span) -> IResult<Span, ListOfVariableDeclAssignments> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_variable_identifiers(s: &str) -> IResult<&str, ListOfVariableIdentifiers> { pub fn list_of_variable_identifiers(s: Span) -> IResult<Span, ListOfVariableIdentifiers> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_variable_port_identifiers(s: &str) -> IResult<&str, ListOfVariablePortIdentifiers> { pub fn list_of_variable_port_identifiers(s: Span) -> IResult<Span, ListOfVariablePortIdentifiers> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -44,26 +44,26 @@ pub struct UnsizedDimension {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn unpacked_dimension(s: &str) -> IResult<&str, UnpackedDimension> { pub fn unpacked_dimension(s: Span) -> IResult<Span, UnpackedDimension> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn packed_dimension(s: &str) -> IResult<&str, PackedDimension> { pub fn packed_dimension(s: Span) -> IResult<Span, PackedDimension> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn associative_dimension(s: &str) -> IResult<&str, AssociativeDimension> { pub fn associative_dimension(s: Span) -> IResult<Span, AssociativeDimension> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn variable_dimension(s: &str) -> IResult<&str, VariableDimension> { pub fn variable_dimension(s: Span) -> IResult<Span, VariableDimension> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn queue_dimension(s: &str) -> IResult<&str, QueueDimension> { pub fn queue_dimension(s: Span) -> IResult<Span, QueueDimension> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn unsized_dimension(s: &str) -> IResult<&str, UnsizedDimension> { pub fn unsized_dimension(s: Span) -> IResult<Span, UnsizedDimension> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -33,7 +33,7 @@ pub struct Delay2Mintypmax<'a> {
#[derive(Debug)] #[derive(Debug)]
pub enum DelayValue<'a> { pub enum DelayValue<'a> {
UnsignedNumber(&'a str), UnsignedNumber(UnsignedNumber<'a>),
RealNumber(RealNumber<'a>), RealNumber(RealNumber<'a>),
Identifier(Identifier<'a>), Identifier(Identifier<'a>),
TimeLiteral(TimeLiteral<'a>), TimeLiteral(TimeLiteral<'a>),
@ -42,14 +42,14 @@ pub enum DelayValue<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn delay3(s: &str) -> IResult<&str, Delay3> { pub fn delay3(s: Span) -> IResult<Span, Delay3> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn delay2(s: &str) -> IResult<&str, Delay2> { pub fn delay2(s: Span) -> IResult<Span, Delay2> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn delay_value(s: &str) -> IResult<&str, DelayValue> { pub fn delay_value(s: Span) -> IResult<Span, DelayValue> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -120,42 +120,42 @@ pub struct DpiTaskProto<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn function_data_type_or_implicit(s: &str) -> IResult<&str, FunctionDataTypeOrImplicit> { pub fn function_data_type_or_implicit(s: Span) -> IResult<Span, FunctionDataTypeOrImplicit> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn function_declaration(s: &str) -> IResult<&str, FunctionDeclaration> { pub fn function_declaration(s: Span) -> IResult<Span, FunctionDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn function_body_declaration(s: &str) -> IResult<&str, FunctionBodyDeclaration> { pub fn function_body_declaration(s: Span) -> IResult<Span, FunctionBodyDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn function_prototype(s: &str) -> IResult<&str, FunctionPrototype> { pub fn function_prototype(s: Span) -> IResult<Span, FunctionPrototype> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn dpi_import_export(s: &str) -> IResult<&str, DpiImportExport> { pub fn dpi_import_export(s: Span) -> IResult<Span, DpiImportExport> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn dpi_spec_string(s: &str) -> IResult<&str, DpiSpecString> { pub fn dpi_spec_string(s: Span) -> IResult<Span, DpiSpecString> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn dpi_function_import_property(s: &str) -> IResult<&str, DpiFunctionImportProperty> { pub fn dpi_function_import_property(s: Span) -> IResult<Span, DpiFunctionImportProperty> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn dpi_task_import_property(s: &str) -> IResult<&str, DpiTaskImportProperty> { pub fn dpi_task_import_property(s: Span) -> IResult<Span, DpiTaskImportProperty> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn dpi_function_proto(s: &str) -> IResult<&str, DpiFunctionProto> { pub fn dpi_function_proto(s: Span) -> IResult<Span, DpiFunctionProto> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn dpi_task_proto(s: &str) -> IResult<&str, DpiTaskProto> { pub fn dpi_task_proto(s: Span) -> IResult<Span, DpiTaskProto> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -86,38 +86,38 @@ pub enum ImportExport {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn modport_declaration(s: &str) -> IResult<&str, ModportDeclaration> { pub fn modport_declaration(s: Span) -> IResult<Span, ModportDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn modport_item(s: &str) -> IResult<&str, ModportItem> { pub fn modport_item(s: Span) -> IResult<Span, ModportItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn modport_ports_declaration(s: &str) -> IResult<&str, ModportPortsDeclaraton> { pub fn modport_ports_declaration(s: Span) -> IResult<Span, ModportPortsDeclaraton> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn modport_clocking_declaration(s: &str) -> IResult<&str, ModportClockingDeclaration> { pub fn modport_clocking_declaration(s: Span) -> IResult<Span, ModportClockingDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn modport_simple_ports_declaration(s: &str) -> IResult<&str, ModportSimplePortsDeclaration> { pub fn modport_simple_ports_declaration(s: Span) -> IResult<Span, ModportSimplePortsDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn modport_simple_port(s: &str) -> IResult<&str, ModportSimplePort> { pub fn modport_simple_port(s: Span) -> IResult<Span, ModportSimplePort> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn modport_tf_ports_declaration(s: &str) -> IResult<&str, ModportTfPortsDeclaration> { pub fn modport_tf_ports_declaration(s: Span) -> IResult<Span, ModportTfPortsDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn modport_tf_port(s: &str) -> IResult<&str, ModportTfPort> { pub fn modport_tf_port(s: Span) -> IResult<Span, ModportTfPort> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn import_export(s: &str) -> IResult<&str, ImportExport> { pub fn import_export(s: Span) -> IResult<Span, ImportExport> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -73,34 +73,34 @@ pub struct LetActualArg<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn let_declaration(s: &str) -> IResult<&str, LetDeclaration> { pub fn let_declaration(s: Span) -> IResult<Span, LetDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn let_identifier(s: &str) -> IResult<&str, LetIdentifier> { pub fn let_identifier(s: Span) -> IResult<Span, LetIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn let_port_list(s: &str) -> IResult<&str, LetPortList> { pub fn let_port_list(s: Span) -> IResult<Span, LetPortList> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn let_port_item(s: &str) -> IResult<&str, LetPortItem> { pub fn let_port_item(s: Span) -> IResult<Span, LetPortItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn let_formal_type(s: &str) -> IResult<&str, LetFormalType> { pub fn let_formal_type(s: Span) -> IResult<Span, LetFormalType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn let_expression(s: &str) -> IResult<&str, LetExpression> { pub fn let_expression(s: Span) -> IResult<Span, LetExpression> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn let_list_of_arguments(s: &str) -> IResult<&str, LetListOfArguments> { pub fn let_list_of_arguments(s: Span) -> IResult<Span, LetListOfArguments> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn let_actual_arg(s: &str) -> IResult<&str, LetActualArg> { pub fn let_actual_arg(s: Span) -> IResult<Span, LetActualArg> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -44,14 +44,14 @@ pub struct SpecparamDeclaration<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn local_parameter_declaration(s: &str) -> IResult<&str, LocalParameterDeclaration> { pub fn local_parameter_declaration(s: Span) -> IResult<Span, LocalParameterDeclaration> {
alt(( alt((
local_parameter_declaration_param, local_parameter_declaration_param,
local_parameter_declaration_type, local_parameter_declaration_type,
))(s) ))(s)
} }
pub fn local_parameter_declaration_param(s: &str) -> IResult<&str, LocalParameterDeclaration> { pub fn local_parameter_declaration_param(s: Span) -> IResult<Span, LocalParameterDeclaration> {
let (s, _) = symbol("localparam")(s)?; let (s, _) = symbol("localparam")(s)?;
let (s, x) = data_type_or_implicit(s)?; let (s, x) = data_type_or_implicit(s)?;
let (s, y) = list_of_param_assignments(s)?; let (s, y) = list_of_param_assignments(s)?;
@ -61,7 +61,7 @@ pub fn local_parameter_declaration_param(s: &str) -> IResult<&str, LocalParamete
)) ))
} }
pub fn local_parameter_declaration_type(s: &str) -> IResult<&str, LocalParameterDeclaration> { pub fn local_parameter_declaration_type(s: Span) -> IResult<Span, LocalParameterDeclaration> {
let (s, _) = symbol("localparam")(s)?; let (s, _) = symbol("localparam")(s)?;
let (s, _) = symbol("type")(s)?; let (s, _) = symbol("type")(s)?;
let (s, x) = list_of_type_assignments(s)?; let (s, x) = list_of_type_assignments(s)?;
@ -71,11 +71,11 @@ pub fn local_parameter_declaration_type(s: &str) -> IResult<&str, LocalParameter
)) ))
} }
pub fn parameter_declaration(s: &str) -> IResult<&str, ParameterDeclaration> { pub fn parameter_declaration(s: Span) -> IResult<Span, ParameterDeclaration> {
alt((parameter_declaration_param, parameter_declaration_type))(s) alt((parameter_declaration_param, parameter_declaration_type))(s)
} }
pub fn parameter_declaration_param(s: &str) -> IResult<&str, ParameterDeclaration> { pub fn parameter_declaration_param(s: Span) -> IResult<Span, ParameterDeclaration> {
let (s, _) = symbol("parameter")(s)?; let (s, _) = symbol("parameter")(s)?;
let (s, x) = data_type_or_implicit(s)?; let (s, x) = data_type_or_implicit(s)?;
let (s, y) = list_of_param_assignments(s)?; let (s, y) = list_of_param_assignments(s)?;
@ -85,7 +85,7 @@ pub fn parameter_declaration_param(s: &str) -> IResult<&str, ParameterDeclaratio
)) ))
} }
pub fn parameter_declaration_type(s: &str) -> IResult<&str, ParameterDeclaration> { pub fn parameter_declaration_type(s: Span) -> IResult<Span, ParameterDeclaration> {
let (s, _) = symbol("parameter")(s)?; let (s, _) = symbol("parameter")(s)?;
let (s, _) = symbol("type")(s)?; let (s, _) = symbol("type")(s)?;
let (s, x) = list_of_type_assignments(s)?; let (s, x) = list_of_type_assignments(s)?;
@ -95,7 +95,7 @@ pub fn parameter_declaration_type(s: &str) -> IResult<&str, ParameterDeclaration
)) ))
} }
pub fn specparam_declaration(s: &str) -> IResult<&str, SpecparamDeclaration> { pub fn specparam_declaration(s: Span) -> IResult<Span, SpecparamDeclaration> {
let (s, _) = symbol("specparam")(s)?; let (s, _) = symbol("specparam")(s)?;
let (s, x) = opt(packed_dimension)(s)?; let (s, x) = opt(packed_dimension)(s)?;
let (s, y) = list_of_specparam_assignments(s)?; let (s, y) = list_of_specparam_assignments(s)?;

View File

@ -259,86 +259,86 @@ pub enum TypeReference<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn casting_type(s: &str) -> IResult<&str, CastingType> { pub fn casting_type(s: Span) -> IResult<Span, CastingType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn data_type(s: &str) -> IResult<&str, DataType> { pub fn data_type(s: Span) -> IResult<Span, DataType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn data_type_or_implicit(s: &str) -> IResult<&str, DataTypeOrImplicit> { pub fn data_type_or_implicit(s: Span) -> IResult<Span, DataTypeOrImplicit> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn implicit_data_type(s: &str) -> IResult<&str, ImplicitDataType> { pub fn implicit_data_type(s: Span) -> IResult<Span, ImplicitDataType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn enum_base_type(s: &str) -> IResult<&str, EnumBaseType> { pub fn enum_base_type(s: Span) -> IResult<Span, EnumBaseType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn enum_name_declaration(s: &str) -> IResult<&str, EnumNameDeclaration> { pub fn enum_name_declaration(s: Span) -> IResult<Span, EnumNameDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn class_scope(s: &str) -> IResult<&str, ClassScope> { pub fn class_scope(s: Span) -> IResult<Span, ClassScope> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn integer_type(s: &str) -> IResult<&str, IntegerType> { pub fn integer_type(s: Span) -> IResult<Span, IntegerType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn integer_atom_type(s: &str) -> IResult<&str, IntegerAtomType> { pub fn integer_atom_type(s: Span) -> IResult<Span, IntegerAtomType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn integer_vector_type(s: &str) -> IResult<&str, IntegerVectorType> { pub fn integer_vector_type(s: Span) -> IResult<Span, IntegerVectorType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn non_integer_type(s: &str) -> IResult<&str, NonIntegerType> { pub fn non_integer_type(s: Span) -> IResult<Span, NonIntegerType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn net_type(s: &str) -> IResult<&str, NetType> { pub fn net_type(s: Span) -> IResult<Span, NetType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn net_port_type(s: &str) -> IResult<&str, NetPortType> { pub fn net_port_type(s: Span) -> IResult<Span, NetPortType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn variable_port_type(s: &str) -> IResult<&str, VariablePortType> { pub fn variable_port_type(s: Span) -> IResult<Span, VariablePortType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn var_data_type(s: &str) -> IResult<&str, VarDataType> { pub fn var_data_type(s: Span) -> IResult<Span, VarDataType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn signing(s: &str) -> IResult<&str, Signing> { pub fn signing(s: Span) -> IResult<Span, Signing> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn simple_type(s: &str) -> IResult<&str, SimpleType> { pub fn simple_type(s: Span) -> IResult<Span, SimpleType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn struct_union_member(s: &str) -> IResult<&str, StructUnionMember> { pub fn struct_union_member(s: Span) -> IResult<Span, StructUnionMember> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn data_type_or_void(s: &str) -> IResult<&str, DataTypeOrVoid> { pub fn data_type_or_void(s: Span) -> IResult<Span, DataTypeOrVoid> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn struct_union(s: &str) -> IResult<&str, StructUnion> { pub fn struct_union(s: Span) -> IResult<Span, StructUnion> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn type_reference(s: &str) -> IResult<&str, TypeReference> { pub fn type_reference(s: Span) -> IResult<Span, TypeReference> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -59,18 +59,18 @@ pub struct RefDeclaration<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn inout_declaratrion(s: &str) -> IResult<&str, InoutDeclaration> { pub fn inout_declaratrion(s: Span) -> IResult<Span, InoutDeclaration> {
let (s, _) = symbol("inout")(s)?; let (s, _) = symbol("inout")(s)?;
let (s, x) = net_port_type(s)?; let (s, x) = net_port_type(s)?;
let (s, y) = list_of_port_identifiers(s)?; let (s, y) = list_of_port_identifiers(s)?;
Ok((s, InoutDeclaration { nodes: (x, y) })) Ok((s, InoutDeclaration { nodes: (x, y) }))
} }
pub fn input_declaratrion(s: &str) -> IResult<&str, InputDeclaration> { pub fn input_declaratrion(s: Span) -> IResult<Span, InputDeclaration> {
alt((input_declaration_net, input_declaration_variable))(s) alt((input_declaration_net, input_declaration_variable))(s)
} }
pub fn input_declaration_net(s: &str) -> IResult<&str, InputDeclaration> { pub fn input_declaration_net(s: Span) -> IResult<Span, InputDeclaration> {
let (s, _) = symbol("input")(s)?; let (s, _) = symbol("input")(s)?;
let (s, x) = net_port_type(s)?; let (s, x) = net_port_type(s)?;
let (s, y) = list_of_port_identifiers(s)?; let (s, y) = list_of_port_identifiers(s)?;
@ -80,7 +80,7 @@ pub fn input_declaration_net(s: &str) -> IResult<&str, InputDeclaration> {
)) ))
} }
pub fn input_declaration_variable(s: &str) -> IResult<&str, InputDeclaration> { pub fn input_declaration_variable(s: Span) -> IResult<Span, InputDeclaration> {
let (s, _) = symbol("input")(s)?; let (s, _) = symbol("input")(s)?;
let (s, x) = variable_port_type(s)?; let (s, x) = variable_port_type(s)?;
let (s, y) = list_of_variable_identifiers(s)?; let (s, y) = list_of_variable_identifiers(s)?;
@ -90,11 +90,11 @@ pub fn input_declaration_variable(s: &str) -> IResult<&str, InputDeclaration> {
)) ))
} }
pub fn output_declaratrion(s: &str) -> IResult<&str, OutputDeclaration> { pub fn output_declaratrion(s: Span) -> IResult<Span, OutputDeclaration> {
alt((output_declaration_net, output_declaration_variable))(s) alt((output_declaration_net, output_declaration_variable))(s)
} }
pub fn output_declaration_net(s: &str) -> IResult<&str, OutputDeclaration> { pub fn output_declaration_net(s: Span) -> IResult<Span, OutputDeclaration> {
let (s, _) = symbol("output")(s)?; let (s, _) = symbol("output")(s)?;
let (s, x) = net_port_type(s)?; let (s, x) = net_port_type(s)?;
let (s, y) = list_of_port_identifiers(s)?; let (s, y) = list_of_port_identifiers(s)?;
@ -104,7 +104,7 @@ pub fn output_declaration_net(s: &str) -> IResult<&str, OutputDeclaration> {
)) ))
} }
pub fn output_declaration_variable(s: &str) -> IResult<&str, OutputDeclaration> { pub fn output_declaration_variable(s: Span) -> IResult<Span, OutputDeclaration> {
let (s, _) = symbol("output")(s)?; let (s, _) = symbol("output")(s)?;
let (s, x) = variable_port_type(s)?; let (s, x) = variable_port_type(s)?;
let (s, y) = list_of_variable_identifiers(s)?; let (s, y) = list_of_variable_identifiers(s)?;
@ -114,14 +114,14 @@ pub fn output_declaration_variable(s: &str) -> IResult<&str, OutputDeclaration>
)) ))
} }
pub fn interface_port_declaration(s: &str) -> IResult<&str, InterfacePortDeclaration> { pub fn interface_port_declaration(s: Span) -> IResult<Span, InterfacePortDeclaration> {
let (s, x) = interface_identifier(s)?; let (s, x) = interface_identifier(s)?;
let (s, y) = opt(preceded(symbol("."), modport_identifier))(s)?; let (s, y) = opt(preceded(symbol("."), modport_identifier))(s)?;
let (s, z) = list_of_interface_identifiers(s)?; let (s, z) = list_of_interface_identifiers(s)?;
Ok((s, InterfacePortDeclaration { nodes: (x, y, z) })) Ok((s, InterfacePortDeclaration { nodes: (x, y, z) }))
} }
pub fn ref_declaration(s: &str) -> IResult<&str, RefDeclaration> { pub fn ref_declaration(s: Span) -> IResult<Span, RefDeclaration> {
let (s, _) = symbol("ref")(s)?; let (s, _) = symbol("ref")(s)?;
let (s, x) = variable_port_type(s)?; let (s, x) = variable_port_type(s)?;
let (s, y) = list_of_variable_identifiers(s)?; let (s, y) = list_of_variable_identifiers(s)?;

View File

@ -1,4 +1,4 @@
//use crate::parser::*; use crate::parser::*;
//use nom::branch::*; //use nom::branch::*;
//use nom::combinator::*; //use nom::combinator::*;
use nom::error::*; use nom::error::*;
@ -41,18 +41,18 @@ pub enum ChargeStrength {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn drive_strength(s: &str) -> IResult<&str, DriveStrength> { pub fn drive_strength(s: Span) -> IResult<Span, DriveStrength> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn strength0(s: &str) -> IResult<&str, Strength0> { pub fn strength0(s: Span) -> IResult<Span, Strength0> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn strength1(s: &str) -> IResult<&str, Strength1> { pub fn strength1(s: Span) -> IResult<Span, Strength1> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn charge_strength(s: &str) -> IResult<&str, ChargeStrength> { pub fn charge_strength(s: Span) -> IResult<Span, ChargeStrength> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -96,34 +96,34 @@ pub struct TaskPrototype<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn task_declaration(s: &str) -> IResult<&str, TaskDeclaration> { pub fn task_declaration(s: Span) -> IResult<Span, TaskDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn task_body_declaration(s: &str) -> IResult<&str, TaskBodyDeclaration> { pub fn task_body_declaration(s: Span) -> IResult<Span, TaskBodyDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn tf_item_declaration(s: &str) -> IResult<&str, TfItemDeclaration> { pub fn tf_item_declaration(s: Span) -> IResult<Span, TfItemDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn tf_port_list(s: &str) -> IResult<&str, TfPortList> { pub fn tf_port_list(s: Span) -> IResult<Span, TfPortList> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn tf_port_item(s: &str) -> IResult<&str, TfPortItem> { pub fn tf_port_item(s: Span) -> IResult<Span, TfPortItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn tf_port_direction(s: &str) -> IResult<&str, TfPortDirection> { pub fn tf_port_direction(s: Span) -> IResult<Span, TfPortDirection> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn tf_port_declaration(s: &str) -> IResult<&str, TfPortDeclaration> { pub fn tf_port_declaration(s: Span) -> IResult<Span, TfPortDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn task_prototype(s: &str) -> IResult<&str, TaskPrototype> { pub fn task_prototype(s: Span) -> IResult<Span, TaskPrototype> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -183,7 +183,7 @@ pub enum Lifetime {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn data_declaration(s: &str) -> IResult<&str, DataDeclaration> { pub fn data_declaration(s: Span) -> IResult<Span, DataDeclaration> {
alt(( alt((
data_declaration_variable, data_declaration_variable,
map(type_declaration, |x| DataDeclaration::Type(x)), map(type_declaration, |x| DataDeclaration::Type(x)),
@ -194,7 +194,7 @@ pub fn data_declaration(s: &str) -> IResult<&str, DataDeclaration> {
))(s) ))(s)
} }
pub fn data_declaration_variable(s: &str) -> IResult<&str, DataDeclaration> { pub fn data_declaration_variable(s: Span) -> IResult<Span, DataDeclaration> {
let (s, x) = opt(symbol("const"))(s)?; let (s, x) = opt(symbol("const"))(s)?;
let (s, y) = opt(symbol("var"))(s)?; let (s, y) = opt(symbol("var"))(s)?;
let (s, z) = opt(lifetime)(s)?; let (s, z) = opt(lifetime)(s)?;
@ -209,18 +209,18 @@ pub fn data_declaration_variable(s: &str) -> IResult<&str, DataDeclaration> {
)) ))
} }
pub fn package_import_declaration(s: &str) -> IResult<&str, PackageImportDeclaration> { pub fn package_import_declaration(s: Span) -> IResult<Span, PackageImportDeclaration> {
let (s, _) = symbol("import")(s)?; let (s, _) = symbol("import")(s)?;
let (s, x) = separated_nonempty_list(symbol(","), package_import_item)(s)?; let (s, x) = separated_nonempty_list(symbol(","), package_import_item)(s)?;
let (s, _) = symbol(";")(s)?; let (s, _) = symbol(";")(s)?;
Ok((s, PackageImportDeclaration { nodes: (x,) })) Ok((s, PackageImportDeclaration { nodes: (x,) }))
} }
pub fn package_import_item(s: &str) -> IResult<&str, PackageImportItem> { pub fn package_import_item(s: Span) -> IResult<Span, PackageImportItem> {
alt((package_import_item_identifier, package_import_item_asterisk))(s) alt((package_import_item_identifier, package_import_item_asterisk))(s)
} }
pub fn package_import_item_identifier(s: &str) -> IResult<&str, PackageImportItem> { pub fn package_import_item_identifier(s: Span) -> IResult<Span, PackageImportItem> {
let (s, x) = package_identifier(s)?; let (s, x) = package_identifier(s)?;
let (s, _) = symbol("::")(s)?; let (s, _) = symbol("::")(s)?;
let (s, y) = identifier(s)?; let (s, y) = identifier(s)?;
@ -230,7 +230,7 @@ pub fn package_import_item_identifier(s: &str) -> IResult<&str, PackageImportIte
)) ))
} }
pub fn package_import_item_asterisk(s: &str) -> IResult<&str, PackageImportItem> { pub fn package_import_item_asterisk(s: Span) -> IResult<Span, PackageImportItem> {
let (s, x) = package_identifier(s)?; let (s, x) = package_identifier(s)?;
let (s, _) = symbol("::")(s)?; let (s, _) = symbol("::")(s)?;
let (s, _) = symbol("*")(s)?; let (s, _) = symbol("*")(s)?;
@ -240,34 +240,34 @@ pub fn package_import_item_asterisk(s: &str) -> IResult<&str, PackageImportItem>
)) ))
} }
pub fn package_export_declaration(s: &str) -> IResult<&str, PackageExportDeclaration> { pub fn package_export_declaration(s: Span) -> IResult<Span, PackageExportDeclaration> {
alt(( alt((
package_export_declaration_asterisk, package_export_declaration_asterisk,
package_export_declaration_item, package_export_declaration_item,
))(s) ))(s)
} }
pub fn package_export_declaration_asterisk(s: &str) -> IResult<&str, PackageExportDeclaration> { pub fn package_export_declaration_asterisk(s: Span) -> IResult<Span, PackageExportDeclaration> {
let (s, _) = symbol("export")(s)?; let (s, _) = symbol("export")(s)?;
let (s, _) = symbol("*::*")(s)?; let (s, _) = symbol("*::*")(s)?;
let (s, _) = symbol(";")(s)?; let (s, _) = symbol(";")(s)?;
Ok((s, PackageExportDeclaration::Asterisk)) Ok((s, PackageExportDeclaration::Asterisk))
} }
pub fn package_export_declaration_item(s: &str) -> IResult<&str, PackageExportDeclaration> { pub fn package_export_declaration_item(s: Span) -> IResult<Span, PackageExportDeclaration> {
let (s, _) = symbol("export")(s)?; let (s, _) = symbol("export")(s)?;
let (s, x) = separated_nonempty_list(symbol(","), package_import_item)(s)?; let (s, x) = separated_nonempty_list(symbol(","), package_import_item)(s)?;
let (s, _) = symbol(";")(s)?; let (s, _) = symbol(";")(s)?;
Ok((s, PackageExportDeclaration::Item(x))) Ok((s, PackageExportDeclaration::Item(x)))
} }
pub fn genvar_declaration(s: &str) -> IResult<&str, GenvarDeclaration> { pub fn genvar_declaration(s: Span) -> IResult<Span, GenvarDeclaration> {
let (s, _) = symbol("genvar")(s)?; let (s, _) = symbol("genvar")(s)?;
let (s, x) = list_of_genvar_identifiers(s)?; let (s, x) = list_of_genvar_identifiers(s)?;
Ok((s, GenvarDeclaration { nodes: (x,) })) Ok((s, GenvarDeclaration { nodes: (x,) }))
} }
pub fn net_declaration(s: &str) -> IResult<&str, NetDeclaration> { pub fn net_declaration(s: Span) -> IResult<Span, NetDeclaration> {
alt(( alt((
net_declaration_net_type, net_declaration_net_type,
net_declaration_net_type_identifier, net_declaration_net_type_identifier,
@ -275,7 +275,7 @@ pub fn net_declaration(s: &str) -> IResult<&str, NetDeclaration> {
))(s) ))(s)
} }
pub fn net_declaration_net_type(s: &str) -> IResult<&str, NetDeclaration> { pub fn net_declaration_net_type(s: Span) -> IResult<Span, NetDeclaration> {
let (s, x) = net_type(s)?; let (s, x) = net_type(s)?;
let (s, y) = opt(strength)(s)?; let (s, y) = opt(strength)(s)?;
let (s, z) = opt(vector_scalar)(s)?; let (s, z) = opt(vector_scalar)(s)?;
@ -291,21 +291,21 @@ pub fn net_declaration_net_type(s: &str) -> IResult<&str, NetDeclaration> {
)) ))
} }
pub fn strength(s: &str) -> IResult<&str, Strength> { pub fn strength(s: Span) -> IResult<Span, Strength> {
alt(( alt((
map(drive_strength, |x| Strength::Drive(x)), map(drive_strength, |x| Strength::Drive(x)),
map(charge_strength, |x| Strength::Charge(x)), map(charge_strength, |x| Strength::Charge(x)),
))(s) ))(s)
} }
pub fn vector_scalar(s: &str) -> IResult<&str, VectorScalar> { pub fn vector_scalar(s: Span) -> IResult<Span, VectorScalar> {
alt(( alt((
map(symbol("vectored"), |_| VectorScalar::Vectored), map(symbol("vectored"), |_| VectorScalar::Vectored),
map(symbol("scalared"), |_| VectorScalar::Scalared), map(symbol("scalared"), |_| VectorScalar::Scalared),
))(s) ))(s)
} }
pub fn net_declaration_net_type_identifier(s: &str) -> IResult<&str, NetDeclaration> { pub fn net_declaration_net_type_identifier(s: Span) -> IResult<Span, NetDeclaration> {
let (s, x) = net_type_identifier(s)?; let (s, x) = net_type_identifier(s)?;
let (s, y) = opt(delay_control)(s)?; let (s, y) = opt(delay_control)(s)?;
let (s, z) = list_of_net_decl_assignments(s)?; let (s, z) = list_of_net_decl_assignments(s)?;
@ -316,7 +316,7 @@ pub fn net_declaration_net_type_identifier(s: &str) -> IResult<&str, NetDeclarat
)) ))
} }
pub fn net_declaration_interconnect(s: &str) -> IResult<&str, NetDeclaration> { pub fn net_declaration_interconnect(s: Span) -> IResult<Span, NetDeclaration> {
let (s, _) = symbol("interconnect")(s)?; let (s, _) = symbol("interconnect")(s)?;
let (s, x) = implicit_data_type(s)?; let (s, x) = implicit_data_type(s)?;
let (s, y) = opt(preceded(symbol("#"), delay_value))(s)?; let (s, y) = opt(preceded(symbol("#"), delay_value))(s)?;
@ -334,7 +334,7 @@ pub fn net_declaration_interconnect(s: &str) -> IResult<&str, NetDeclaration> {
)) ))
} }
pub fn type_declaration(s: &str) -> IResult<&str, TypeDeclaration> { pub fn type_declaration(s: Span) -> IResult<Span, TypeDeclaration> {
alt(( alt((
type_declaration_data_type, type_declaration_data_type,
type_declaration_interface, type_declaration_interface,
@ -342,7 +342,7 @@ pub fn type_declaration(s: &str) -> IResult<&str, TypeDeclaration> {
))(s) ))(s)
} }
pub fn type_declaration_data_type(s: &str) -> IResult<&str, TypeDeclaration> { pub fn type_declaration_data_type(s: Span) -> IResult<Span, TypeDeclaration> {
let (s, _) = symbol("typedef")(s)?; let (s, _) = symbol("typedef")(s)?;
let (s, x) = data_type(s)?; let (s, x) = data_type(s)?;
let (s, y) = type_identifier(s)?; let (s, y) = type_identifier(s)?;
@ -354,7 +354,7 @@ pub fn type_declaration_data_type(s: &str) -> IResult<&str, TypeDeclaration> {
)) ))
} }
pub fn type_declaration_interface(s: &str) -> IResult<&str, TypeDeclaration> { pub fn type_declaration_interface(s: Span) -> IResult<Span, TypeDeclaration> {
let (s, _) = symbol("typedef")(s)?; let (s, _) = symbol("typedef")(s)?;
let (s, x) = interface_instance_identifier(s)?; let (s, x) = interface_instance_identifier(s)?;
let (s, y) = constant_bit_select(s)?; let (s, y) = constant_bit_select(s)?;
@ -370,7 +370,7 @@ pub fn type_declaration_interface(s: &str) -> IResult<&str, TypeDeclaration> {
)) ))
} }
pub fn type_declaration_reserved(s: &str) -> IResult<&str, TypeDeclaration> { pub fn type_declaration_reserved(s: Span) -> IResult<Span, TypeDeclaration> {
let (s, _) = symbol("typedef")(s)?; let (s, _) = symbol("typedef")(s)?;
let (s, x) = type_declaration_keyword(s)?; let (s, x) = type_declaration_keyword(s)?;
let (s, y) = type_identifier(s)?; let (s, y) = type_identifier(s)?;
@ -381,7 +381,7 @@ pub fn type_declaration_reserved(s: &str) -> IResult<&str, TypeDeclaration> {
)) ))
} }
pub fn type_declaration_keyword(s: &str) -> IResult<&str, TypeDeclarationKeyword> { pub fn type_declaration_keyword(s: Span) -> IResult<Span, TypeDeclarationKeyword> {
alt(( alt((
map(symbol("enum"), |_| TypeDeclarationKeyword::Enum), map(symbol("enum"), |_| TypeDeclarationKeyword::Enum),
map(symbol("struct"), |_| TypeDeclarationKeyword::Struct), map(symbol("struct"), |_| TypeDeclarationKeyword::Struct),
@ -393,14 +393,14 @@ pub fn type_declaration_keyword(s: &str) -> IResult<&str, TypeDeclarationKeyword
))(s) ))(s)
} }
pub fn net_type_declaration(s: &str) -> IResult<&str, NetTypeDeclaration> { pub fn net_type_declaration(s: Span) -> IResult<Span, NetTypeDeclaration> {
alt(( alt((
net_type_declaration_data_type, net_type_declaration_data_type,
net_type_declaration_net_type, net_type_declaration_net_type,
))(s) ))(s)
} }
pub fn net_type_declaration_data_type(s: &str) -> IResult<&str, NetTypeDeclaration> { pub fn net_type_declaration_data_type(s: Span) -> IResult<Span, NetTypeDeclaration> {
let (s, _) = symbol("nettype")(s)?; let (s, _) = symbol("nettype")(s)?;
let (s, x) = data_type(s)?; let (s, x) = data_type(s)?;
let (s, y) = net_type_identifier(s)?; let (s, y) = net_type_identifier(s)?;
@ -415,7 +415,7 @@ pub fn net_type_declaration_data_type(s: &str) -> IResult<&str, NetTypeDeclarati
)) ))
} }
pub fn net_type_declaration_net_type(s: &str) -> IResult<&str, NetTypeDeclaration> { pub fn net_type_declaration_net_type(s: Span) -> IResult<Span, NetTypeDeclaration> {
let (s, _) = symbol("nettype")(s)?; let (s, _) = symbol("nettype")(s)?;
let (s, x) = opt(package_scope_or_class_scope)(s)?; let (s, x) = opt(package_scope_or_class_scope)(s)?;
let (s, y) = net_type_identifier(s)?; let (s, y) = net_type_identifier(s)?;
@ -427,7 +427,7 @@ pub fn net_type_declaration_net_type(s: &str) -> IResult<&str, NetTypeDeclaratio
)) ))
} }
pub fn lifetime(s: &str) -> IResult<&str, Lifetime> { pub fn lifetime(s: Span) -> IResult<Span, Lifetime> {
alt(( alt((
map(symbol("static"), |_| Lifetime::Static), map(symbol("static"), |_| Lifetime::Static),
map(symbol("automatic"), |_| Lifetime::Automatic), map(symbol("automatic"), |_| Lifetime::Automatic),

View File

@ -39,7 +39,16 @@ pub struct MultipleConcatenation<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct StreamingConcatenation<'a> { pub struct StreamingConcatenation<'a> {
pub nodes: (Operator<'a>, Option<SliceSize<'a>>, StreamConcatenation<'a>), pub nodes: (
StreamOperator<'a>,
Option<SliceSize<'a>>,
StreamConcatenation<'a>,
),
}
#[derive(Debug)]
pub struct StreamOperator<'a> {
pub nodes: (Symbol<'a>,),
} }
#[derive(Debug)] #[derive(Debug)]
@ -60,22 +69,31 @@ pub struct StreamExpression<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct ArrayRangeExpression<'a> { pub struct ArrayRangeExpression<'a> {
pub nodes: (Expression<'a>, Option<Operator<'a>>, Option<Expression<'a>>), pub nodes: (
Expression<'a>,
Option<ArrayRangeOperator<'a>>,
Option<Expression<'a>>,
),
}
#[derive(Debug)]
pub struct ArrayRangeOperator<'a> {
pub nodes: (Symbol<'a>,),
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn concatenation(s: &str) -> IResult<&str, Concatenation> { pub fn concatenation(s: Span) -> IResult<Span, Concatenation> {
let (s, x) = brace(separated_nonempty_list(symbol(","), expression))(s)?; let (s, x) = brace(separated_nonempty_list(symbol(","), expression))(s)?;
Ok((s, Concatenation { nodes: (x,) })) Ok((s, Concatenation { nodes: (x,) }))
} }
pub fn constant_concatenation(s: &str) -> IResult<&str, ConstantConcatenation> { pub fn constant_concatenation(s: Span) -> IResult<Span, ConstantConcatenation> {
let (s, x) = brace(separated_nonempty_list(symbol(","), constant_expression))(s)?; let (s, x) = brace(separated_nonempty_list(symbol(","), constant_expression))(s)?;
Ok((s, ConstantConcatenation { nodes: (x,) })) Ok((s, ConstantConcatenation { nodes: (x,) }))
} }
pub fn constant_multiple_concatenation(s: &str) -> IResult<&str, ConstantMultipleConcatenation> { pub fn constant_multiple_concatenation(s: Span) -> IResult<Span, ConstantMultipleConcatenation> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, x) = constant_expression(s)?; let (s, x) = constant_expression(s)?;
let (s, y) = constant_concatenation(s)?; let (s, y) = constant_concatenation(s)?;
@ -83,14 +101,14 @@ pub fn constant_multiple_concatenation(s: &str) -> IResult<&str, ConstantMultipl
Ok((s, ConstantMultipleConcatenation { nodes: (x, y) })) Ok((s, ConstantMultipleConcatenation { nodes: (x, y) }))
} }
pub fn module_path_concatenation(s: &str) -> IResult<&str, ModulePathConcatenation> { pub fn module_path_concatenation(s: Span) -> IResult<Span, ModulePathConcatenation> {
let (s, x) = brace(separated_nonempty_list(symbol(","), module_path_expression))(s)?; let (s, x) = brace(separated_nonempty_list(symbol(","), module_path_expression))(s)?;
Ok((s, ModulePathConcatenation { nodes: (x,) })) Ok((s, ModulePathConcatenation { nodes: (x,) }))
} }
pub fn module_path_multiple_concatenation( pub fn module_path_multiple_concatenation(
s: &str, s: Span,
) -> IResult<&str, ModulePathMultipleConcatenation> { ) -> IResult<Span, ModulePathMultipleConcatenation> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, x) = constant_expression(s)?; let (s, x) = constant_expression(s)?;
let (s, y) = module_path_concatenation(s)?; let (s, y) = module_path_concatenation(s)?;
@ -98,7 +116,7 @@ pub fn module_path_multiple_concatenation(
Ok((s, ModulePathMultipleConcatenation { nodes: (x, y) })) Ok((s, ModulePathMultipleConcatenation { nodes: (x, y) }))
} }
pub fn multiple_concatenation(s: &str) -> IResult<&str, MultipleConcatenation> { pub fn multiple_concatenation(s: Span) -> IResult<Span, MultipleConcatenation> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
let (s, y) = concatenation(s)?; let (s, y) = concatenation(s)?;
@ -106,7 +124,7 @@ pub fn multiple_concatenation(s: &str) -> IResult<&str, MultipleConcatenation> {
Ok((s, MultipleConcatenation { nodes: (x, y) })) Ok((s, MultipleConcatenation { nodes: (x, y) }))
} }
pub fn streaming_concatenation(s: &str) -> IResult<&str, StreamingConcatenation> { pub fn streaming_concatenation(s: Span) -> IResult<Span, StreamingConcatenation> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, x) = stream_operator(s)?; let (s, x) = stream_operator(s)?;
let (s, y) = opt(slice_size)(s)?; let (s, y) = opt(slice_size)(s)?;
@ -115,34 +133,34 @@ pub fn streaming_concatenation(s: &str) -> IResult<&str, StreamingConcatenation>
Ok((s, StreamingConcatenation { nodes: (x, y, z) })) Ok((s, StreamingConcatenation { nodes: (x, y, z) }))
} }
pub fn stream_operator(s: &str) -> IResult<&str, Operator> { pub fn stream_operator(s: Span) -> IResult<Span, StreamOperator> {
alt(( alt((
map(symbol(">>"), |x| Operator { nodes: (x,) }), map(symbol(">>"), |x| StreamOperator { nodes: (x,) }),
map(symbol("<<"), |x| Operator { nodes: (x,) }), map(symbol("<<"), |x| StreamOperator { nodes: (x,) }),
))(s) ))(s)
} }
pub fn slice_size(s: &str) -> IResult<&str, SliceSize> { pub fn slice_size(s: Span) -> IResult<Span, SliceSize> {
alt(( alt((
map(simple_type, |x| SliceSize::Type(x)), map(simple_type, |x| SliceSize::Type(x)),
map(constant_expression, |x| SliceSize::Expression(x)), map(constant_expression, |x| SliceSize::Expression(x)),
))(s) ))(s)
} }
pub fn stream_concatenation(s: &str) -> IResult<&str, StreamConcatenation> { pub fn stream_concatenation(s: Span) -> IResult<Span, StreamConcatenation> {
let (s, x) = brace(separated_nonempty_list(symbol(","), stream_expression))(s)?; let (s, x) = brace(separated_nonempty_list(symbol(","), stream_expression))(s)?;
Ok((s, StreamConcatenation { nodes: (x,) })) Ok((s, StreamConcatenation { nodes: (x,) }))
} }
pub fn stream_expression(s: &str) -> IResult<&str, StreamExpression> { pub fn stream_expression(s: Span) -> IResult<Span, StreamExpression> {
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
let (s, y) = opt(preceded(symbol("with"), bracket(array_range_expression)))(s)?; let (s, y) = opt(preceded(symbol("with"), bracket(array_range_expression)))(s)?;
Ok((s, StreamExpression { nodes: (x, y) })) Ok((s, StreamExpression { nodes: (x, y) }))
} }
pub fn array_range_expression(s: &str) -> IResult<&str, ArrayRangeExpression> { pub fn array_range_expression(s: Span) -> IResult<Span, ArrayRangeExpression> {
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
let (s, y) = opt(pair(array_range_expression_operator, expression))(s)?; let (s, y) = opt(pair(array_range_operator, expression))(s)?;
let (y, z) = if let Some((y, z)) = y { let (y, z) = if let Some((y, z)) = y {
(Some(y), Some(z)) (Some(y), Some(z))
} else { } else {
@ -151,15 +169,15 @@ pub fn array_range_expression(s: &str) -> IResult<&str, ArrayRangeExpression> {
Ok((s, ArrayRangeExpression { nodes: (x, y, z) })) Ok((s, ArrayRangeExpression { nodes: (x, y, z) }))
} }
pub fn array_range_expression_operator(s: &str) -> IResult<&str, Operator> { pub fn array_range_operator(s: Span) -> IResult<Span, ArrayRangeOperator> {
alt(( alt((
map(symbol(":"), |x| Operator { nodes: (x,) }), map(symbol(":"), |x| ArrayRangeOperator { nodes: (x,) }),
map(symbol("+:"), |x| Operator { nodes: (x,) }), map(symbol("+:"), |x| ArrayRangeOperator { nodes: (x,) }),
map(symbol("-:"), |x| Operator { nodes: (x,) }), map(symbol("-:"), |x| ArrayRangeOperator { nodes: (x,) }),
))(s) ))(s)
} }
pub fn empty_unpacked_array_concatenation(s: &str) -> IResult<&str, ()> { pub fn empty_unpacked_array_concatenation(s: Span) -> IResult<Span, ()> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, _) = symbol("}")(s)?; let (s, _) = symbol("}")(s)?;
Ok((s, ())) Ok((s, ()))

View File

@ -63,11 +63,11 @@ pub struct NonrangeVariableLvalue<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn net_lvalue(s: &str) -> IResult<&str, NetLvalue> { pub fn net_lvalue(s: Span) -> IResult<Span, NetLvalue> {
alt((net_lvalue_identifier, net_lvalue_lvalue, net_lvalue_pattern))(s) alt((net_lvalue_identifier, net_lvalue_lvalue, net_lvalue_pattern))(s)
} }
pub fn net_lvalue_identifier(s: &str) -> IResult<&str, NetLvalue> { pub fn net_lvalue_identifier(s: Span) -> IResult<Span, NetLvalue> {
let (s, x) = ps_or_hierarchical_net_identifier(s)?; let (s, x) = ps_or_hierarchical_net_identifier(s)?;
let (s, y) = constant_select(s)?; let (s, y) = constant_select(s)?;
Ok(( Ok((
@ -76,7 +76,7 @@ pub fn net_lvalue_identifier(s: &str) -> IResult<&str, NetLvalue> {
)) ))
} }
pub fn net_lvalue_pattern(s: &str) -> IResult<&str, NetLvalue> { pub fn net_lvalue_pattern(s: Span) -> IResult<Span, NetLvalue> {
let (s, x) = opt(assignment_pattern_expression_type)(s)?; let (s, x) = opt(assignment_pattern_expression_type)(s)?;
let (s, y) = assignment_pattern_net_lvalue(s)?; let (s, y) = assignment_pattern_net_lvalue(s)?;
Ok(( Ok((
@ -85,7 +85,7 @@ pub fn net_lvalue_pattern(s: &str) -> IResult<&str, NetLvalue> {
)) ))
} }
pub fn net_lvalue_lvalue(s: &str) -> IResult<&str, NetLvalue> { pub fn net_lvalue_lvalue(s: Span) -> IResult<Span, NetLvalue> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, x) = net_lvalue(s)?; let (s, x) = net_lvalue(s)?;
let (s, y) = many0(preceded(symbol(","), net_lvalue))(s)?; let (s, y) = many0(preceded(symbol(","), net_lvalue))(s)?;
@ -100,7 +100,7 @@ pub fn net_lvalue_lvalue(s: &str) -> IResult<&str, NetLvalue> {
Ok((s, NetLvalue::Lvalue(Box::new(ret)))) Ok((s, NetLvalue::Lvalue(Box::new(ret))))
} }
pub fn variable_lvalue(s: &str) -> IResult<&str, VariableLvalue> { pub fn variable_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
alt(( alt((
variable_lvalue_identifier, variable_lvalue_identifier,
variable_lvalue_lvalue, variable_lvalue_lvalue,
@ -111,7 +111,7 @@ pub fn variable_lvalue(s: &str) -> IResult<&str, VariableLvalue> {
))(s) ))(s)
} }
pub fn variable_lvalue_identifier(s: &str) -> IResult<&str, VariableLvalue> { pub fn variable_lvalue_identifier(s: Span) -> IResult<Span, VariableLvalue> {
let (s, x) = opt(implicit_class_handle_or_package_scope)(s)?; let (s, x) = opt(implicit_class_handle_or_package_scope)(s)?;
let (s, y) = hierarchical_variable_identifier(s)?; let (s, y) = hierarchical_variable_identifier(s)?;
let (s, z) = select(s)?; let (s, z) = select(s)?;
@ -121,7 +121,7 @@ pub fn variable_lvalue_identifier(s: &str) -> IResult<&str, VariableLvalue> {
)) ))
} }
pub fn variable_lvalue_pattern(s: &str) -> IResult<&str, VariableLvalue> { pub fn variable_lvalue_pattern(s: Span) -> IResult<Span, VariableLvalue> {
let (s, x) = opt(assignment_pattern_expression_type)(s)?; let (s, x) = opt(assignment_pattern_expression_type)(s)?;
let (s, y) = assignment_pattern_variable_lvalue(s)?; let (s, y) = assignment_pattern_variable_lvalue(s)?;
Ok(( Ok((
@ -130,7 +130,7 @@ pub fn variable_lvalue_pattern(s: &str) -> IResult<&str, VariableLvalue> {
)) ))
} }
pub fn variable_lvalue_lvalue(s: &str) -> IResult<&str, VariableLvalue> { pub fn variable_lvalue_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, x) = variable_lvalue(s)?; let (s, x) = variable_lvalue(s)?;
let (s, y) = many0(preceded(symbol(","), variable_lvalue))(s)?; let (s, y) = many0(preceded(symbol(","), variable_lvalue))(s)?;
@ -145,7 +145,7 @@ pub fn variable_lvalue_lvalue(s: &str) -> IResult<&str, VariableLvalue> {
Ok((s, VariableLvalue::Lvalue(Box::new(ret)))) Ok((s, VariableLvalue::Lvalue(Box::new(ret))))
} }
pub fn nonrange_variable_lvalue(s: &str) -> IResult<&str, NonrangeVariableLvalue> { pub fn nonrange_variable_lvalue(s: Span) -> IResult<Span, NonrangeVariableLvalue> {
let (s, x) = opt(implicit_class_handle_or_package_scope)(s)?; let (s, x) = opt(implicit_class_handle_or_package_scope)(s)?;
let (s, y) = hierarchical_variable_identifier(s)?; let (s, y) = hierarchical_variable_identifier(s)?;
let (s, z) = nonrange_select(s)?; let (s, z) = nonrange_select(s)?;
@ -160,45 +160,45 @@ mod tests {
#[test] #[test]
fn test() { fn test() {
assert_eq!( //assert_eq!(
format!("{:?}", all_consuming(net_lvalue)("a")), // format!("{:?}", all_consuming(net_lvalue)(Span::new("a"))),
"Ok((\"\", Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } } }, select: ConstantSelect { member: None, bit_select: [], part_select_range: None } })))" // "Ok((\"\", Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } } }, select: ConstantSelect { member: None, bit_select: [], part_select_range: None } })))"
); //);
assert_eq!( //assert_eq!(
format!("{:?}", all_consuming(net_lvalue)("a[1][2]")), // format!("{:?}", all_consuming(net_lvalue)(Span::new("a[1][2]"))),
"Ok((\"\", Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } } }, select: ConstantSelect { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"2\")))))], part_select_range: None } })))" // "Ok((\"\", Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } } }, select: ConstantSelect { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"2\")))))], part_select_range: None } })))"
); //);
assert_eq!( //assert_eq!(
format!("{:?}", all_consuming(net_lvalue)("a[1][10:5]")), // format!("{:?}", all_consuming(net_lvalue)(Span::new("a[1][10:5]"))),
"Ok((\"\", Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } } }, select: ConstantSelect { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))], part_select_range: Some(Range((Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"10\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"5\")))))))) } })))" // "Ok((\"\", Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } } }, select: ConstantSelect { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))], part_select_range: Some(Range((Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"10\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"5\")))))))) } })))"
); //);
assert_eq!( //assert_eq!(
format!("{:?}", all_consuming(net_lvalue)("{a, b[1], c}")), // format!("{:?}", all_consuming(net_lvalue)(Span::new("{a, b[1], c}"))),
"Ok((\"\", Lvalue([Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } } }, select: ConstantSelect { member: None, bit_select: [], part_select_range: None } }), Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"b\" } } }, select: ConstantSelect { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))], part_select_range: None } }), Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"c\" } } }, select: ConstantSelect { member: None, bit_select: [], part_select_range: None } })])))" // "Ok((\"\", Lvalue([Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } } }, select: ConstantSelect { member: None, bit_select: [], part_select_range: None } }), Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"b\" } } }, select: ConstantSelect { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))], part_select_range: None } }), Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"c\" } } }, select: ConstantSelect { member: None, bit_select: [], part_select_range: None } })])))"
); //);
assert_eq!( //assert_eq!(
format!("{:?}", all_consuming(variable_lvalue)("a")), // format!("{:?}", all_consuming(variable_lvalue)(Span::new("a"))),
"Ok((\"\", Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [], part_select_range: None } })))" // "Ok((\"\", Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [], part_select_range: None } })))"
); //);
assert_eq!( //assert_eq!(
format!("{:?}", all_consuming(variable_lvalue)("a[1][2]")), // format!("{:?}", all_consuming(variable_lvalue)(Span::new("a[1][2]"))),
"Ok((\"\", Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"2\")))))], part_select_range: None } })))" // "Ok((\"\", Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"2\")))))], part_select_range: None } })))"
); //);
assert_eq!( //assert_eq!(
format!("{:?}", all_consuming(variable_lvalue)("a[1][10:5]")), // format!("{:?}", all_consuming(variable_lvalue)(Span::new("a[1][10:5]"))),
"Ok((\"\", Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))], part_select_range: Some(Range((Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"10\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"5\")))))))) } })))" // "Ok((\"\", Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))], part_select_range: Some(Range((Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"10\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"5\")))))))) } })))"
); //);
assert_eq!( //assert_eq!(
format!("{:?}", all_consuming(variable_lvalue)("{a, b[1], c}")), // format!("{:?}", all_consuming(variable_lvalue)(Span::new("{a, b[1], c}"))),
"Ok((\"\", Lvalue([Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [], part_select_range: None } }), Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"b\" } }, select: Select { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))], part_select_range: None } }), Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"c\" } }, select: Select { member: None, bit_select: [], part_select_range: None } })])))" // "Ok((\"\", Lvalue([Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [], part_select_range: None } }), Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"b\" } }, select: Select { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))], part_select_range: None } }), Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"c\" } }, select: Select { member: None, bit_select: [], part_select_range: None } })])))"
); //);
assert_eq!( //assert_eq!(
format!("{:?}", all_consuming(nonrange_variable_lvalue)("a")), // format!("{:?}", all_consuming(nonrange_variable_lvalue)(Span::new("a"))),
"Ok((\"\", NonrangeVariableLvalue { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [], part_select_range: None } }))" // "Ok((\"\", NonrangeVariableLvalue { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [], part_select_range: None } }))"
); //);
assert_eq!( //assert_eq!(
format!("{:?}", all_consuming(nonrange_variable_lvalue)("a[1][2]")), // format!("{:?}", all_consuming(nonrange_variable_lvalue)(Span::new("a[1][2]"))),
"Ok((\"\", NonrangeVariableLvalue { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"2\")))))], part_select_range: None } }))" // "Ok((\"\", NonrangeVariableLvalue { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"2\")))))], part_select_range: None } }))"
); //);
} }
} }

View File

@ -14,12 +14,20 @@ pub enum IncOrDecExpression<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct IncOrDecExpressionPrefix<'a> { pub struct IncOrDecExpressionPrefix<'a> {
pub nodes: (Operator<'a>, Vec<AttributeInstance<'a>>, VariableLvalue<'a>), pub nodes: (
IncOrDecOperator<'a>,
Vec<AttributeInstance<'a>>,
VariableLvalue<'a>,
),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct IncOrDecExpressionSuffix<'a> { pub struct IncOrDecExpressionSuffix<'a> {
pub nodes: (VariableLvalue<'a>, Vec<AttributeInstance<'a>>, Operator<'a>), pub nodes: (
VariableLvalue<'a>,
Vec<AttributeInstance<'a>>,
IncOrDecOperator<'a>,
),
} }
#[derive(Debug)] #[derive(Debug)]
@ -43,7 +51,7 @@ pub enum ConstantExpression<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct ConstantExpressionUnary<'a> { pub struct ConstantExpressionUnary<'a> {
pub nodes: ( pub nodes: (
Operator<'a>, UnaryOperator<'a>,
Vec<AttributeInstance<'a>>, Vec<AttributeInstance<'a>>,
ConstantPrimary<'a>, ConstantPrimary<'a>,
), ),
@ -53,7 +61,7 @@ pub struct ConstantExpressionUnary<'a> {
pub struct ConstantExpressionBinary<'a> { pub struct ConstantExpressionBinary<'a> {
pub nodes: ( pub nodes: (
ConstantExpression<'a>, ConstantExpression<'a>,
Operator<'a>, BinaryOperator<'a>,
Vec<AttributeInstance<'a>>, Vec<AttributeInstance<'a>>,
ConstantExpression<'a>, ConstantExpression<'a>,
), ),
@ -114,7 +122,16 @@ pub struct ConstantRange<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct ConstantIndexedRange<'a> { pub struct ConstantIndexedRange<'a> {
pub nodes: (ConstantExpression<'a>, Operator<'a>, ConstantExpression<'a>), pub nodes: (
ConstantExpression<'a>,
ConstantIndexedRangeOperator<'a>,
ConstantExpression<'a>,
),
}
#[derive(Debug)]
pub struct ConstantIndexedRangeOperator<'a> {
pub nodes: (Symbol<'a>,),
} }
#[derive(Debug)] #[derive(Debug)]
@ -131,14 +148,14 @@ pub enum Expression<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct ExpressionUnary<'a> { pub struct ExpressionUnary<'a> {
pub nodes: (Operator<'a>, Vec<AttributeInstance<'a>>, Primary<'a>), pub nodes: (UnaryOperator<'a>, Vec<AttributeInstance<'a>>, Primary<'a>),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct ExpressionBinary<'a> { pub struct ExpressionBinary<'a> {
pub nodes: ( pub nodes: (
Expression<'a>, Expression<'a>,
Operator<'a>, BinaryOperator<'a>,
Vec<AttributeInstance<'a>>, Vec<AttributeInstance<'a>>,
Expression<'a>, Expression<'a>,
), ),
@ -187,7 +204,7 @@ pub enum ModulePathExpression<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct ModulePathExpressionUnary<'a> { pub struct ModulePathExpressionUnary<'a> {
pub nodes: ( pub nodes: (
Operator<'a>, UnaryModulePathOperator<'a>,
Vec<AttributeInstance<'a>>, Vec<AttributeInstance<'a>>,
ModulePathPrimary<'a>, ModulePathPrimary<'a>,
), ),
@ -197,7 +214,7 @@ pub struct ModulePathExpressionUnary<'a> {
pub struct ModulePathExpressionBinary<'a> { pub struct ModulePathExpressionBinary<'a> {
pub nodes: ( pub nodes: (
ModulePathExpression<'a>, ModulePathExpression<'a>,
Operator<'a>, BinaryModulePathOperator<'a>,
Vec<AttributeInstance<'a>>, Vec<AttributeInstance<'a>>,
ModulePathExpression<'a>, ModulePathExpression<'a>,
), ),
@ -223,11 +240,11 @@ pub enum PartSelectRange<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn inc_or_dec_expression(s: &str) -> IResult<&str, IncOrDecExpression> { pub fn inc_or_dec_expression(s: Span) -> IResult<Span, IncOrDecExpression> {
alt((inc_or_dec_expression_prefix, inc_or_dec_expression_suffix))(s) alt((inc_or_dec_expression_prefix, inc_or_dec_expression_suffix))(s)
} }
pub fn inc_or_dec_expression_prefix(s: &str) -> IResult<&str, IncOrDecExpression> { pub fn inc_or_dec_expression_prefix(s: Span) -> IResult<Span, IncOrDecExpression> {
let (s, x) = inc_or_dec_operator(s)?; let (s, x) = inc_or_dec_operator(s)?;
let (s, y) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, z) = variable_lvalue(s)?; let (s, z) = variable_lvalue(s)?;
@ -237,7 +254,7 @@ pub fn inc_or_dec_expression_prefix(s: &str) -> IResult<&str, IncOrDecExpression
)) ))
} }
pub fn inc_or_dec_expression_suffix(s: &str) -> IResult<&str, IncOrDecExpression> { pub fn inc_or_dec_expression_suffix(s: Span) -> IResult<Span, IncOrDecExpression> {
let (s, x) = variable_lvalue(s)?; let (s, x) = variable_lvalue(s)?;
let (s, y) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, z) = inc_or_dec_operator(s)?; let (s, z) = inc_or_dec_operator(s)?;
@ -247,7 +264,7 @@ pub fn inc_or_dec_expression_suffix(s: &str) -> IResult<&str, IncOrDecExpression
)) ))
} }
pub fn conditional_expression(s: &str) -> IResult<&str, ConditionalExpression> { pub fn conditional_expression(s: Span) -> IResult<Span, ConditionalExpression> {
let (s, x) = cond_predicate(s)?; let (s, x) = cond_predicate(s)?;
let (s, _) = symbol("?")(s)?; let (s, _) = symbol("?")(s)?;
let (s, y) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
@ -262,7 +279,7 @@ pub fn conditional_expression(s: &str) -> IResult<&str, ConditionalExpression> {
)) ))
} }
pub fn constant_expression(s: &str) -> IResult<&str, ConstantExpression> { pub fn constant_expression(s: Span) -> IResult<Span, ConstantExpression> {
alt(( alt((
map(constant_primary, |x| { map(constant_primary, |x| {
ConstantExpression::Nullary(Box::new(x)) ConstantExpression::Nullary(Box::new(x))
@ -273,7 +290,7 @@ pub fn constant_expression(s: &str) -> IResult<&str, ConstantExpression> {
))(s) ))(s)
} }
pub fn constant_expression_unary(s: &str) -> IResult<&str, ConstantExpression> { pub fn constant_expression_unary(s: Span) -> IResult<Span, ConstantExpression> {
let (s, x) = unary_operator(s)?; let (s, x) = unary_operator(s)?;
let (s, y) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, z) = constant_primary(s)?; let (s, z) = constant_primary(s)?;
@ -283,7 +300,7 @@ pub fn constant_expression_unary(s: &str) -> IResult<&str, ConstantExpression> {
)) ))
} }
pub fn constant_expression_binary(s: &str) -> IResult<&str, ConstantExpression> { pub fn constant_expression_binary(s: Span) -> IResult<Span, ConstantExpression> {
let (s, x) = constant_expression(s)?; let (s, x) = constant_expression(s)?;
let (s, y) = binary_operator(s)?; let (s, y) = binary_operator(s)?;
let (s, z) = many0(attribute_instance)(s)?; let (s, z) = many0(attribute_instance)(s)?;
@ -296,7 +313,7 @@ pub fn constant_expression_binary(s: &str) -> IResult<&str, ConstantExpression>
)) ))
} }
pub fn constant_expression_ternary(s: &str) -> IResult<&str, ConstantExpression> { pub fn constant_expression_ternary(s: Span) -> IResult<Span, ConstantExpression> {
let (s, x) = constant_expression(s)?; let (s, x) = constant_expression(s)?;
let (s, _) = symbol("?")(s)?; let (s, _) = symbol("?")(s)?;
let (s, y) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
@ -311,7 +328,7 @@ pub fn constant_expression_ternary(s: &str) -> IResult<&str, ConstantExpression>
)) ))
} }
pub fn constant_mintypmax_expression(s: &str) -> IResult<&str, ConstantMintypmaxExpression> { pub fn constant_mintypmax_expression(s: Span) -> IResult<Span, ConstantMintypmaxExpression> {
alt(( alt((
constant_mintypmax_expression_ternary, constant_mintypmax_expression_ternary,
map(constant_expression, |x| { map(constant_expression, |x| {
@ -321,8 +338,8 @@ pub fn constant_mintypmax_expression(s: &str) -> IResult<&str, ConstantMintypmax
} }
pub fn constant_mintypmax_expression_ternary( pub fn constant_mintypmax_expression_ternary(
s: &str, s: Span,
) -> IResult<&str, ConstantMintypmaxExpression> { ) -> IResult<Span, ConstantMintypmaxExpression> {
let (s, x) = constant_expression(s)?; let (s, x) = constant_expression(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
let (s, y) = constant_expression(s)?; let (s, y) = constant_expression(s)?;
@ -331,7 +348,7 @@ pub fn constant_mintypmax_expression_ternary(
Ok((s, ConstantMintypmaxExpression::Ternary((x, y, z)))) Ok((s, ConstantMintypmaxExpression::Ternary((x, y, z))))
} }
pub fn constant_param_expression(s: &str) -> IResult<&str, ConstantParamExpression> { pub fn constant_param_expression(s: Span) -> IResult<Span, ConstantParamExpression> {
alt(( alt((
map(symbol("$"), |_| ConstantParamExpression::Dollar), map(symbol("$"), |_| ConstantParamExpression::Dollar),
map(constant_mintypmax_expression, |x| { map(constant_mintypmax_expression, |x| {
@ -341,7 +358,7 @@ pub fn constant_param_expression(s: &str) -> IResult<&str, ConstantParamExpressi
))(s) ))(s)
} }
pub fn param_expression(s: &str) -> IResult<&str, ParamExpression> { pub fn param_expression(s: Span) -> IResult<Span, ParamExpression> {
alt(( alt((
map(symbol("$"), |_| ParamExpression::Dollar), map(symbol("$"), |_| ParamExpression::Dollar),
map(mintypmax_expression, |x| ParamExpression::Mintypmax(x)), map(mintypmax_expression, |x| ParamExpression::Mintypmax(x)),
@ -349,7 +366,7 @@ pub fn param_expression(s: &str) -> IResult<&str, ParamExpression> {
))(s) ))(s)
} }
pub fn constant_range_expression(s: &str) -> IResult<&str, ConstantRangeExpression> { pub fn constant_range_expression(s: Span) -> IResult<Span, ConstantRangeExpression> {
alt(( alt((
map(constant_part_select_range, |x| { map(constant_part_select_range, |x| {
ConstantRangeExpression::PartSelectRange(x) ConstantRangeExpression::PartSelectRange(x)
@ -360,7 +377,7 @@ pub fn constant_range_expression(s: &str) -> IResult<&str, ConstantRangeExpressi
))(s) ))(s)
} }
pub fn constant_part_select_range(s: &str) -> IResult<&str, ConstantPartSelectRange> { pub fn constant_part_select_range(s: Span) -> IResult<Span, ConstantPartSelectRange> {
alt(( alt((
map(constant_range, |x| ConstantPartSelectRange::Range(x)), map(constant_range, |x| ConstantPartSelectRange::Range(x)),
map(constant_indexed_range, |x| { map(constant_indexed_range, |x| {
@ -369,23 +386,23 @@ pub fn constant_part_select_range(s: &str) -> IResult<&str, ConstantPartSelectRa
))(s) ))(s)
} }
pub fn constant_range(s: &str) -> IResult<&str, ConstantRange> { pub fn constant_range(s: Span) -> IResult<Span, ConstantRange> {
let (s, x) = constant_expression(s)?; let (s, x) = constant_expression(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
let (s, y) = constant_expression(s)?; let (s, y) = constant_expression(s)?;
Ok((s, ConstantRange { nodes: (x, y) })) Ok((s, ConstantRange { nodes: (x, y) }))
} }
pub fn constant_indexed_range(s: &str) -> IResult<&str, ConstantIndexedRange> { pub fn constant_indexed_range(s: Span) -> IResult<Span, ConstantIndexedRange> {
let (s, x) = constant_expression(s)?; let (s, x) = constant_expression(s)?;
let (s, y) = map(alt((symbol("+:"), symbol("-:"))), |x| Operator { let (s, y) = map(alt((symbol("+:"), symbol("-:"))), |x| {
nodes: (x,), ConstantIndexedRangeOperator { nodes: (x,) }
})(s)?; })(s)?;
let (s, z) = constant_expression(s)?; let (s, z) = constant_expression(s)?;
Ok((s, ConstantIndexedRange { nodes: (x, y, z) })) Ok((s, ConstantIndexedRange { nodes: (x, y, z) }))
} }
pub fn expression(s: &str) -> IResult<&str, Expression> { pub fn expression(s: Span) -> IResult<Span, Expression> {
alt(( alt((
map(primary, |x| Expression::Nullary(Box::new(x))), map(primary, |x| Expression::Nullary(Box::new(x))),
expression_unary, expression_unary,
@ -404,7 +421,7 @@ pub fn expression(s: &str) -> IResult<&str, Expression> {
))(s) ))(s)
} }
pub fn expression_unary(s: &str) -> IResult<&str, Expression> { pub fn expression_unary(s: Span) -> IResult<Span, Expression> {
let (s, x) = unary_operator(s)?; let (s, x) = unary_operator(s)?;
let (s, y) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, z) = primary(s)?; let (s, z) = primary(s)?;
@ -414,7 +431,7 @@ pub fn expression_unary(s: &str) -> IResult<&str, Expression> {
)) ))
} }
pub fn expression_binary(s: &str) -> IResult<&str, Expression> { pub fn expression_binary(s: Span) -> IResult<Span, Expression> {
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
let (s, y) = binary_operator(s)?; let (s, y) = binary_operator(s)?;
let (s, z) = many0(attribute_instance)(s)?; let (s, z) = many0(attribute_instance)(s)?;
@ -427,28 +444,28 @@ pub fn expression_binary(s: &str) -> IResult<&str, Expression> {
)) ))
} }
pub fn tagged_union_expression(s: &str) -> IResult<&str, TaggedUnionExpression> { pub fn tagged_union_expression(s: Span) -> IResult<Span, TaggedUnionExpression> {
let (s, _) = symbol("tagged")(s)?; let (s, _) = symbol("tagged")(s)?;
let (s, x) = member_identifier(s)?; let (s, x) = member_identifier(s)?;
let (s, y) = opt(expression)(s)?; let (s, y) = opt(expression)(s)?;
Ok((s, TaggedUnionExpression { nodes: (x, y) })) Ok((s, TaggedUnionExpression { nodes: (x, y) }))
} }
pub fn inside_expression(s: &str) -> IResult<&str, InsideExpression> { pub fn inside_expression(s: Span) -> IResult<Span, InsideExpression> {
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
let (s, _) = symbol("inside")(s)?; let (s, _) = symbol("inside")(s)?;
let (s, y) = brace(open_range_list)(s)?; let (s, y) = brace(open_range_list)(s)?;
Ok((s, InsideExpression { nodes: (x, y) })) Ok((s, InsideExpression { nodes: (x, y) }))
} }
pub fn value_range(s: &str) -> IResult<&str, ValueRange> { pub fn value_range(s: Span) -> IResult<Span, ValueRange> {
alt(( alt((
value_range_binary, value_range_binary,
map(expression, |x| ValueRange::Unary(x)), map(expression, |x| ValueRange::Unary(x)),
))(s) ))(s)
} }
pub fn value_range_binary(s: &str) -> IResult<&str, ValueRange> { pub fn value_range_binary(s: Span) -> IResult<Span, ValueRange> {
let (s, _) = symbol("[")(s)?; let (s, _) = symbol("[")(s)?;
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
@ -457,14 +474,14 @@ pub fn value_range_binary(s: &str) -> IResult<&str, ValueRange> {
Ok((s, ValueRange::Binary((x, y)))) Ok((s, ValueRange::Binary((x, y))))
} }
pub fn mintypmax_expression(s: &str) -> IResult<&str, MintypmaxExpression> { pub fn mintypmax_expression(s: Span) -> IResult<Span, MintypmaxExpression> {
alt(( alt((
mintypmax_expression_ternary, mintypmax_expression_ternary,
map(expression, |x| MintypmaxExpression::Unary(x)), map(expression, |x| MintypmaxExpression::Unary(x)),
))(s) ))(s)
} }
pub fn mintypmax_expression_ternary(s: &str) -> IResult<&str, MintypmaxExpression> { pub fn mintypmax_expression_ternary(s: Span) -> IResult<Span, MintypmaxExpression> {
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
let (s, y) = expression(s)?; let (s, y) = expression(s)?;
@ -474,8 +491,8 @@ pub fn mintypmax_expression_ternary(s: &str) -> IResult<&str, MintypmaxExpressio
} }
pub fn module_path_conditional_expression( pub fn module_path_conditional_expression(
s: &str, s: Span,
) -> IResult<&str, ModulePathConditionalExpression> { ) -> IResult<Span, ModulePathConditionalExpression> {
let (s, x) = module_path_expression(s)?; let (s, x) = module_path_expression(s)?;
let (s, _) = symbol("?")(s)?; let (s, _) = symbol("?")(s)?;
let (s, y) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
@ -490,7 +507,7 @@ pub fn module_path_conditional_expression(
)) ))
} }
pub fn module_path_expression(s: &str) -> IResult<&str, ModulePathExpression> { pub fn module_path_expression(s: Span) -> IResult<Span, ModulePathExpression> {
alt(( alt((
map(module_path_primary, |x| { map(module_path_primary, |x| {
ModulePathExpression::Nullary(Box::new(x)) ModulePathExpression::Nullary(Box::new(x))
@ -503,7 +520,7 @@ pub fn module_path_expression(s: &str) -> IResult<&str, ModulePathExpression> {
))(s) ))(s)
} }
pub fn module_path_expression_unary(s: &str) -> IResult<&str, ModulePathExpression> { pub fn module_path_expression_unary(s: Span) -> IResult<Span, ModulePathExpression> {
let (s, x) = unary_module_path_operator(s)?; let (s, x) = unary_module_path_operator(s)?;
let (s, y) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, z) = module_path_primary(s)?; let (s, z) = module_path_primary(s)?;
@ -513,7 +530,7 @@ pub fn module_path_expression_unary(s: &str) -> IResult<&str, ModulePathExpressi
)) ))
} }
pub fn module_path_expression_binary(s: &str) -> IResult<&str, ModulePathExpression> { pub fn module_path_expression_binary(s: Span) -> IResult<Span, ModulePathExpression> {
let (s, x) = module_path_expression(s)?; let (s, x) = module_path_expression(s)?;
let (s, y) = binary_module_path_operator(s)?; let (s, y) = binary_module_path_operator(s)?;
let (s, z) = many0(attribute_instance)(s)?; let (s, z) = many0(attribute_instance)(s)?;
@ -526,7 +543,7 @@ pub fn module_path_expression_binary(s: &str) -> IResult<&str, ModulePathExpress
)) ))
} }
pub fn module_path_mintypmax_expression(s: &str) -> IResult<&str, ModulePathMintypmaxExpression> { pub fn module_path_mintypmax_expression(s: Span) -> IResult<Span, ModulePathMintypmaxExpression> {
alt(( alt((
module_path_mintypmax_expression_ternary, module_path_mintypmax_expression_ternary,
map(module_path_expression, |x| { map(module_path_expression, |x| {
@ -536,8 +553,8 @@ pub fn module_path_mintypmax_expression(s: &str) -> IResult<&str, ModulePathMint
} }
pub fn module_path_mintypmax_expression_ternary( pub fn module_path_mintypmax_expression_ternary(
s: &str, s: Span,
) -> IResult<&str, ModulePathMintypmaxExpression> { ) -> IResult<Span, ModulePathMintypmaxExpression> {
let (s, x) = module_path_expression(s)?; let (s, x) = module_path_expression(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
let (s, y) = module_path_expression(s)?; let (s, y) = module_path_expression(s)?;
@ -546,25 +563,25 @@ pub fn module_path_mintypmax_expression_ternary(
Ok((s, ModulePathMintypmaxExpression::Ternary((x, y, z)))) Ok((s, ModulePathMintypmaxExpression::Ternary((x, y, z))))
} }
pub fn part_select_range(s: &str) -> IResult<&str, PartSelectRange> { pub fn part_select_range(s: Span) -> IResult<Span, PartSelectRange> {
alt((range, indexed_range))(s) alt((range, indexed_range))(s)
} }
pub fn range(s: &str) -> IResult<&str, PartSelectRange> { pub fn range(s: Span) -> IResult<Span, PartSelectRange> {
let (s, x) = constant_expression(s)?; let (s, x) = constant_expression(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
let (s, y) = constant_expression(s)?; let (s, y) = constant_expression(s)?;
Ok((s, PartSelectRange::Range((x, y)))) Ok((s, PartSelectRange::Range((x, y))))
} }
pub fn indexed_range(s: &str) -> IResult<&str, PartSelectRange> { pub fn indexed_range(s: Span) -> IResult<Span, PartSelectRange> {
let (s, x) = expression(s)?; let (s, x) = expression(s)?;
let (s, y) = alt((symbol("+:"), symbol("-:")))(s)?; let (s, y) = alt((symbol("+:"), symbol("-:")))(s)?;
let (s, z) = constant_expression(s)?; let (s, z) = constant_expression(s)?;
Ok((s, PartSelectRange::IndexedRange((x, y, z)))) Ok((s, PartSelectRange::IndexedRange((x, y, z))))
} }
pub fn genvar_expression(s: &str) -> IResult<&str, ConstantExpression> { pub fn genvar_expression(s: Span) -> IResult<Span, ConstantExpression> {
constant_expression(s) constant_expression(s)
} }

View File

@ -74,7 +74,7 @@ pub struct Size<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct NonZeroUnsignedNumber<'a> { pub struct NonZeroUnsignedNumber<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
@ -106,52 +106,52 @@ pub struct Exp<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct UnsignedNumber<'a> { pub struct UnsignedNumber<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct BinaryValue<'a> { pub struct BinaryValue<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct OctalValue<'a> { pub struct OctalValue<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct HexValue<'a> { pub struct HexValue<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct DecimalBase<'a> { pub struct DecimalBase<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct BinaryBase<'a> { pub struct BinaryBase<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct OctalBase<'a> { pub struct OctalBase<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct HexBase<'a> { pub struct HexBase<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct XNumber<'a> { pub struct XNumber<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct ZNumber<'a> { pub struct ZNumber<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
@ -161,14 +161,14 @@ pub struct UnbasedUnsizedLiteral<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn number(s: &str) -> IResult<&str, Number> { pub fn number(s: Span) -> IResult<Span, Number> {
alt(( alt((
map(real_number, |x| Number::RealNumber(x)), map(real_number, |x| Number::RealNumber(x)),
map(integral_number, |x| Number::IntegralNumber(x)), map(integral_number, |x| Number::IntegralNumber(x)),
))(s) ))(s)
} }
pub fn integral_number(s: &str) -> IResult<&str, IntegralNumber> { pub fn integral_number(s: Span) -> IResult<Span, IntegralNumber> {
alt(( alt((
map(octal_number, |x| IntegralNumber::OctalNumber(x)), map(octal_number, |x| IntegralNumber::OctalNumber(x)),
map(binary_number, |x| IntegralNumber::BinaryNumber(x)), map(binary_number, |x| IntegralNumber::BinaryNumber(x)),
@ -177,16 +177,16 @@ pub fn integral_number(s: &str) -> IResult<&str, IntegralNumber> {
))(s) ))(s)
} }
pub fn decimal_number(s: &str) -> IResult<&str, DecimalNumber> { pub fn decimal_number(s: Span) -> IResult<Span, DecimalNumber> {
alt(( alt((
map(unsigned_number, |x| DecimalNumber::UnsignedNumber(x)),
decimal_number_base_unsigned, decimal_number_base_unsigned,
decimal_number_base_x_number, decimal_number_base_x_number,
decimal_number_base_z_number, decimal_number_base_z_number,
map(unsigned_number, |x| DecimalNumber::UnsignedNumber(x)),
))(s) ))(s)
} }
pub fn decimal_number_base_unsigned(s: &str) -> IResult<&str, DecimalNumber> { pub fn decimal_number_base_unsigned(s: Span) -> IResult<Span, DecimalNumber> {
let (s, a) = opt(size)(s)?; let (s, a) = opt(size)(s)?;
let (s, b) = decimal_base(s)?; let (s, b) = decimal_base(s)?;
let (s, c) = unsigned_number(s)?; let (s, c) = unsigned_number(s)?;
@ -196,7 +196,7 @@ pub fn decimal_number_base_unsigned(s: &str) -> IResult<&str, DecimalNumber> {
)) ))
} }
pub fn decimal_number_base_x_number(s: &str) -> IResult<&str, DecimalNumber> { pub fn decimal_number_base_x_number(s: Span) -> IResult<Span, DecimalNumber> {
let (s, a) = opt(size)(s)?; let (s, a) = opt(size)(s)?;
let (s, b) = decimal_base(s)?; let (s, b) = decimal_base(s)?;
let (s, c) = x_number(s)?; let (s, c) = x_number(s)?;
@ -206,7 +206,7 @@ pub fn decimal_number_base_x_number(s: &str) -> IResult<&str, DecimalNumber> {
)) ))
} }
pub fn decimal_number_base_z_number(s: &str) -> IResult<&str, DecimalNumber> { pub fn decimal_number_base_z_number(s: Span) -> IResult<Span, DecimalNumber> {
let (s, a) = opt(size)(s)?; let (s, a) = opt(size)(s)?;
let (s, b) = decimal_base(s)?; let (s, b) = decimal_base(s)?;
let (s, c) = z_number(s)?; let (s, c) = z_number(s)?;
@ -216,59 +216,59 @@ pub fn decimal_number_base_z_number(s: &str) -> IResult<&str, DecimalNumber> {
)) ))
} }
pub fn binary_number(s: &str) -> IResult<&str, BinaryNumber> { pub fn binary_number(s: Span) -> IResult<Span, BinaryNumber> {
let (s, a) = opt(size)(s)?; let (s, a) = opt(size)(s)?;
let (s, b) = binary_base(s)?; let (s, b) = binary_base(s)?;
let (s, c) = binary_value(s)?; let (s, c) = binary_value(s)?;
Ok((s, BinaryNumber { nodes: (a, b, c) })) Ok((s, BinaryNumber { nodes: (a, b, c) }))
} }
pub fn octal_number(s: &str) -> IResult<&str, OctalNumber> { pub fn octal_number(s: Span) -> IResult<Span, OctalNumber> {
let (s, a) = opt(size)(s)?; let (s, a) = opt(size)(s)?;
let (s, b) = octal_base(s)?; let (s, b) = octal_base(s)?;
let (s, c) = octal_value(s)?; let (s, c) = octal_value(s)?;
Ok((s, OctalNumber { nodes: (a, b, c) })) Ok((s, OctalNumber { nodes: (a, b, c) }))
} }
pub fn hex_number(s: &str) -> IResult<&str, HexNumber> { pub fn hex_number(s: Span) -> IResult<Span, HexNumber> {
let (s, a) = opt(size)(s)?; let (s, a) = opt(size)(s)?;
let (s, b) = hex_base(s)?; let (s, b) = hex_base(s)?;
let (s, c) = hex_value(s)?; let (s, c) = hex_value(s)?;
Ok((s, HexNumber { nodes: (a, b, c) })) Ok((s, HexNumber { nodes: (a, b, c) }))
} }
pub fn sign(s: &str) -> IResult<&str, Sign> { pub fn sign(s: Span) -> IResult<Span, Sign> {
alt(( alt((
map(symbol("+"), |x| Sign::Plus(x)), map(symbol("+"), |x| Sign::Plus(x)),
map(symbol("-"), |x| Sign::Minus(x)), map(symbol("-"), |x| Sign::Minus(x)),
))(s) ))(s)
} }
pub fn size(s: &str) -> IResult<&str, Size> { pub fn size(s: Span) -> IResult<Span, Size> {
let (s, a) = non_zero_unsigned_number(s)?; let (s, a) = non_zero_unsigned_number(s)?;
Ok((s, Size { nodes: (a,) })) Ok((s, Size { nodes: (a,) }))
} }
pub fn non_zero_unsigned_number(s: &str) -> IResult<&str, NonZeroUnsignedNumber> { pub fn non_zero_unsigned_number(s: Span) -> IResult<Span, NonZeroUnsignedNumber> {
let (s, a) = ws(non_zero_unsigned_number_impl)(s)?; let (s, a) = ws(non_zero_unsigned_number_impl)(s)?;
Ok((s, NonZeroUnsignedNumber { nodes: (a,) })) Ok((s, NonZeroUnsignedNumber { nodes: a }))
} }
pub fn non_zero_unsigned_number_impl(s: &str) -> IResult<&str, &str> { pub fn non_zero_unsigned_number_impl(s: Span) -> IResult<Span, Span> {
let (s, a) = is_a("123456789")(s)?; let (s, a) = is_a("123456789")(s)?;
fold_many0(alt((tag("_"), digit1)), a, |acc, item| { fold_many0(alt((tag("_"), digit1)), a, |acc, item| {
str_concat::concat(acc, item).unwrap() concat(acc, item).unwrap()
})(s) })(s)
} }
pub fn real_number(s: &str) -> IResult<&str, RealNumber> { pub fn real_number(s: Span) -> IResult<Span, RealNumber> {
alt(( alt((
real_number_floating, real_number_floating,
map(fixed_point_number, |x| RealNumber::FixedPointNumber(x)), map(fixed_point_number, |x| RealNumber::FixedPointNumber(x)),
))(s) ))(s)
} }
pub fn real_number_floating(s: &str) -> IResult<&str, RealNumber> { pub fn real_number_floating(s: Span) -> IResult<Span, RealNumber> {
let (s, a) = unsigned_number(s)?; let (s, a) = unsigned_number(s)?;
let (s, b) = opt(pair(symbol("."), unsigned_number))(s)?; let (s, b) = opt(pair(symbol("."), unsigned_number))(s)?;
let (s, c) = exp(s)?; let (s, c) = exp(s)?;
@ -282,129 +282,129 @@ pub fn real_number_floating(s: &str) -> IResult<&str, RealNumber> {
)) ))
} }
pub fn fixed_point_number(s: &str) -> IResult<&str, FixedPointNumber> { pub fn fixed_point_number(s: Span) -> IResult<Span, FixedPointNumber> {
let (s, a) = unsigned_number(s)?; let (s, a) = unsigned_number(s)?;
let (s, b) = map(tag("."), |x| Symbol { nodes: (x,) })(s)?;; let (s, b) = map(tag("."), |x| Symbol { nodes: (x, vec![]) })(s)?;;
let (s, c) = unsigned_number(s)?; let (s, c) = unsigned_number(s)?;
Ok((s, FixedPointNumber { nodes: (a, b, c) })) Ok((s, FixedPointNumber { nodes: (a, b, c) }))
} }
pub fn exp(s: &str) -> IResult<&str, Exp> { pub fn exp(s: Span) -> IResult<Span, Exp> {
let (s, a) = alt((symbol("e"), symbol("E")))(s)?; let (s, a) = alt((symbol("e"), symbol("E")))(s)?;
Ok((s, Exp { nodes: (a,) })) Ok((s, Exp { nodes: (a,) }))
} }
pub fn unsigned_number(s: &str) -> IResult<&str, UnsignedNumber> { pub fn unsigned_number(s: Span) -> IResult<Span, UnsignedNumber> {
let (s, a) = ws(unsigned_number_impl)(s)?; let (s, a) = ws(unsigned_number_impl)(s)?;
Ok((s, UnsignedNumber { nodes: (a,) })) Ok((s, UnsignedNumber { nodes: a }))
} }
pub fn unsigned_number_impl(s: &str) -> IResult<&str, &str> { pub fn unsigned_number_impl(s: Span) -> IResult<Span, Span> {
let (s, a) = digit1(s)?; let (s, a) = digit1(s)?;
fold_many0(alt((tag("_"), digit1)), a, |acc, item| { fold_many0(alt((tag("_"), digit1)), a, |acc, item| {
str_concat::concat(acc, item).unwrap() concat(acc, item).unwrap()
})(s) })(s)
} }
pub fn binary_value(s: &str) -> IResult<&str, BinaryValue> { pub fn binary_value(s: Span) -> IResult<Span, BinaryValue> {
let (s, a) = ws(binary_value_impl)(s)?; let (s, a) = ws(binary_value_impl)(s)?;
Ok((s, BinaryValue { nodes: (a,) })) Ok((s, BinaryValue { nodes: a }))
} }
pub fn binary_value_impl(s: &str) -> IResult<&str, &str> { pub fn binary_value_impl(s: Span) -> IResult<Span, Span> {
let (s, a) = is_a("01xXzZ?")(s)?; let (s, a) = is_a("01xXzZ?")(s)?;
fold_many0(alt((tag("_"), is_a("01xXzZ?"))), a, |acc, item| { fold_many0(alt((tag("_"), is_a("01xXzZ?"))), a, |acc, item| {
str_concat::concat(acc, item).unwrap() concat(acc, item).unwrap()
})(s) })(s)
} }
pub fn octal_value(s: &str) -> IResult<&str, OctalValue> { pub fn octal_value(s: Span) -> IResult<Span, OctalValue> {
let (s, a) = ws(octal_value_impl)(s)?; let (s, a) = ws(octal_value_impl)(s)?;
Ok((s, OctalValue { nodes: (a,) })) Ok((s, OctalValue { nodes: a }))
} }
pub fn octal_value_impl(s: &str) -> IResult<&str, &str> { pub fn octal_value_impl(s: Span) -> IResult<Span, Span> {
let (s, a) = is_a("01234567xXzZ?")(s)?; let (s, a) = is_a("01234567xXzZ?")(s)?;
fold_many0(alt((tag("_"), is_a("01234567xXzZ?"))), a, |acc, item| { fold_many0(alt((tag("_"), is_a("01234567xXzZ?"))), a, |acc, item| {
str_concat::concat(acc, item).unwrap() concat(acc, item).unwrap()
})(s) })(s)
} }
pub fn hex_value(s: &str) -> IResult<&str, HexValue> { pub fn hex_value(s: Span) -> IResult<Span, HexValue> {
let (s, a) = ws(hex_value_impl)(s)?; let (s, a) = ws(hex_value_impl)(s)?;
Ok((s, HexValue { nodes: (a,) })) Ok((s, HexValue { nodes: a }))
} }
pub fn hex_value_impl(s: &str) -> IResult<&str, &str> { pub fn hex_value_impl(s: Span) -> IResult<Span, Span> {
let (s, a) = is_a("0123456789abcdefABCDEFxXzZ?")(s)?; let (s, a) = is_a("0123456789abcdefABCDEFxXzZ?")(s)?;
fold_many0( fold_many0(
alt((tag("_"), is_a("0123456789abcdefABCDEFxXzZ?"))), alt((tag("_"), is_a("0123456789abcdefABCDEFxXzZ?"))),
a, a,
|acc, item| str_concat::concat(acc, item).unwrap(), |acc, item| concat(acc, item).unwrap(),
)(s) )(s)
} }
pub fn decimal_base(s: &str) -> IResult<&str, DecimalBase> { pub fn decimal_base(s: Span) -> IResult<Span, DecimalBase> {
let (s, a) = ws(decimal_base_impl)(s)?; let (s, a) = ws(decimal_base_impl)(s)?;
Ok((s, DecimalBase { nodes: (a,) })) Ok((s, DecimalBase { nodes: a }))
} }
pub fn decimal_base_impl(s: &str) -> IResult<&str, &str> { pub fn decimal_base_impl(s: Span) -> IResult<Span, Span> {
alt((tag_no_case("'d"), tag_no_case("'sd")))(s) alt((tag_no_case("'d"), tag_no_case("'sd")))(s)
} }
pub fn binary_base(s: &str) -> IResult<&str, BinaryBase> { pub fn binary_base(s: Span) -> IResult<Span, BinaryBase> {
let (s, a) = ws(binary_base_impl)(s)?; let (s, a) = ws(binary_base_impl)(s)?;
Ok((s, BinaryBase { nodes: (a,) })) Ok((s, BinaryBase { nodes: a }))
} }
pub fn binary_base_impl(s: &str) -> IResult<&str, &str> { pub fn binary_base_impl(s: Span) -> IResult<Span, Span> {
alt((tag_no_case("'b"), tag_no_case("'sb")))(s) alt((tag_no_case("'b"), tag_no_case("'sb")))(s)
} }
pub fn octal_base(s: &str) -> IResult<&str, OctalBase> { pub fn octal_base(s: Span) -> IResult<Span, OctalBase> {
let (s, a) = ws(octal_base_impl)(s)?; let (s, a) = ws(octal_base_impl)(s)?;
Ok((s, OctalBase { nodes: (a,) })) Ok((s, OctalBase { nodes: a }))
} }
pub fn octal_base_impl(s: &str) -> IResult<&str, &str> { pub fn octal_base_impl(s: Span) -> IResult<Span, Span> {
alt((tag_no_case("'o"), tag_no_case("'so")))(s) alt((tag_no_case("'o"), tag_no_case("'so")))(s)
} }
pub fn hex_base(s: &str) -> IResult<&str, HexBase> { pub fn hex_base(s: Span) -> IResult<Span, HexBase> {
let (s, a) = ws(hex_base_impl)(s)?; let (s, a) = ws(hex_base_impl)(s)?;
Ok((s, HexBase { nodes: (a,) })) Ok((s, HexBase { nodes: a }))
} }
pub fn hex_base_impl(s: &str) -> IResult<&str, &str> { pub fn hex_base_impl(s: Span) -> IResult<Span, Span> {
alt((tag_no_case("'h"), tag_no_case("'sh")))(s) alt((tag_no_case("'h"), tag_no_case("'sh")))(s)
} }
pub fn x_number(s: &str) -> IResult<&str, XNumber> { pub fn x_number(s: Span) -> IResult<Span, XNumber> {
let (s, a) = ws(x_number_impl)(s)?; let (s, a) = ws(x_number_impl)(s)?;
Ok((s, XNumber { nodes: (a,) })) Ok((s, XNumber { nodes: a }))
} }
pub fn x_number_impl(s: &str) -> IResult<&str, &str> { pub fn x_number_impl(s: Span) -> IResult<Span, Span> {
let (s, a) = tag_no_case("x")(s)?; let (s, a) = tag_no_case("x")(s)?;
fold_many0(alt((tag("_"), is_a("_"))), a, |acc, item| { fold_many0(alt((tag("_"), is_a("_"))), a, |acc, item| {
str_concat::concat(acc, item).unwrap() concat(acc, item).unwrap()
})(s) })(s)
} }
pub fn z_number(s: &str) -> IResult<&str, ZNumber> { pub fn z_number(s: Span) -> IResult<Span, ZNumber> {
let (s, a) = ws(z_number_impl)(s)?; let (s, a) = ws(z_number_impl)(s)?;
Ok((s, ZNumber { nodes: (a,) })) Ok((s, ZNumber { nodes: a }))
} }
pub fn z_number_impl(s: &str) -> IResult<&str, &str> { pub fn z_number_impl(s: Span) -> IResult<Span, Span> {
let (s, a) = alt((tag_no_case("z"), tag("?")))(s)?; let (s, a) = alt((tag_no_case("z"), tag("?")))(s)?;
fold_many0(alt((tag("_"), is_a("_"))), a, |acc, item| { fold_many0(alt((tag("_"), is_a("_"))), a, |acc, item| {
str_concat::concat(acc, item).unwrap() concat(acc, item).unwrap()
})(s) })(s)
} }
pub fn unbased_unsized_literal(s: &str) -> IResult<&str, UnbasedUnsizedLiteral> { pub fn unbased_unsized_literal(s: Span) -> IResult<Span, UnbasedUnsizedLiteral> {
let (s, a) = alt((symbol("'0"), symbol("'1"), symbol("'z"), symbol("'x")))(s)?; let (s, a) = alt((symbol("'0"), symbol("'1"), symbol("'z"), symbol("'x")))(s)?;
Ok((s, UnbasedUnsizedLiteral { nodes: (a,) })) Ok((s, UnbasedUnsizedLiteral { nodes: (a,) }))
} }
@ -418,120 +418,123 @@ mod tests {
#[test] #[test]
fn test() { fn test() {
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("659")), format!("{:?}", all_consuming(number)(Span::new("659"))),
"Ok((\"\", IntegralNumber(UnsignedNumber(\"659\"))))" "Ok((LocatedSpanEx { offset: 3, line: 1, fragment: \"\", extra: () }, IntegralNumber(DecimalNumber(UnsignedNumber(UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"659\", extra: () }, []) })))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("'h 837FF")), format!("{:?}", all_consuming(number)(Span::new("'h 837FF"))),
"Ok((\"\", IntegralNumber(HexNumber(HexNumber { size: None, hex_base: \"\\\'h\", hex_value: \"837FF\" }))))" "Ok((LocatedSpanEx { offset: 8, line: 1, fragment: \"\", extra: () }, IntegralNumber(HexNumber(HexNumber { nodes: (None, HexBase { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"\\\'h\", extra: () }, [Space(LocatedSpanEx { offset: 2, line: 1, fragment: \" \", extra: () })]) }, HexValue { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \"837FF\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("'o7460")), format!("{:?}", all_consuming(number)(Span::new("'o7460"))),
"Ok((\"\", IntegralNumber(OctalNumber(OctalNumber { size: None, octal_base: \"\\\'o\", octal_value: \"7460\" }))))" "Ok((LocatedSpanEx { offset: 6, line: 1, fragment: \"\", extra: () }, IntegralNumber(OctalNumber(OctalNumber { nodes: (None, OctalBase { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"\\\'o\", extra: () }, []) }, OctalValue { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"7460\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("4af")), format!("{:?}", all_consuming(number)(Span::new("4af"))),
"Err(Error((\"af\", Eof)))" "Err(Error((LocatedSpanEx { offset: 1, line: 1, fragment: \"af\", extra: () }, Eof)))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("4'b1001")), format!("{:?}", all_consuming(number)(Span::new("4'b1001"))),
"Ok((\"\", IntegralNumber(BinaryNumber(BinaryNumber { size: Some(\"4\"), binary_base: \"\\\'b\", binary_value: \"1001\" }))))" "Ok((LocatedSpanEx { offset: 7, line: 1, fragment: \"\", extra: () }, IntegralNumber(BinaryNumber(BinaryNumber { nodes: (Some(Size { nodes: (NonZeroUnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"4\", extra: () }, []) },) }), BinaryBase { nodes: (LocatedSpanEx { offset: 1, line: 1, fragment: \"\\\'b\", extra: () }, []) }, BinaryValue { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \"1001\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("5 'D 3")), format!("{:?}", all_consuming(number)(Span::new("5 'D 3"))),
"Ok((\"\", IntegralNumber(DecimalNumber(DecimalNumber { size: Some(\"5\"), decimal_base: \"\\\'D\", decimal_value: \"3\" }))))" "Ok((LocatedSpanEx { offset: 6, line: 1, fragment: \"\", extra: () }, IntegralNumber(DecimalNumber(BaseUnsigned(DecimalNumberBaseUnsigned { nodes: (Some(Size { nodes: (NonZeroUnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"5\", extra: () }, [Space(LocatedSpanEx { offset: 1, line: 1, fragment: \" \", extra: () })]) },) }), DecimalBase { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"\\\'D\", extra: () }, [Space(LocatedSpanEx { offset: 4, line: 1, fragment: \" \", extra: () })]) }, UnsignedNumber { nodes: (LocatedSpanEx { offset: 5, line: 1, fragment: \"3\", extra: () }, []) }) })))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("3'b01x")), format!("{:?}", all_consuming(number)(Span::new("3'b01x"))),
"Ok((\"\", IntegralNumber(BinaryNumber(BinaryNumber { size: Some(\"3\"), binary_base: \"\\\'b\", binary_value: \"01x\" }))))" "Ok((LocatedSpanEx { offset: 6, line: 1, fragment: \"\", extra: () }, IntegralNumber(BinaryNumber(BinaryNumber { nodes: (Some(Size { nodes: (NonZeroUnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"3\", extra: () }, []) },) }), BinaryBase { nodes: (LocatedSpanEx { offset: 1, line: 1, fragment: \"\\\'b\", extra: () }, []) }, BinaryValue { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \"01x\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("12'hx")), format!("{:?}", all_consuming(number)(Span::new("12'hx"))),
"Ok((\"\", IntegralNumber(HexNumber(HexNumber { size: Some(\"12\"), hex_base: \"\\\'h\", hex_value: \"x\" }))))" "Ok((LocatedSpanEx { offset: 5, line: 1, fragment: \"\", extra: () }, IntegralNumber(HexNumber(HexNumber { nodes: (Some(Size { nodes: (NonZeroUnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"12\", extra: () }, []) },) }), HexBase { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"\\\'h\", extra: () }, []) }, HexValue { nodes: (LocatedSpanEx { offset: 4, line: 1, fragment: \"x\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("16'hz")), format!("{:?}", all_consuming(number)(Span::new("16'hz"))),
"Ok((\"\", IntegralNumber(HexNumber(HexNumber { size: Some(\"16\"), hex_base: \"\\\'h\", hex_value: \"z\" }))))" "Ok((LocatedSpanEx { offset: 5, line: 1, fragment: \"\", extra: () }, IntegralNumber(HexNumber(HexNumber { nodes: (Some(Size { nodes: (NonZeroUnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"16\", extra: () }, []) },) }), HexBase { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"\\\'h\", extra: () }, []) }, HexValue { nodes: (LocatedSpanEx { offset: 4, line: 1, fragment: \"z\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("8 'd -6")), format!("{:?}", all_consuming(number)(Span::new("8 'd -6"))),
"Err(Error((\"\\\'d -6\", Eof)))" "Err(Error((LocatedSpanEx { offset: 2, line: 1, fragment: \"\\\'d -6\", extra: () }, Eof)))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("4 'shf")), format!("{:?}", all_consuming(number)(Span::new("4 'shf"))),
"Ok((\"\", IntegralNumber(HexNumber(HexNumber { size: Some(\"4\"), hex_base: \"\\\'sh\", hex_value: \"f\" }))))" "Ok((LocatedSpanEx { offset: 6, line: 1, fragment: \"\", extra: () }, IntegralNumber(HexNumber(HexNumber { nodes: (Some(Size { nodes: (NonZeroUnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"4\", extra: () }, [Space(LocatedSpanEx { offset: 1, line: 1, fragment: \" \", extra: () })]) },) }), HexBase { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"\\\'sh\", extra: () }, []) }, HexValue { nodes: (LocatedSpanEx { offset: 5, line: 1, fragment: \"f\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("16'sd?")), format!("{:?}", all_consuming(number)(Span::new("16'sd?"))),
"Ok((\"\", IntegralNumber(DecimalNumber(DecimalNumber { size: Some(\"16\"), decimal_base: \"\\\'sd\", decimal_value: \"?\" }))))" "Ok((LocatedSpanEx { offset: 6, line: 1, fragment: \"\", extra: () }, IntegralNumber(DecimalNumber(BaseZNumber(DecimalNumberBaseZNumber { nodes: (Some(Size { nodes: (NonZeroUnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"16\", extra: () }, []) },) }), DecimalBase { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"\\\'sd\", extra: () }, []) }, ZNumber { nodes: (LocatedSpanEx { offset: 5, line: 1, fragment: \"?\", extra: () }, []) }) })))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("27_195_000")), format!("{:?}", all_consuming(number)(Span::new("27_195_000"))),
"Ok((\"\", IntegralNumber(UnsignedNumber(\"27_195_000\"))))" "Ok((LocatedSpanEx { offset: 10, line: 1, fragment: \"\", extra: () }, IntegralNumber(DecimalNumber(UnsignedNumber(UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"27_195_000\", extra: () }, []) })))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("16'b0011_0101_0001_1111")), format!("{:?}", all_consuming(number)(Span::new("16'b0011_0101_0001_1111"))),
"Ok((\"\", IntegralNumber(BinaryNumber(BinaryNumber { size: Some(\"16\"), binary_base: \"\\\'b\", binary_value: \"0011_0101_0001_1111\" }))))" "Ok((LocatedSpanEx { offset: 23, line: 1, fragment: \"\", extra: () }, IntegralNumber(BinaryNumber(BinaryNumber { nodes: (Some(Size { nodes: (NonZeroUnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"16\", extra: () }, []) },) }), BinaryBase { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"\\\'b\", extra: () }, []) }, BinaryValue { nodes: (LocatedSpanEx { offset: 4, line: 1, fragment: \"0011_0101_0001_1111\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("32 'h 12ab_f001")), format!("{:?}", all_consuming(number)(Span::new("32 'h 12ab_f001"))),
"Ok((\"\", IntegralNumber(HexNumber(HexNumber { size: Some(\"32\"), hex_base: \"\\\'h\", hex_value: \"12ab_f001\" }))))" "Ok((LocatedSpanEx { offset: 15, line: 1, fragment: \"\", extra: () }, IntegralNumber(HexNumber(HexNumber { nodes: (Some(Size { nodes: (NonZeroUnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"32\", extra: () }, [Space(LocatedSpanEx { offset: 2, line: 1, fragment: \" \", extra: () })]) },) }), HexBase { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \"\\\'h\", extra: () }, [Space(LocatedSpanEx { offset: 5, line: 1, fragment: \" \", extra: () })]) }, HexValue { nodes: (LocatedSpanEx { offset: 6, line: 1, fragment: \"12ab_f001\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("1.2")), format!("{:?}", all_consuming(number)(Span::new("1.2"))),
"Ok((\"\", RealNumber(FixedPointNumber(FixedPointNumber { integer_value: \"1\", fraction_value: \"2\" }))))" "Ok((LocatedSpanEx { offset: 3, line: 1, fragment: \"\", extra: () }, RealNumber(FixedPointNumber(FixedPointNumber { nodes: (UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"1\", extra: () }, []) }, Symbol { nodes: (LocatedSpanEx { offset: 1, line: 1, fragment: \".\", extra: () }, []) }, UnsignedNumber { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"2\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("0.1")), format!("{:?}", all_consuming(number)(Span::new("0.1"))),
"Ok((\"\", RealNumber(FixedPointNumber(FixedPointNumber { integer_value: \"0\", fraction_value: \"1\" }))))" "Ok((LocatedSpanEx { offset: 3, line: 1, fragment: \"\", extra: () }, RealNumber(FixedPointNumber(FixedPointNumber { nodes: (UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"0\", extra: () }, []) }, Symbol { nodes: (LocatedSpanEx { offset: 1, line: 1, fragment: \".\", extra: () }, []) }, UnsignedNumber { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"1\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("2394.26331")), format!("{:?}", all_consuming(number)(Span::new("2394.26331"))),
"Ok((\"\", RealNumber(FixedPointNumber(FixedPointNumber { integer_value: \"2394\", fraction_value: \"26331\" }))))" "Ok((LocatedSpanEx { offset: 10, line: 1, fragment: \"\", extra: () }, RealNumber(FixedPointNumber(FixedPointNumber { nodes: (UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"2394\", extra: () }, []) }, Symbol { nodes: (LocatedSpanEx { offset: 4, line: 1, fragment: \".\", extra: () }, []) }, UnsignedNumber { nodes: (LocatedSpanEx { offset: 5, line: 1, fragment: \"26331\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("1.2E12")), format!("{:?}", all_consuming(number)(Span::new("1.2E12"))),
"Ok((\"\", RealNumber(FloatingPointNumber(FloatingPointNumber { integer_value: \"1\", fraction_value: Some(\"2\"), exponent: \"E\", sign: None, exponent_value: \"12\" }))))" "Ok((LocatedSpanEx { offset: 6, line: 1, fragment: \"\", extra: () }, RealNumber(Floating(RealNumberFloating { nodes: (UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"1\", extra: () }, []) }, Some((Symbol { nodes: (LocatedSpanEx { offset: 1, line: 1, fragment: \".\", extra: () }, []) }, UnsignedNumber { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"2\", extra: () }, []) })), Exp { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \"E\", extra: () }, []) },) }, None, UnsignedNumber { nodes: (LocatedSpanEx { offset: 4, line: 1, fragment: \"12\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("1.30e-2")), format!("{:?}", all_consuming(number)(Span::new("1.30e-2"))),
"Ok((\"\", RealNumber(FloatingPointNumber(FloatingPointNumber { integer_value: \"1\", fraction_value: Some(\"30\"), exponent: \"e\", sign: Some(\"-\"), exponent_value: \"2\" }))))" "Ok((LocatedSpanEx { offset: 7, line: 1, fragment: \"\", extra: () }, RealNumber(Floating(RealNumberFloating { nodes: (UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"1\", extra: () }, []) }, Some((Symbol { nodes: (LocatedSpanEx { offset: 1, line: 1, fragment: \".\", extra: () }, []) }, UnsignedNumber { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"30\", extra: () }, []) })), Exp { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 4, line: 1, fragment: \"e\", extra: () }, []) },) }, Some(Minus(Symbol { nodes: (LocatedSpanEx { offset: 5, line: 1, fragment: \"-\", extra: () }, []) })), UnsignedNumber { nodes: (LocatedSpanEx { offset: 6, line: 1, fragment: \"2\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("0.1e-0")), format!("{:?}", all_consuming(number)(Span::new("0.1e-0"))),
"Ok((\"\", RealNumber(FloatingPointNumber(FloatingPointNumber { integer_value: \"0\", fraction_value: Some(\"1\"), exponent: \"e\", sign: Some(\"-\"), exponent_value: \"0\" }))))" "Ok((LocatedSpanEx { offset: 6, line: 1, fragment: \"\", extra: () }, RealNumber(Floating(RealNumberFloating { nodes: (UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"0\", extra: () }, []) }, Some((Symbol { nodes: (LocatedSpanEx { offset: 1, line: 1, fragment: \".\", extra: () }, []) }, UnsignedNumber { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"1\", extra: () }, []) })), Exp { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \"e\", extra: () }, []) },) }, Some(Minus(Symbol { nodes: (LocatedSpanEx { offset: 4, line: 1, fragment: \"-\", extra: () }, []) })), UnsignedNumber { nodes: (LocatedSpanEx { offset: 5, line: 1, fragment: \"0\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("23E10")), format!("{:?}", all_consuming(number)(Span::new("23E10"))),
"Ok((\"\", RealNumber(FloatingPointNumber(FloatingPointNumber { integer_value: \"23\", fraction_value: None, exponent: \"E\", sign: None, exponent_value: \"10\" }))))" "Ok((LocatedSpanEx { offset: 5, line: 1, fragment: \"\", extra: () }, RealNumber(Floating(RealNumberFloating { nodes: (UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"23\", extra: () }, []) }, None, Exp { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"E\", extra: () }, []) },) }, None, UnsignedNumber { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \"10\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("29E-2")), format!("{:?}", all_consuming(number)(Span::new("29E-2"))),
"Ok((\"\", RealNumber(FloatingPointNumber(FloatingPointNumber { integer_value: \"29\", fraction_value: None, exponent: \"E\", sign: Some(\"-\"), exponent_value: \"2\" }))))" "Ok((LocatedSpanEx { offset: 5, line: 1, fragment: \"\", extra: () }, RealNumber(Floating(RealNumberFloating { nodes: (UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"29\", extra: () }, []) }, None, Exp { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"E\", extra: () }, []) },) }, Some(Minus(Symbol { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \"-\", extra: () }, []) })), UnsignedNumber { nodes: (LocatedSpanEx { offset: 4, line: 1, fragment: \"2\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("236.123_763_e-12")), format!("{:?}", all_consuming(number)(Span::new("236.123_763_e-12"))),
"Ok((\"\", RealNumber(FloatingPointNumber(FloatingPointNumber { integer_value: \"236\", fraction_value: Some(\"123_763_\"), exponent: \"e\", sign: Some(\"-\"), exponent_value: \"12\" }))))" "Ok((LocatedSpanEx { offset: 16, line: 1, fragment: \"\", extra: () }, RealNumber(Floating(RealNumberFloating { nodes: (UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"236\", extra: () }, []) }, Some((Symbol { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \".\", extra: () }, []) }, UnsignedNumber { nodes: (LocatedSpanEx { offset: 4, line: 1, fragment: \"123_763_\", extra: () }, []) })), Exp { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 12, line: 1, fragment: \"e\", extra: () }, []) },) }, Some(Minus(Symbol { nodes: (LocatedSpanEx { offset: 13, line: 1, fragment: \"-\", extra: () }, []) })), UnsignedNumber { nodes: (LocatedSpanEx { offset: 14, line: 1, fragment: \"12\", extra: () }, []) }) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)(".12")), format!("{:?}", all_consuming(number)(Span::new(".12"))),
"Err(Error((\".12\", Digit)))" "Err(Error((LocatedSpanEx { offset: 0, line: 1, fragment: \".12\", extra: () }, Digit)))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("9.")), format!("{:?}", all_consuming(number)(Span::new("9."))),
"Err(Error((\".\", Eof)))" "Err(Error((LocatedSpanEx { offset: 1, line: 1, fragment: \".\", extra: () }, Eof)))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)("4.E3")), format!("{:?}", all_consuming(number)(Span::new("4.E3"))),
"Err(Error((\".E3\", Eof)))" "Err(Error((LocatedSpanEx { offset: 1, line: 1, fragment: \".E3\", extra: () }, Eof)))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(number)(".2e-7")), format!("{:?}", all_consuming(number)(Span::new(".2e-7"))),
"Err(Error((\".2e-7\", Digit)))" "Err(Error((LocatedSpanEx { offset: 0, line: 1, fragment: \".2e-7\", extra: () }, Digit)))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(unbased_unsized_literal)("'0")), format!(
"Ok((\"\", \"\\\'0\"))" "{:?}",
all_consuming(unbased_unsized_literal)(Span::new("'0"))
),
"Ok((LocatedSpanEx { offset: 2, line: 1, fragment: \"\", extra: () }, UnbasedUnsizedLiteral { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"\\\'0\", extra: () }, []) },) }))"
); );
} }
} }

View File

@ -5,13 +5,33 @@ use nom::IResult;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#[derive(Debug)] #[derive(Debug)]
pub struct Operator<'a> { pub struct UnaryOperator<'a> {
pub nodes: (Symbol<'a>,),
}
#[derive(Debug)]
pub struct BinaryOperator<'a> {
pub nodes: (Symbol<'a>,),
}
#[derive(Debug)]
pub struct IncOrDecOperator<'a> {
pub nodes: (Symbol<'a>,),
}
#[derive(Debug)]
pub struct UnaryModulePathOperator<'a> {
pub nodes: (Symbol<'a>,),
}
#[derive(Debug)]
pub struct BinaryModulePathOperator<'a> {
pub nodes: (Symbol<'a>,), pub nodes: (Symbol<'a>,),
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn unary_operator(s: &str) -> IResult<&str, Operator> { pub fn unary_operator(s: Span) -> IResult<Span, UnaryOperator> {
let (s, a) = alt(( let (s, a) = alt((
symbol("+"), symbol("+"),
symbol("-"), symbol("-"),
@ -25,10 +45,10 @@ pub fn unary_operator(s: &str) -> IResult<&str, Operator> {
symbol("^"), symbol("^"),
symbol("~"), symbol("~"),
))(s)?; ))(s)?;
Ok((s, Operator { nodes: (a,) })) Ok((s, UnaryOperator { nodes: (a,) }))
} }
pub fn binary_operator(s: &str) -> IResult<&str, Operator> { pub fn binary_operator(s: Span) -> IResult<Span, BinaryOperator> {
let (s, a) = alt(( let (s, a) = alt((
alt(( alt((
symbol("+"), symbol("+"),
@ -64,15 +84,15 @@ pub fn binary_operator(s: &str) -> IResult<&str, Operator> {
symbol(">"), symbol(">"),
)), )),
))(s)?; ))(s)?;
Ok((s, Operator { nodes: (a,) })) Ok((s, BinaryOperator { nodes: (a,) }))
} }
pub fn inc_or_dec_operator(s: &str) -> IResult<&str, Operator> { pub fn inc_or_dec_operator(s: Span) -> IResult<Span, IncOrDecOperator> {
let (s, a) = alt((symbol("++"), symbol("--")))(s)?; let (s, a) = alt((symbol("++"), symbol("--")))(s)?;
Ok((s, Operator { nodes: (a,) })) Ok((s, IncOrDecOperator { nodes: (a,) }))
} }
pub fn unary_module_path_operator(s: &str) -> IResult<&str, Operator> { pub fn unary_module_path_operator(s: Span) -> IResult<Span, UnaryModulePathOperator> {
let (s, a) = alt(( let (s, a) = alt((
symbol("!"), symbol("!"),
symbol("&"), symbol("&"),
@ -84,10 +104,10 @@ pub fn unary_module_path_operator(s: &str) -> IResult<&str, Operator> {
symbol("^"), symbol("^"),
symbol("~"), symbol("~"),
))(s)?; ))(s)?;
Ok((s, Operator { nodes: (a,) })) Ok((s, UnaryModulePathOperator { nodes: (a,) }))
} }
pub fn binary_module_path_operator(s: &str) -> IResult<&str, Operator> { pub fn binary_module_path_operator(s: Span) -> IResult<Span, BinaryModulePathOperator> {
let (s, a) = alt(( let (s, a) = alt((
symbol("=="), symbol("=="),
symbol("!="), symbol("!="),
@ -99,7 +119,7 @@ pub fn binary_module_path_operator(s: &str) -> IResult<&str, Operator> {
symbol("^"), symbol("^"),
symbol("~^"), symbol("~^"),
))(s)?; ))(s)?;
Ok((s, Operator { nodes: (a,) })) Ok((s, BinaryModulePathOperator { nodes: (a,) }))
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -112,24 +132,30 @@ mod tests {
#[test] #[test]
fn test() { fn test() {
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(unary_operator)("~")), format!("{:?}", all_consuming(unary_operator)(Span::new("~"))),
"Ok((\"\", Operator { raw: \"~\" }))" "Ok((LocatedSpanEx { offset: 1, line: 1, fragment: \"\", extra: () }, UnaryOperator { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"~\", extra: () }, []) },) }))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(binary_operator)(">>>")), format!("{:?}", all_consuming(binary_operator)(Span::new(">>>"))),
"Ok((\"\", Operator { raw: \">>>\" }))" "Ok((LocatedSpanEx { offset: 3, line: 1, fragment: \"\", extra: () }, BinaryOperator { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \">>>\", extra: () }, []) },) }))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(inc_or_dec_operator)("++")), format!("{:?}", all_consuming(inc_or_dec_operator)(Span::new("++"))),
"Ok((\"\", Operator { raw: \"++\" }))" "Ok((LocatedSpanEx { offset: 2, line: 1, fragment: \"\", extra: () }, IncOrDecOperator { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"++\", extra: () }, []) },) }))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(unary_module_path_operator)("^~")), format!(
"Ok((\"\", Operator { raw: \"^~\" }))" "{:?}",
all_consuming(unary_module_path_operator)(Span::new("^~"))
),
"Ok((LocatedSpanEx { offset: 2, line: 1, fragment: \"\", extra: () }, UnaryModulePathOperator { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"^~\", extra: () }, []) },) }))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(binary_module_path_operator)("||")), format!(
"Ok((\"\", Operator { raw: \"||\" }))" "{:?}",
all_consuming(binary_module_path_operator)(Span::new("||"))
),
"Ok((LocatedSpanEx { offset: 2, line: 1, fragment: \"\", extra: () }, BinaryModulePathOperator { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"||\", extra: () }, []) },) }))"
); );
} }
} }

View File

@ -86,9 +86,24 @@ pub enum Primary<'a> {
AssignmentPatternExpression(AssignmentPatternExpression<'a>), AssignmentPatternExpression(AssignmentPatternExpression<'a>),
StreamingConcatenation(StreamingConcatenation<'a>), StreamingConcatenation(StreamingConcatenation<'a>),
SequenceMethodCall(SequenceMethodCall<'a>), SequenceMethodCall(SequenceMethodCall<'a>),
This, This(This<'a>),
Dollar, Dollar(Dollar<'a>),
Null, Null(Null<'a>),
}
#[derive(Debug)]
pub struct This<'a> {
pub nodes: (Symbol<'a>,),
}
#[derive(Debug)]
pub struct Dollar<'a> {
pub nodes: (Symbol<'a>,),
}
#[derive(Debug)]
pub struct Null<'a> {
pub nodes: (Symbol<'a>,),
} }
#[derive(Debug)] #[derive(Debug)]
@ -219,7 +234,7 @@ pub struct ConstantCast<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn constant_primary(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary(s: Span) -> IResult<Span, ConstantPrimary> {
alt(( alt((
map(symbol("null"), |_| ConstantPrimary::Null), map(symbol("null"), |_| ConstantPrimary::Null),
map(primary_literal, |x| ConstantPrimary::PrimaryLiteral(x)), map(primary_literal, |x| ConstantPrimary::PrimaryLiteral(x)),
@ -245,7 +260,7 @@ pub fn constant_primary(s: &str) -> IResult<&str, ConstantPrimary> {
))(s) ))(s)
} }
pub fn constant_primary_ps_parameter(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary_ps_parameter(s: Span) -> IResult<Span, ConstantPrimary> {
let (s, x) = ps_parameter_identifier(s)?; let (s, x) = ps_parameter_identifier(s)?;
let (s, y) = constant_select(s)?; let (s, y) = constant_select(s)?;
Ok(( Ok((
@ -254,7 +269,7 @@ pub fn constant_primary_ps_parameter(s: &str) -> IResult<&str, ConstantPrimary>
)) ))
} }
pub fn constant_primary_specparam(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary_specparam(s: Span) -> IResult<Span, ConstantPrimary> {
let (s, x) = specparam_identifier(s)?; let (s, x) = specparam_identifier(s)?;
let (s, y) = opt(bracket(constant_range_expression))(s)?; let (s, y) = opt(bracket(constant_range_expression))(s)?;
Ok(( Ok((
@ -263,7 +278,7 @@ pub fn constant_primary_specparam(s: &str) -> IResult<&str, ConstantPrimary> {
)) ))
} }
pub fn constant_primary_formal_port(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary_formal_port(s: Span) -> IResult<Span, ConstantPrimary> {
let (s, x) = formal_port_identifier(s)?; let (s, x) = formal_port_identifier(s)?;
let (s, y) = constant_select(s)?; let (s, y) = constant_select(s)?;
Ok(( Ok((
@ -272,7 +287,7 @@ pub fn constant_primary_formal_port(s: &str) -> IResult<&str, ConstantPrimary> {
)) ))
} }
pub fn constant_primary_enum(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary_enum(s: Span) -> IResult<Span, ConstantPrimary> {
let (s, x) = package_scope_or_class_scope(s)?; let (s, x) = package_scope_or_class_scope(s)?;
let (s, y) = enum_identifier(s)?; let (s, y) = enum_identifier(s)?;
Ok(( Ok((
@ -281,7 +296,7 @@ pub fn constant_primary_enum(s: &str) -> IResult<&str, ConstantPrimary> {
)) ))
} }
pub fn constant_primary_concatenation(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary_concatenation(s: Span) -> IResult<Span, ConstantPrimary> {
let (s, x) = constant_concatenation(s)?; let (s, x) = constant_concatenation(s)?;
let (s, y) = opt(bracket(constant_range_expression))(s)?; let (s, y) = opt(bracket(constant_range_expression))(s)?;
Ok(( Ok((
@ -290,7 +305,7 @@ pub fn constant_primary_concatenation(s: &str) -> IResult<&str, ConstantPrimary>
)) ))
} }
pub fn constant_primary_multiple_concatenation(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary_multiple_concatenation(s: Span) -> IResult<Span, ConstantPrimary> {
let (s, x) = constant_multiple_concatenation(s)?; let (s, x) = constant_multiple_concatenation(s)?;
let (s, y) = opt(bracket(constant_range_expression))(s)?; let (s, y) = opt(bracket(constant_range_expression))(s)?;
Ok(( Ok((
@ -301,12 +316,12 @@ pub fn constant_primary_multiple_concatenation(s: &str) -> IResult<&str, Constan
)) ))
} }
pub fn constant_primary_mintypmax_expression(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary_mintypmax_expression(s: Span) -> IResult<Span, ConstantPrimary> {
let (s, x) = paren(constant_mintypmax_expression)(s)?; let (s, x) = paren(constant_mintypmax_expression)(s)?;
Ok((s, ConstantPrimary::MintypmaxExpression(x))) Ok((s, ConstantPrimary::MintypmaxExpression(x)))
} }
pub fn module_path_primary(s: &str) -> IResult<&str, ModulePathPrimary> { pub fn module_path_primary(s: Span) -> IResult<Span, ModulePathPrimary> {
alt(( alt((
map(number, |x| ModulePathPrimary::Number(x)), map(number, |x| ModulePathPrimary::Number(x)),
map(identifier, |x| ModulePathPrimary::Identifier(x)), map(identifier, |x| ModulePathPrimary::Identifier(x)),
@ -325,7 +340,7 @@ pub fn module_path_primary(s: &str) -> IResult<&str, ModulePathPrimary> {
))(s) ))(s)
} }
pub fn primary(s: &str) -> IResult<&str, Primary> { pub fn primary(s: Span) -> IResult<Span, Primary> {
alt(( alt((
map(primary_literal, |x| Primary::PrimaryLiteral(x)), map(primary_literal, |x| Primary::PrimaryLiteral(x)),
primary_hierarchical, primary_hierarchical,
@ -348,13 +363,13 @@ pub fn primary(s: &str) -> IResult<&str, Primary> {
Primary::StreamingConcatenation(x) Primary::StreamingConcatenation(x)
}), }),
map(sequence_method_call, |x| Primary::SequenceMethodCall(x)), map(sequence_method_call, |x| Primary::SequenceMethodCall(x)),
map(symbol("this"), |_| Primary::This), map(symbol("this"), |x| Primary::This(This { nodes: (x,) })),
map(symbol("$"), |_| Primary::Dollar), map(symbol("$"), |x| Primary::Dollar(Dollar { nodes: (x,) })),
map(symbol("null"), |_| Primary::Null), map(symbol("null"), |x| Primary::Null(Null { nodes: (x,) })),
))(s) ))(s)
} }
pub fn primary_hierarchical(s: &str) -> IResult<&str, Primary> { pub fn primary_hierarchical(s: Span) -> IResult<Span, Primary> {
let (s, x) = opt(primary_hierarchical_qualifier)(s)?; let (s, x) = opt(primary_hierarchical_qualifier)(s)?;
let (s, y) = hierarchical_identifier(s)?; let (s, y) = hierarchical_identifier(s)?;
let (s, z) = select(s)?; let (s, z) = select(s)?;
@ -364,7 +379,7 @@ pub fn primary_hierarchical(s: &str) -> IResult<&str, Primary> {
)) ))
} }
pub fn primary_concatenation(s: &str) -> IResult<&str, Primary> { pub fn primary_concatenation(s: Span) -> IResult<Span, Primary> {
let (s, x) = concatenation(s)?; let (s, x) = concatenation(s)?;
let (s, y) = opt(range_expression)(s)?; let (s, y) = opt(range_expression)(s)?;
Ok(( Ok((
@ -373,7 +388,7 @@ pub fn primary_concatenation(s: &str) -> IResult<&str, Primary> {
)) ))
} }
pub fn primary_multiple_concatenation(s: &str) -> IResult<&str, Primary> { pub fn primary_multiple_concatenation(s: Span) -> IResult<Span, Primary> {
let (s, x) = multiple_concatenation(s)?; let (s, x) = multiple_concatenation(s)?;
let (s, y) = opt(range_expression)(s)?; let (s, y) = opt(range_expression)(s)?;
Ok(( Ok((
@ -382,7 +397,7 @@ pub fn primary_multiple_concatenation(s: &str) -> IResult<&str, Primary> {
)) ))
} }
pub fn primary_hierarchical_qualifier(s: &str) -> IResult<&str, PrimaryHierarchicalQualifier> { pub fn primary_hierarchical_qualifier(s: Span) -> IResult<Span, PrimaryHierarchicalQualifier> {
alt(( alt((
map(class_qualifier, |x| { map(class_qualifier, |x| {
PrimaryHierarchicalQualifier::ClassQualifier(x) PrimaryHierarchicalQualifier::ClassQualifier(x)
@ -393,7 +408,7 @@ pub fn primary_hierarchical_qualifier(s: &str) -> IResult<&str, PrimaryHierarchi
))(s) ))(s)
} }
pub fn class_qualifier(s: &str) -> IResult<&str, ClassQualifier> { pub fn class_qualifier(s: Span) -> IResult<Span, ClassQualifier> {
let (s, x) = opt(symbol("local::"))(s)?; let (s, x) = opt(symbol("local::"))(s)?;
let (s, y) = opt(implicit_class_handle_or_class_scope)(s)?; let (s, y) = opt(implicit_class_handle_or_class_scope)(s)?;
Ok(( Ok((
@ -404,14 +419,14 @@ pub fn class_qualifier(s: &str) -> IResult<&str, ClassQualifier> {
)) ))
} }
pub fn range_expression(s: &str) -> IResult<&str, RangeExpression> { pub fn range_expression(s: Span) -> IResult<Span, RangeExpression> {
alt(( alt((
map(expression, |x| RangeExpression::Expression(x)), map(expression, |x| RangeExpression::Expression(x)),
map(part_select_range, |x| RangeExpression::PartSelectRange(x)), map(part_select_range, |x| RangeExpression::PartSelectRange(x)),
))(s) ))(s)
} }
pub fn primary_literal(s: &str) -> IResult<&str, PrimaryLiteral> { pub fn primary_literal(s: Span) -> IResult<Span, PrimaryLiteral> {
alt(( alt((
map(time_literal, |x| PrimaryLiteral::TimeLiteral(x)), map(time_literal, |x| PrimaryLiteral::TimeLiteral(x)),
map(number, |x| PrimaryLiteral::Number(x)), map(number, |x| PrimaryLiteral::Number(x)),
@ -422,11 +437,11 @@ pub fn primary_literal(s: &str) -> IResult<&str, PrimaryLiteral> {
))(s) ))(s)
} }
pub fn time_literal(s: &str) -> IResult<&str, TimeLiteral> { pub fn time_literal(s: Span) -> IResult<Span, TimeLiteral> {
alt((unsigned_time_literal, fixed_point_time_literal))(s) alt((unsigned_time_literal, fixed_point_time_literal))(s)
} }
pub fn unsigned_time_literal(s: &str) -> IResult<&str, TimeLiteral> { pub fn unsigned_time_literal(s: Span) -> IResult<Span, TimeLiteral> {
let (s, x) = unsigned_number(s)?; let (s, x) = unsigned_number(s)?;
let (s, y) = time_unit(s)?; let (s, y) = time_unit(s)?;
Ok(( Ok((
@ -435,7 +450,7 @@ pub fn unsigned_time_literal(s: &str) -> IResult<&str, TimeLiteral> {
)) ))
} }
pub fn fixed_point_time_literal(s: &str) -> IResult<&str, TimeLiteral> { pub fn fixed_point_time_literal(s: Span) -> IResult<Span, TimeLiteral> {
let (s, x) = fixed_point_number(s)?; let (s, x) = fixed_point_number(s)?;
let (s, y) = time_unit(s)?; let (s, y) = time_unit(s)?;
Ok(( Ok((
@ -444,7 +459,7 @@ pub fn fixed_point_time_literal(s: &str) -> IResult<&str, TimeLiteral> {
)) ))
} }
pub fn time_unit(s: &str) -> IResult<&str, TimeUnit> { pub fn time_unit(s: Span) -> IResult<Span, TimeUnit> {
alt(( alt((
map(symbol("s"), |x| TimeUnit::S(x)), map(symbol("s"), |x| TimeUnit::S(x)),
map(symbol("ms"), |x| TimeUnit::MS(x)), map(symbol("ms"), |x| TimeUnit::MS(x)),
@ -455,7 +470,7 @@ pub fn time_unit(s: &str) -> IResult<&str, TimeUnit> {
))(s) ))(s)
} }
pub fn implicit_class_handle(s: &str) -> IResult<&str, ImplicitClassHandle> { pub fn implicit_class_handle(s: Span) -> IResult<Span, ImplicitClassHandle> {
alt(( alt((
map( map(
tuple((symbol("this"), symbol("."), symbol("super"))), tuple((symbol("this"), symbol("."), symbol("super"))),
@ -466,12 +481,12 @@ pub fn implicit_class_handle(s: &str) -> IResult<&str, ImplicitClassHandle> {
))(s) ))(s)
} }
pub fn bit_select(s: &str) -> IResult<&str, BitSelect> { pub fn bit_select(s: Span) -> IResult<Span, BitSelect> {
let (s, x) = many0(bracket(expression))(s)?; let (s, x) = many0(bracket(expression))(s)?;
Ok((s, BitSelect { nodes: (x,) })) Ok((s, BitSelect { nodes: (x,) }))
} }
pub fn select(s: &str) -> IResult<&str, Select> { pub fn select(s: Span) -> IResult<Span, Select> {
let (s, x) = opt(pair( let (s, x) = opt(pair(
many0(preceded(symbol("."), pair(member_identifier, bit_select))), many0(preceded(symbol("."), pair(member_identifier, bit_select))),
preceded(symbol("."), member_identifier), preceded(symbol("."), member_identifier),
@ -488,7 +503,7 @@ pub fn select(s: &str) -> IResult<&str, Select> {
Ok((s, Select { nodes: (x, y, z) })) Ok((s, Select { nodes: (x, y, z) }))
} }
pub fn nonrange_select(s: &str) -> IResult<&str, Select> { pub fn nonrange_select(s: Span) -> IResult<Span, Select> {
let (s, x) = opt(pair( let (s, x) = opt(pair(
many0(preceded(symbol("."), pair(member_identifier, bit_select))), many0(preceded(symbol("."), pair(member_identifier, bit_select))),
preceded(symbol("."), member_identifier), preceded(symbol("."), member_identifier),
@ -509,12 +524,12 @@ pub fn nonrange_select(s: &str) -> IResult<&str, Select> {
)) ))
} }
pub fn constant_bit_select(s: &str) -> IResult<&str, ConstantBitSelect> { pub fn constant_bit_select(s: Span) -> IResult<Span, ConstantBitSelect> {
let (s, x) = many0(bracket(constant_expression))(s)?; let (s, x) = many0(bracket(constant_expression))(s)?;
Ok((s, ConstantBitSelect { nodes: (x,) })) Ok((s, ConstantBitSelect { nodes: (x,) }))
} }
pub fn constant_select(s: &str) -> IResult<&str, ConstantSelect> { pub fn constant_select(s: Span) -> IResult<Span, ConstantSelect> {
let (s, x) = opt(pair( let (s, x) = opt(pair(
many0(preceded(symbol("."), pair(member_identifier, bit_select))), many0(preceded(symbol("."), pair(member_identifier, bit_select))),
preceded(symbol("."), member_identifier), preceded(symbol("."), member_identifier),
@ -531,18 +546,18 @@ pub fn constant_select(s: &str) -> IResult<&str, ConstantSelect> {
Ok((s, ConstantSelect { nodes: (x, y, z) })) Ok((s, ConstantSelect { nodes: (x, y, z) }))
} }
pub fn constant_cast(s: &str) -> IResult<&str, ConstantCast> { pub fn constant_cast(s: Span) -> IResult<Span, ConstantCast> {
let (s, x) = casting_type(s)?; let (s, x) = casting_type(s)?;
let (s, _) = symbol("'")(s)?; let (s, _) = symbol("'")(s)?;
let (s, y) = paren(constant_expression)(s)?; let (s, y) = paren(constant_expression)(s)?;
Ok((s, ConstantCast { nodes: (x, y) })) Ok((s, ConstantCast { nodes: (x, y) }))
} }
pub fn constant_let_expression(s: &str) -> IResult<&str, LetExpression> { pub fn constant_let_expression(s: Span) -> IResult<Span, LetExpression> {
let_expression(s) let_expression(s)
} }
pub fn cast(s: &str) -> IResult<&str, Cast> { pub fn cast(s: Span) -> IResult<Span, Cast> {
let (s, x) = casting_type(s)?; let (s, x) = casting_type(s)?;
let (s, _) = symbol("'")(s)?; let (s, _) = symbol("'")(s)?;
let (s, y) = paren(expression)(s)?; let (s, y) = paren(expression)(s)?;
@ -558,48 +573,36 @@ mod tests {
#[test] #[test]
fn test() { fn test() {
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(primary)("2.1ns")), format!("{:?}", all_consuming(primary)(Span::new("2.1ns"))),
"Ok((\"\", PrimaryLiteral(TimeLiteral(FixedPointTimeLiteral(FixedPointTimeLiteral { number: FixedPointNumber(FixedPointNumber { integer_value: \"2\", fraction_value: \"1\" }), unit: NS })))))" "Ok((LocatedSpanEx { offset: 5, line: 1, fragment: \"\", extra: () }, PrimaryLiteral(TimeLiteral(FixedPointTimeLiteral(FixedPointTimeLiteral { nodes: (FixedPointNumber { nodes: (UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"2\", extra: () }, []) }, Symbol { nodes: (LocatedSpanEx { offset: 1, line: 1, fragment: \".\", extra: () }, []) }, UnsignedNumber { nodes: (LocatedSpanEx { offset: 2, line: 1, fragment: \"1\", extra: () }, []) }) }, NS(Symbol { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \"ns\", extra: () }, []) })) })))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(primary)("40 ps")), format!("{:?}", all_consuming(primary)(Span::new("40 ps"))),
"Ok((\"\", PrimaryLiteral(TimeLiteral(UnsignedTimeLiteral(UnsignedTimeLiteral { number: \"40\", unit: PS })))))" "Ok((LocatedSpanEx { offset: 5, line: 1, fragment: \"\", extra: () }, PrimaryLiteral(TimeLiteral(UnsignedTimeLiteral(UnsignedTimeLiteral { nodes: (UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"40\", extra: () }, [Space(LocatedSpanEx { offset: 2, line: 1, fragment: \" \", extra: () })]) }, PS(Symbol { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \"ps\", extra: () }, []) })) })))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(primary)("'0")), format!("{:?}", all_consuming(primary)(Span::new("'0"))),
"Ok((\"\", PrimaryLiteral(UnbasedUnsizedLiteral(\"\\\'0\"))))" "Ok((LocatedSpanEx { offset: 2, line: 1, fragment: \"\", extra: () }, PrimaryLiteral(UnbasedUnsizedLiteral(UnbasedUnsizedLiteral { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"\\\'0\", extra: () }, []) },) }))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(primary)("10")), format!("{:?}", all_consuming(primary)(Span::new("10"))),
"Ok((\"\", PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"10\"))))))" "Ok((LocatedSpanEx { offset: 2, line: 1, fragment: \"\", extra: () }, PrimaryLiteral(Number(IntegralNumber(DecimalNumber(UnsignedNumber(UnsignedNumber { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"10\", extra: () }, []) })))))))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(primary)("\"aaa\"")), format!("{:?}", all_consuming(primary)(Span::new("\"aaa\""))),
"Ok((\"\", PrimaryLiteral(StringLiteral(StringLiteral { raw: \"aaa\" }))))" "Ok((LocatedSpanEx { offset: 5, line: 1, fragment: \"\", extra: () }, PrimaryLiteral(StringLiteral(StringLiteral { nodes: (LocatedSpanEx { offset: 1, line: 1, fragment: \"aaa\", extra: () }, []) }))))"
); );
//assert_eq!( //assert_eq!(
// format!("{:?}", all_consuming(primary)("this")), // format!("{:?}", all_consuming(primary)(Span::new("this"))),
// "Ok((\"\", This))" // "Ok((LocatedSpanEx { offset: 4, line: 1, fragment: \"\", extra: () }, This(This { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"this\", extra: () }, []) },) })))"
//); //);
//assert_eq!( //assert_eq!(
// format!("{:?}", all_consuming(primary)("$")), // format!("{:?}", all_consuming(primary)(Span::new("$"))),
// "Ok((\"\", Dollar))" // "Ok((LocatedSpanEx { offset: 1, line: 1, fragment: \"\", extra: () }, Dollar(Dollar { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"$\", extra: () }, []) },) })))"
//); //);
//assert_eq!( //assert_eq!(
// format!("{:?}", all_consuming(primary)("null")), // format!("{:?}", all_consuming(primary)(Span::new("null"))),
// "Ok((\"\", Null))" // "Ok((LocatedSpanEx { offset: 4, line: 1, fragment: \"\", extra: () }, Null(Null { nodes: (Symbol { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"null\", extra: () }, []) },) })))"
//); //);
assert_eq!(
format!("{:?}", all_consuming(primary)("this . super.a")),
"Ok((\"\", Hierarchical(PrimaryHierarchical { qualifier: Some(ClassQualifier(ClassQualifier { local: false, scope: Some(ImplicitClassHandle(ThisSuper)) })), identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [], part_select_range: None } })))"
);
assert_eq!(
format!("{:?}", all_consuming(module_path_primary)("10")),
"Ok((\"\", Number(IntegralNumber(UnsignedNumber(\"10\")))))"
);
assert_eq!(
format!("{:?}", all_consuming(constant_primary)("null")),
"Ok((\"\", Null))"
);
} }
} }

View File

@ -9,44 +9,45 @@ use nom::IResult;
#[derive(Debug)] #[derive(Debug)]
pub struct StringLiteral<'a> { pub struct StringLiteral<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn string_literal(s: &str) -> IResult<&str, StringLiteral> { pub fn string_literal(s: Span) -> IResult<Span, StringLiteral> {
ws(string_literal_impl)(s) let (s, a) = ws(string_literal_impl)(s)?;
Ok((s, StringLiteral { nodes: a }))
} }
pub fn string_literal_impl(s: &str) -> IResult<&str, StringLiteral> { pub fn string_literal_impl(s: Span) -> IResult<Span, Span> {
let (s, _) = tag("\"")(s)?; let (s, _) = tag("\"")(s)?;
let (s, x) = many1(pair(is_not("\\\""), opt(pair(tag("\\"), take(1usize)))))(s)?; let (s, x) = many1(pair(is_not("\\\""), opt(pair(tag("\\"), take(1usize)))))(s)?;
let (s, _) = tag("\"")(s)?; let (s, _) = tag("\"")(s)?;
let mut raw = None; let mut ret = None;
for (x, y) in x { for (x, y) in x {
raw = if let Some(raw) = raw { ret = if let Some(ret) = ret {
Some(str_concat::concat(raw, x).unwrap()) Some(concat(ret, x).unwrap())
} else { } else {
Some(x) Some(x)
}; };
if let Some((y, z)) = y { if let Some((y, z)) = y {
raw = if let Some(raw) = raw { ret = if let Some(ret) = ret {
Some(str_concat::concat(raw, y).unwrap()) Some(concat(ret, y).unwrap())
} else { } else {
Some(y) Some(y)
}; };
raw = if let Some(raw) = raw { ret = if let Some(ret) = ret {
Some(str_concat::concat(raw, z).unwrap()) Some(concat(ret, z).unwrap())
} else { } else {
Some(z) Some(z)
}; };
} }
} }
let raw = raw.unwrap(); let ret = ret.unwrap();
Ok((s, StringLiteral { nodes: (raw,) })) Ok((s, ret))
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -58,16 +59,25 @@ mod tests {
#[test] #[test]
fn test() { fn test() {
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(string_literal)("\"aaa aaaa\"")), format!(
"Ok((\"\", StringLiteral { raw: \"aaa aaaa\" }))" "{:?}",
all_consuming(string_literal)(Span::new("\"aaa aaaa\""))
),
"Ok((LocatedSpanEx { offset: 10, line: 1, fragment: \"\", extra: () }, StringLiteral { nodes: (LocatedSpanEx { offset: 1, line: 1, fragment: \"aaa aaaa\", extra: () }, []) }))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(string_literal)(r#""aaa\" aaaa""#)), format!(
"Ok((\"\", StringLiteral { raw: \"aaa\\\\\\\" aaaa\" }))" "{:?}",
all_consuming(string_literal)(Span::new(r#""aaa\" aaaa""#))
),
"Ok((LocatedSpanEx { offset: 12, line: 1, fragment: \"\", extra: () }, StringLiteral { nodes: (LocatedSpanEx { offset: 1, line: 1, fragment: \"aaa\\\\\\\" aaaa\", extra: () }, []) }))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(string_literal)(r#""aaa\"""#)), format!(
"Ok((\"\", StringLiteral { raw: \"aaa\\\\\\\"\" }))" "{:?}",
all_consuming(string_literal)(Span::new(r#""aaa\"""#))
),
"Ok((LocatedSpanEx { offset: 7, line: 1, fragment: \"\", extra: () }, StringLiteral { nodes: (LocatedSpanEx { offset: 1, line: 1, fragment: \"aaa\\\\\\\"\", extra: () }, []) }))"
); );
} }
} }

View File

@ -102,18 +102,18 @@ pub enum ArrayMethodName<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn constant_function_call(s: &str) -> IResult<&str, SubroutineCall> { pub fn constant_function_call(s: Span) -> IResult<Span, SubroutineCall> {
function_subroutine_call(s) function_subroutine_call(s)
} }
pub fn tf_call(s: &str) -> IResult<&str, TfCall> { pub fn tf_call(s: Span) -> IResult<Span, TfCall> {
let (s, x) = ps_or_hierarchical_tf_identifier(s)?; let (s, x) = ps_or_hierarchical_tf_identifier(s)?;
let (s, y) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, z) = opt(paren(list_of_arguments))(s)?; let (s, z) = opt(paren(list_of_arguments))(s)?;
Ok((s, TfCall { nodes: (x, y, z) })) Ok((s, TfCall { nodes: (x, y, z) }))
} }
pub fn system_tf_call(s: &str) -> IResult<&str, SystemTfCall> { pub fn system_tf_call(s: Span) -> IResult<Span, SystemTfCall> {
alt(( alt((
system_tf_call_list_of_arguments, system_tf_call_list_of_arguments,
system_tf_call_data_type, system_tf_call_data_type,
@ -121,7 +121,7 @@ pub fn system_tf_call(s: &str) -> IResult<&str, SystemTfCall> {
))(s) ))(s)
} }
pub fn system_tf_call_list_of_arguments(s: &str) -> IResult<&str, SystemTfCall> { pub fn system_tf_call_list_of_arguments(s: Span) -> IResult<Span, SystemTfCall> {
let (s, x) = system_tf_identifier(s)?; let (s, x) = system_tf_identifier(s)?;
let (s, y) = opt(paren(list_of_arguments))(s)?; let (s, y) = opt(paren(list_of_arguments))(s)?;
Ok(( Ok((
@ -132,7 +132,7 @@ pub fn system_tf_call_list_of_arguments(s: &str) -> IResult<&str, SystemTfCall>
)) ))
} }
pub fn system_tf_call_data_type(s: &str) -> IResult<&str, SystemTfCall> { pub fn system_tf_call_data_type(s: Span) -> IResult<Span, SystemTfCall> {
let (s, x) = system_tf_identifier(s)?; let (s, x) = system_tf_identifier(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, y) = data_type(s)?; let (s, y) = data_type(s)?;
@ -146,7 +146,7 @@ pub fn system_tf_call_data_type(s: &str) -> IResult<&str, SystemTfCall> {
)) ))
} }
pub fn system_tf_call_clocking_event(s: &str) -> IResult<&str, SystemTfCall> { pub fn system_tf_call_clocking_event(s: Span) -> IResult<Span, SystemTfCall> {
let (s, x) = system_tf_identifier(s)?; let (s, x) = system_tf_identifier(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, y) = separated_nonempty_list(symbol(","), expression)(s)?; let (s, y) = separated_nonempty_list(symbol(","), expression)(s)?;
@ -161,7 +161,7 @@ pub fn system_tf_call_clocking_event(s: &str) -> IResult<&str, SystemTfCall> {
)) ))
} }
pub fn subroutine_call(s: &str) -> IResult<&str, SubroutineCall> { pub fn subroutine_call(s: Span) -> IResult<Span, SubroutineCall> {
alt(( alt((
map(tf_call, |x| SubroutineCall::Tf(Box::new(x))), map(tf_call, |x| SubroutineCall::Tf(Box::new(x))),
map(system_tf_call, |x| SubroutineCall::SystemTf(Box::new(x))), map(system_tf_call, |x| SubroutineCall::SystemTf(Box::new(x))),
@ -174,11 +174,11 @@ pub fn subroutine_call(s: &str) -> IResult<&str, SubroutineCall> {
))(s) ))(s)
} }
pub fn function_subroutine_call(s: &str) -> IResult<&str, SubroutineCall> { pub fn function_subroutine_call(s: Span) -> IResult<Span, SubroutineCall> {
subroutine_call(s) subroutine_call(s)
} }
pub fn list_of_arguments(s: &str) -> IResult<&str, ListOfArguments> { pub fn list_of_arguments(s: Span) -> IResult<Span, ListOfArguments> {
let (s, x) = separated_list(symbol(","), expression)(s)?; let (s, x) = separated_list(symbol(","), expression)(s)?;
let (s, y) = separated_list( let (s, y) = separated_list(
symbol(","), symbol(","),
@ -187,7 +187,7 @@ pub fn list_of_arguments(s: &str) -> IResult<&str, ListOfArguments> {
Ok((s, ListOfArguments { nodes: (x, y) })) Ok((s, ListOfArguments { nodes: (x, y) }))
} }
pub fn method_call(s: &str) -> IResult<&str, MethodCall> { pub fn method_call(s: Span) -> IResult<Span, MethodCall> {
let (s, x) = method_call_root(s)?; let (s, x) = method_call_root(s)?;
let (s, _) = symbol(".")(s)?; let (s, _) = symbol(".")(s)?;
let (s, y) = method_call_body(s)?; let (s, y) = method_call_body(s)?;
@ -195,11 +195,11 @@ pub fn method_call(s: &str) -> IResult<&str, MethodCall> {
Ok((s, MethodCall { nodes: (x, y) })) Ok((s, MethodCall { nodes: (x, y) }))
} }
pub fn method_call_body(s: &str) -> IResult<&str, MethodCallBody> { pub fn method_call_body(s: Span) -> IResult<Span, MethodCallBody> {
alt((method_call_body_user, built_in_method_call))(s) alt((method_call_body_user, built_in_method_call))(s)
} }
pub fn method_call_body_user(s: &str) -> IResult<&str, MethodCallBody> { pub fn method_call_body_user(s: Span) -> IResult<Span, MethodCallBody> {
let (s, x) = method_identifier(s)?; let (s, x) = method_identifier(s)?;
let (s, y) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, z) = opt(paren(list_of_arguments))(s)?; let (s, z) = opt(paren(list_of_arguments))(s)?;
@ -209,14 +209,14 @@ pub fn method_call_body_user(s: &str) -> IResult<&str, MethodCallBody> {
)) ))
} }
pub fn built_in_method_call(s: &str) -> IResult<&str, MethodCallBody> { pub fn built_in_method_call(s: Span) -> IResult<Span, MethodCallBody> {
alt(( alt((
map(array_manipulation_call, |x| MethodCallBody::Array(x)), map(array_manipulation_call, |x| MethodCallBody::Array(x)),
map(randomize_call, |x| MethodCallBody::Randomize(x)), map(randomize_call, |x| MethodCallBody::Randomize(x)),
))(s) ))(s)
} }
pub fn array_manipulation_call(s: &str) -> IResult<&str, ArrayManipulationCall> { pub fn array_manipulation_call(s: Span) -> IResult<Span, ArrayManipulationCall> {
let (s, x) = array_method_name(s)?; let (s, x) = array_method_name(s)?;
let (s, y) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, z) = opt(paren(list_of_arguments))(s)?; let (s, z) = opt(paren(list_of_arguments))(s)?;
@ -229,7 +229,7 @@ pub fn array_manipulation_call(s: &str) -> IResult<&str, ArrayManipulationCall>
)) ))
} }
pub fn randomize_call(s: &str) -> IResult<&str, RandomizeCall> { pub fn randomize_call(s: Span) -> IResult<Span, RandomizeCall> {
let (s, _) = symbol("randomize")(s)?; let (s, _) = symbol("randomize")(s)?;
let (s, x) = many0(attribute_instance)(s)?; let (s, x) = many0(attribute_instance)(s)?;
let (s, y) = opt(paren(opt(alt(( let (s, y) = opt(paren(opt(alt((
@ -261,7 +261,7 @@ pub fn randomize_call(s: &str) -> IResult<&str, RandomizeCall> {
)) ))
} }
pub fn method_call_root(s: &str) -> IResult<&str, MethodCallRoot> { pub fn method_call_root(s: Span) -> IResult<Span, MethodCallRoot> {
alt(( alt((
map(primary, |x| MethodCallRoot::Primary(x)), map(primary, |x| MethodCallRoot::Primary(x)),
map(implicit_class_handle, |x| { map(implicit_class_handle, |x| {
@ -270,7 +270,7 @@ pub fn method_call_root(s: &str) -> IResult<&str, MethodCallRoot> {
))(s) ))(s)
} }
pub fn array_method_name(s: &str) -> IResult<&str, ArrayMethodName> { pub fn array_method_name(s: Span) -> IResult<Span, ArrayMethodName> {
alt(( alt((
map(symbol("unique"), |_| ArrayMethodName::Unique), map(symbol("unique"), |_| ArrayMethodName::Unique),
map(symbol("and"), |_| ArrayMethodName::And), map(symbol("and"), |_| ArrayMethodName::And),

View File

@ -18,14 +18,14 @@ pub struct AttrSpec<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn attribute_instance(s: &str) -> IResult<&str, AttributeInstance> { pub fn attribute_instance(s: Span) -> IResult<Span, AttributeInstance> {
let (s, _) = symbol("(*")(s)?; let (s, _) = symbol("(*")(s)?;
let (s, x) = separated_nonempty_list(symbol(","), attr_spec)(s)?; let (s, x) = separated_nonempty_list(symbol(","), attr_spec)(s)?;
let (s, _) = symbol("*)")(s)?; let (s, _) = symbol("*)")(s)?;
Ok((s, AttributeInstance { nodes: (x,) })) Ok((s, AttributeInstance { nodes: (x,) }))
} }
pub fn attr_spec(s: &str) -> IResult<&str, AttrSpec> { pub fn attr_spec(s: Span) -> IResult<Span, AttrSpec> {
let (s, x) = identifier(s)?; let (s, x) = identifier(s)?;
let (s, y) = opt(preceded(symbol("="), constant_expression))(s)?; let (s, y) = opt(preceded(symbol("="), constant_expression))(s)?;
Ok((s, AttrSpec { nodes: (x, y) })) Ok((s, AttrSpec { nodes: (x, y) }))
@ -42,23 +42,23 @@ mod tests {
assert_eq!( assert_eq!(
format!( format!(
"{:?}", "{:?}",
all_consuming(attribute_instance)("(* full_case, parallel_case *)") all_consuming(attribute_instance)(Span::new("(* full_case, parallel_case *)"))
), ),
"Ok((\"\", AttributeInstance { attr_spec: [AttrSpec { attr_name: Identifier { raw: \"full_case\" }, rvalue: None }, AttrSpec { attr_name: Identifier { raw: \"parallel_case\" }, rvalue: None }] }))" "Ok((LocatedSpanEx { offset: 30, line: 1, fragment: \"\", extra: () }, AttributeInstance { nodes: ([AttrSpec { nodes: (SimpleIdentifier(SimpleIdentifier { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \"full_case\", extra: () }, []) }), None) }, AttrSpec { nodes: (SimpleIdentifier(SimpleIdentifier { nodes: (LocatedSpanEx { offset: 14, line: 1, fragment: \"parallel_case\", extra: () }, [Space(LocatedSpanEx { offset: 27, line: 1, fragment: \" \", extra: () })]) }), None) }],) }))"
); );
assert_eq!( assert_eq!(
format!( format!(
"{:?}", "{:?}",
all_consuming(attribute_instance)("(* full_case=1 *)") all_consuming(attribute_instance)(Span::new("(* full_case=1 *)"))
), ),
"Ok((\"\", AttributeInstance { attr_spec: [AttrSpec { attr_name: Identifier { raw: \"full_case\" }, rvalue: Some(Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))) }] }))" "Ok((LocatedSpanEx { offset: 17, line: 1, fragment: \"\", extra: () }, AttributeInstance { nodes: ([AttrSpec { nodes: (SimpleIdentifier(SimpleIdentifier { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \"full_case\", extra: () }, []) }), Some(Nullary(PrimaryLiteral(Number(IntegralNumber(DecimalNumber(UnsignedNumber(UnsignedNumber { nodes: (LocatedSpanEx { offset: 13, line: 1, fragment: \"1\", extra: () }, [Space(LocatedSpanEx { offset: 14, line: 1, fragment: \" \", extra: () })]) })))))))) }],) }))"
); );
assert_eq!( assert_eq!(
format!( format!(
"{:?}", "{:?}",
all_consuming(attribute_instance)("(* full_case=1, parallel_case = 0 *)") all_consuming(attribute_instance)(Span::new("(* full_case=1, parallel_case = 0 *)"))
), ),
"Ok((\"\", AttributeInstance { attr_spec: [AttrSpec { attr_name: Identifier { raw: \"full_case\" }, rvalue: Some(Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))) }, AttrSpec { attr_name: Identifier { raw: \"parallel_case\" }, rvalue: Some(Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"0\")))))) }] }))" "Ok((LocatedSpanEx { offset: 36, line: 1, fragment: \"\", extra: () }, AttributeInstance { nodes: ([AttrSpec { nodes: (SimpleIdentifier(SimpleIdentifier { nodes: (LocatedSpanEx { offset: 3, line: 1, fragment: \"full_case\", extra: () }, []) }), Some(Nullary(PrimaryLiteral(Number(IntegralNumber(DecimalNumber(UnsignedNumber(UnsignedNumber { nodes: (LocatedSpanEx { offset: 13, line: 1, fragment: \"1\", extra: () }, []) })))))))) }, AttrSpec { nodes: (SimpleIdentifier(SimpleIdentifier { nodes: (LocatedSpanEx { offset: 16, line: 1, fragment: \"parallel_case\", extra: () }, [Space(LocatedSpanEx { offset: 29, line: 1, fragment: \" \", extra: () })]) }), Some(Nullary(PrimaryLiteral(Number(IntegralNumber(DecimalNumber(UnsignedNumber(UnsignedNumber { nodes: (LocatedSpanEx { offset: 32, line: 1, fragment: \"0\", extra: () }, [Space(LocatedSpanEx { offset: 33, line: 1, fragment: \" \", extra: () })]) })))))))) }],) }))"
); );
} }
} }

View File

@ -1,3 +1,4 @@
use crate::parser::*;
use nom::branch::*; use nom::branch::*;
use nom::bytes::complete::*; use nom::bytes::complete::*;
use nom::IResult; use nom::IResult;
@ -6,28 +7,28 @@ use nom::IResult;
#[derive(Debug)] #[derive(Debug)]
pub struct Comment<'a> { pub struct Comment<'a> {
nodes: (&'a str,), nodes: (Span<'a>,),
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn comment(s: &str) -> IResult<&str, Comment> { pub fn comment(s: Span) -> IResult<Span, Comment> {
alt((one_line_comment, block_comment))(s) alt((one_line_comment, block_comment))(s)
} }
pub fn one_line_comment(s: &str) -> IResult<&str, Comment> { pub fn one_line_comment(s: Span) -> IResult<Span, Comment> {
let (s, x) = tag("//")(s)?; let (s, x) = tag("//")(s)?;
let (s, y) = is_not("\n")(s)?; let (s, y) = is_not("\n")(s)?;
let x = str_concat::concat(x, y).unwrap(); let x = concat(x, y).unwrap();
Ok((s, Comment { nodes: (x,) })) Ok((s, Comment { nodes: (x,) }))
} }
pub fn block_comment(s: &str) -> IResult<&str, Comment> { pub fn block_comment(s: Span) -> IResult<Span, Comment> {
let (s, x) = tag("/*")(s)?; let (s, x) = tag("/*")(s)?;
let (s, y) = is_not("*/")(s)?; let (s, y) = is_not("*/")(s)?;
let (s, z) = tag("*/")(s)?; let (s, z) = tag("*/")(s)?;
let x = str_concat::concat(x, y).unwrap(); let x = concat(x, y).unwrap();
let x = str_concat::concat(x, z).unwrap(); let x = concat(x, z).unwrap();
Ok((s, Comment { nodes: (x,) })) Ok((s, Comment { nodes: (x,) }))
} }
@ -41,12 +42,15 @@ mod tests {
#[test] #[test]
fn test() { fn test() {
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(comment)("// comment")), format!("{:?}", all_consuming(comment)(Span::new("// comment"))),
"Ok((\"\", Comment { raw: \"// comment\" }))" "Ok((LocatedSpanEx { offset: 10, line: 1, fragment: \"\", extra: () }, Comment { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"// comment\", extra: () },) }))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(comment)("/* comment\n\n */")), format!(
"Ok((\"\", Comment { raw: \"/* comment\\n\\n */\" }))" "{:?}",
all_consuming(comment)(Span::new("/* comment\n\n */"))
),
"Ok((LocatedSpanEx { offset: 15, line: 3, fragment: \"\", extra: () }, Comment { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"/* comment\\n\\n */\", extra: () },) }))"
); );
} }
} }

View File

@ -29,7 +29,7 @@ pub struct BinIdentifier<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct CIdentifier<'a> { pub struct CIdentifier<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
@ -104,7 +104,7 @@ pub struct EnumIdentifier<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct EscapedIdentifier<'a> { pub struct EscapedIdentifier<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
@ -447,7 +447,7 @@ pub struct SignalIdentifier<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct SimpleIdentifier<'a> { pub struct SimpleIdentifier<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
@ -457,7 +457,7 @@ pub struct SpecparamIdentifier<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct SystemTfIdentifier<'a> { pub struct SystemTfIdentifier<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
@ -522,438 +522,442 @@ pub enum PackageScopeOrClassScope<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn array_identifier(s: &str) -> IResult<&str, ArrayIdentifier> { pub fn array_identifier(s: Span) -> IResult<Span, ArrayIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, ArrayIdentifier { nodes: (a,) })) Ok((s, ArrayIdentifier { nodes: (a,) }))
} }
pub fn block_identifier(s: &str) -> IResult<&str, BlockIdentifier> { pub fn block_identifier(s: Span) -> IResult<Span, BlockIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, BlockIdentifier { nodes: (a,) })) Ok((s, BlockIdentifier { nodes: (a,) }))
} }
pub fn bin_identifier(s: &str) -> IResult<&str, BinIdentifier> { pub fn bin_identifier(s: Span) -> IResult<Span, BinIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, BinIdentifier { nodes: (a,) })) Ok((s, BinIdentifier { nodes: (a,) }))
} }
pub fn c_identifier(s: &str) -> IResult<&str, CIdentifier> { pub fn c_identifier(s: Span) -> IResult<Span, CIdentifier> {
ws(c_identifier_impl)(s) let (s, a) = ws(c_identifier_impl)(s)?;
Ok((s, CIdentifier { nodes: a }))
} }
pub fn c_identifier_impl(s: &str) -> IResult<&str, CIdentifier> { pub fn c_identifier_impl(s: Span) -> IResult<Span, Span> {
let (s, a) = is_a(AZ_)(s)?; let (s, a) = is_a(AZ_)(s)?;
let (s, b) = opt(is_a(AZ09_))(s)?; let (s, b) = opt(is_a(AZ09_))(s)?;
let a = if let Some(b) = b { let a = if let Some(b) = b {
str_concat::concat(a, b).unwrap() concat(a, b).unwrap()
} else { } else {
a a
}; };
Ok((s, CIdentifier { nodes: (a,) })) Ok((s, a))
} }
pub fn cell_identifier(s: &str) -> IResult<&str, CellIdentifier> { pub fn cell_identifier(s: Span) -> IResult<Span, CellIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, CellIdentifier { nodes: (a,) })) Ok((s, CellIdentifier { nodes: (a,) }))
} }
pub fn checker_identifier(s: &str) -> IResult<&str, CheckerIdentifier> { pub fn checker_identifier(s: Span) -> IResult<Span, CheckerIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, CheckerIdentifier { nodes: (a,) })) Ok((s, CheckerIdentifier { nodes: (a,) }))
} }
pub fn class_identifier(s: &str) -> IResult<&str, ClassIdentifier> { pub fn class_identifier(s: Span) -> IResult<Span, ClassIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, ClassIdentifier { nodes: (a,) })) Ok((s, ClassIdentifier { nodes: (a,) }))
} }
pub fn class_variable_identifier(s: &str) -> IResult<&str, ClassVariableIdentifier> { pub fn class_variable_identifier(s: Span) -> IResult<Span, ClassVariableIdentifier> {
let (s, a) = variable_identifier(s)?; let (s, a) = variable_identifier(s)?;
Ok((s, ClassVariableIdentifier { nodes: (a,) })) Ok((s, ClassVariableIdentifier { nodes: (a,) }))
} }
pub fn clocking_identifier(s: &str) -> IResult<&str, ClockingIdentifier> { pub fn clocking_identifier(s: Span) -> IResult<Span, ClockingIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, ClockingIdentifier { nodes: (a,) })) Ok((s, ClockingIdentifier { nodes: (a,) }))
} }
pub fn config_identifier(s: &str) -> IResult<&str, ConfigIdentifier> { pub fn config_identifier(s: Span) -> IResult<Span, ConfigIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, ConfigIdentifier { nodes: (a,) })) Ok((s, ConfigIdentifier { nodes: (a,) }))
} }
pub fn const_identifier(s: &str) -> IResult<&str, ConstIdentifier> { pub fn const_identifier(s: Span) -> IResult<Span, ConstIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, ConstIdentifier { nodes: (a,) })) Ok((s, ConstIdentifier { nodes: (a,) }))
} }
pub fn constraint_identifier(s: &str) -> IResult<&str, ConstraintIdentifier> { pub fn constraint_identifier(s: Span) -> IResult<Span, ConstraintIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, ConstraintIdentifier { nodes: (a,) })) Ok((s, ConstraintIdentifier { nodes: (a,) }))
} }
pub fn covergroup_identifier(s: &str) -> IResult<&str, CovergroupIdentifier> { pub fn covergroup_identifier(s: Span) -> IResult<Span, CovergroupIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, CovergroupIdentifier { nodes: (a,) })) Ok((s, CovergroupIdentifier { nodes: (a,) }))
} }
pub fn covergroup_variable_identifier(s: &str) -> IResult<&str, CovergroupVariableIdentifier> { pub fn covergroup_variable_identifier(s: Span) -> IResult<Span, CovergroupVariableIdentifier> {
let (s, a) = variable_identifier(s)?; let (s, a) = variable_identifier(s)?;
Ok((s, CovergroupVariableIdentifier { nodes: (a,) })) Ok((s, CovergroupVariableIdentifier { nodes: (a,) }))
} }
pub fn cover_point_identifier(s: &str) -> IResult<&str, CoverPointIdentifier> { pub fn cover_point_identifier(s: Span) -> IResult<Span, CoverPointIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, CoverPointIdentifier { nodes: (a,) })) Ok((s, CoverPointIdentifier { nodes: (a,) }))
} }
pub fn cross_identifier(s: &str) -> IResult<&str, CrossIdentifier> { pub fn cross_identifier(s: Span) -> IResult<Span, CrossIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, CrossIdentifier { nodes: (a,) })) Ok((s, CrossIdentifier { nodes: (a,) }))
} }
pub fn dynamic_array_variable_identifier(s: &str) -> IResult<&str, DynamicArrayVariableIdentifier> { pub fn dynamic_array_variable_identifier(s: Span) -> IResult<Span, DynamicArrayVariableIdentifier> {
let (s, a) = variable_identifier(s)?; let (s, a) = variable_identifier(s)?;
Ok((s, DynamicArrayVariableIdentifier { nodes: (a,) })) Ok((s, DynamicArrayVariableIdentifier { nodes: (a,) }))
} }
pub fn enum_identifier(s: &str) -> IResult<&str, EnumIdentifier> { pub fn enum_identifier(s: Span) -> IResult<Span, EnumIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, EnumIdentifier { nodes: (a,) })) Ok((s, EnumIdentifier { nodes: (a,) }))
} }
pub fn escaped_identifier(s: &str) -> IResult<&str, EscapedIdentifier> { pub fn escaped_identifier(s: Span) -> IResult<Span, EscapedIdentifier> {
ws(escaped_identifier_impl)(s) let (s, a) = ws(escaped_identifier_impl)(s)?;
Ok((s, EscapedIdentifier { nodes: a }))
} }
pub fn escaped_identifier_impl(s: &str) -> IResult<&str, EscapedIdentifier> { pub fn escaped_identifier_impl(s: Span) -> IResult<Span, Span> {
let (s, a) = tag("\\")(s)?; let (s, a) = tag("\\")(s)?;
let (s, b) = is_not(" \t\r\n")(s)?; let (s, b) = is_not(" \t\r\n")(s)?;
let a = str_concat::concat(a, b).unwrap(); let a = concat(a, b).unwrap();
Ok((s, EscapedIdentifier { nodes: (a,) })) Ok((s, a))
} }
pub fn formal_identifier(s: &str) -> IResult<&str, FormalIdentifier> { pub fn formal_identifier(s: Span) -> IResult<Span, FormalIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, FormalIdentifier { nodes: (a,) })) Ok((s, FormalIdentifier { nodes: (a,) }))
} }
pub fn formal_port_identifier(s: &str) -> IResult<&str, FormalPortIdentifier> { pub fn formal_port_identifier(s: Span) -> IResult<Span, FormalPortIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, FormalPortIdentifier { nodes: (a,) })) Ok((s, FormalPortIdentifier { nodes: (a,) }))
} }
pub fn function_identifier(s: &str) -> IResult<&str, FunctionIdentifier> { pub fn function_identifier(s: Span) -> IResult<Span, FunctionIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, FunctionIdentifier { nodes: (a,) })) Ok((s, FunctionIdentifier { nodes: (a,) }))
} }
pub fn generate_block_identifier(s: &str) -> IResult<&str, GenerateBlockIdentifier> { pub fn generate_block_identifier(s: Span) -> IResult<Span, GenerateBlockIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, GenerateBlockIdentifier { nodes: (a,) })) Ok((s, GenerateBlockIdentifier { nodes: (a,) }))
} }
pub fn genvar_identifier(s: &str) -> IResult<&str, GenvarIdentifier> { pub fn genvar_identifier(s: Span) -> IResult<Span, GenvarIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, GenvarIdentifier { nodes: (a,) })) Ok((s, GenvarIdentifier { nodes: (a,) }))
} }
pub fn hierarchical_array_identifier(s: &str) -> IResult<&str, HierarchicalArrayIdentifier> { pub fn hierarchical_array_identifier(s: Span) -> IResult<Span, HierarchicalArrayIdentifier> {
let (s, a) = hierarchical_identifier(s)?; let (s, a) = hierarchical_identifier(s)?;
Ok((s, HierarchicalArrayIdentifier { nodes: (a,) })) Ok((s, HierarchicalArrayIdentifier { nodes: (a,) }))
} }
pub fn hierarchical_block_identifier(s: &str) -> IResult<&str, HierarchicalBlockIdentifier> { pub fn hierarchical_block_identifier(s: Span) -> IResult<Span, HierarchicalBlockIdentifier> {
let (s, a) = hierarchical_identifier(s)?; let (s, a) = hierarchical_identifier(s)?;
Ok((s, HierarchicalBlockIdentifier { nodes: (a,) })) Ok((s, HierarchicalBlockIdentifier { nodes: (a,) }))
} }
pub fn hierarchical_event_identifier(s: &str) -> IResult<&str, HierarchicalEventIdentifier> { pub fn hierarchical_event_identifier(s: Span) -> IResult<Span, HierarchicalEventIdentifier> {
let (s, a) = hierarchical_identifier(s)?; let (s, a) = hierarchical_identifier(s)?;
Ok((s, HierarchicalEventIdentifier { nodes: (a,) })) Ok((s, HierarchicalEventIdentifier { nodes: (a,) }))
} }
pub fn hierarchical_identifier(s: &str) -> IResult<&str, HierarchicalIdentifier> { pub fn hierarchical_identifier(s: Span) -> IResult<Span, HierarchicalIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn hierarchical_net_identifier(s: &str) -> IResult<&str, HierarchicalNetIdentifier> { pub fn hierarchical_net_identifier(s: Span) -> IResult<Span, HierarchicalNetIdentifier> {
let (s, a) = hierarchical_identifier(s)?; let (s, a) = hierarchical_identifier(s)?;
Ok((s, HierarchicalNetIdentifier { nodes: (a,) })) Ok((s, HierarchicalNetIdentifier { nodes: (a,) }))
} }
pub fn hierarchical_parameter_identifier( pub fn hierarchical_parameter_identifier(
s: &str, s: Span,
) -> IResult<&str, HierarchicalParameterIdentifier> { ) -> IResult<Span, HierarchicalParameterIdentifier> {
let (s, a) = hierarchical_identifier(s)?; let (s, a) = hierarchical_identifier(s)?;
Ok((s, HierarchicalParameterIdentifier { nodes: (a,) })) Ok((s, HierarchicalParameterIdentifier { nodes: (a,) }))
} }
pub fn hierarchical_property_identifier(s: &str) -> IResult<&str, HierarchicalPropertyIdentifier> { pub fn hierarchical_property_identifier(s: Span) -> IResult<Span, HierarchicalPropertyIdentifier> {
let (s, a) = hierarchical_identifier(s)?; let (s, a) = hierarchical_identifier(s)?;
Ok((s, HierarchicalPropertyIdentifier { nodes: (a,) })) Ok((s, HierarchicalPropertyIdentifier { nodes: (a,) }))
} }
pub fn hierarchical_sequence_identifier(s: &str) -> IResult<&str, HierarchicalSequenceIdentifier> { pub fn hierarchical_sequence_identifier(s: Span) -> IResult<Span, HierarchicalSequenceIdentifier> {
let (s, a) = hierarchical_identifier(s)?; let (s, a) = hierarchical_identifier(s)?;
Ok((s, HierarchicalSequenceIdentifier { nodes: (a,) })) Ok((s, HierarchicalSequenceIdentifier { nodes: (a,) }))
} }
pub fn hierarchical_task_identifier(s: &str) -> IResult<&str, HierarchicalTaskIdentifier> { pub fn hierarchical_task_identifier(s: Span) -> IResult<Span, HierarchicalTaskIdentifier> {
let (s, a) = hierarchical_identifier(s)?; let (s, a) = hierarchical_identifier(s)?;
Ok((s, HierarchicalTaskIdentifier { nodes: (a,) })) Ok((s, HierarchicalTaskIdentifier { nodes: (a,) }))
} }
pub fn hierarchical_tf_identifier(s: &str) -> IResult<&str, HierarchicalTfIdentifier> { pub fn hierarchical_tf_identifier(s: Span) -> IResult<Span, HierarchicalTfIdentifier> {
let (s, a) = hierarchical_identifier(s)?; let (s, a) = hierarchical_identifier(s)?;
Ok((s, HierarchicalTfIdentifier { nodes: (a,) })) Ok((s, HierarchicalTfIdentifier { nodes: (a,) }))
} }
pub fn hierarchical_variable_identifier(s: &str) -> IResult<&str, HierarchicalVariableIdentifier> { pub fn hierarchical_variable_identifier(s: Span) -> IResult<Span, HierarchicalVariableIdentifier> {
let (s, a) = hierarchical_identifier(s)?; let (s, a) = hierarchical_identifier(s)?;
Ok((s, HierarchicalVariableIdentifier { nodes: (a,) })) Ok((s, HierarchicalVariableIdentifier { nodes: (a,) }))
} }
pub fn identifier(s: &str) -> IResult<&str, Identifier> { pub fn identifier(s: Span) -> IResult<Span, Identifier> {
alt(( alt((
map(escaped_identifier, |x| Identifier::EscapedIdentifier(x)), map(escaped_identifier, |x| Identifier::EscapedIdentifier(x)),
map(simple_identifier, |x| Identifier::SimpleIdentifier(x)), map(simple_identifier, |x| Identifier::SimpleIdentifier(x)),
))(s) ))(s)
} }
pub fn index_variable_identifier(s: &str) -> IResult<&str, IndexVariableIdentifier> { pub fn index_variable_identifier(s: Span) -> IResult<Span, IndexVariableIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, IndexVariableIdentifier { nodes: (a,) })) Ok((s, IndexVariableIdentifier { nodes: (a,) }))
} }
pub fn interface_identifier(s: &str) -> IResult<&str, InterfaceIdentifier> { pub fn interface_identifier(s: Span) -> IResult<Span, InterfaceIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, InterfaceIdentifier { nodes: (a,) })) Ok((s, InterfaceIdentifier { nodes: (a,) }))
} }
pub fn interface_instance_identifier(s: &str) -> IResult<&str, InterfaceInstanceIdentifier> { pub fn interface_instance_identifier(s: Span) -> IResult<Span, InterfaceInstanceIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, InterfaceInstanceIdentifier { nodes: (a,) })) Ok((s, InterfaceInstanceIdentifier { nodes: (a,) }))
} }
pub fn inout_port_identifier(s: &str) -> IResult<&str, InoutPortIdentifier> { pub fn inout_port_identifier(s: Span) -> IResult<Span, InoutPortIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, InoutPortIdentifier { nodes: (a,) })) Ok((s, InoutPortIdentifier { nodes: (a,) }))
} }
pub fn input_port_identifier(s: &str) -> IResult<&str, InputPortIdentifier> { pub fn input_port_identifier(s: Span) -> IResult<Span, InputPortIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, InputPortIdentifier { nodes: (a,) })) Ok((s, InputPortIdentifier { nodes: (a,) }))
} }
pub fn instance_identifier(s: &str) -> IResult<&str, InstanceIdentifier> { pub fn instance_identifier(s: Span) -> IResult<Span, InstanceIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, InstanceIdentifier { nodes: (a,) })) Ok((s, InstanceIdentifier { nodes: (a,) }))
} }
pub fn library_identifier(s: &str) -> IResult<&str, LibraryIdentifier> { pub fn library_identifier(s: Span) -> IResult<Span, LibraryIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, LibraryIdentifier { nodes: (a,) })) Ok((s, LibraryIdentifier { nodes: (a,) }))
} }
pub fn member_identifier(s: &str) -> IResult<&str, MemberIdentifier> { pub fn member_identifier(s: Span) -> IResult<Span, MemberIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, MemberIdentifier { nodes: (a,) })) Ok((s, MemberIdentifier { nodes: (a,) }))
} }
pub fn method_identifier(s: &str) -> IResult<&str, MethodIdentifier> { pub fn method_identifier(s: Span) -> IResult<Span, MethodIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, MethodIdentifier { nodes: (a,) })) Ok((s, MethodIdentifier { nodes: (a,) }))
} }
pub fn modport_identifier(s: &str) -> IResult<&str, ModportIdentifier> { pub fn modport_identifier(s: Span) -> IResult<Span, ModportIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, ModportIdentifier { nodes: (a,) })) Ok((s, ModportIdentifier { nodes: (a,) }))
} }
pub fn module_identifier(s: &str) -> IResult<&str, ModuleIdentifier> { pub fn module_identifier(s: Span) -> IResult<Span, ModuleIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, ModuleIdentifier { nodes: (a,) })) Ok((s, ModuleIdentifier { nodes: (a,) }))
} }
pub fn net_identifier(s: &str) -> IResult<&str, NetIdentifier> { pub fn net_identifier(s: Span) -> IResult<Span, NetIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, NetIdentifier { nodes: (a,) })) Ok((s, NetIdentifier { nodes: (a,) }))
} }
pub fn net_type_identifier(s: &str) -> IResult<&str, NetTypeIdentifier> { pub fn net_type_identifier(s: Span) -> IResult<Span, NetTypeIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, NetTypeIdentifier { nodes: (a,) })) Ok((s, NetTypeIdentifier { nodes: (a,) }))
} }
pub fn output_port_identifier(s: &str) -> IResult<&str, OutputPortIdentifier> { pub fn output_port_identifier(s: Span) -> IResult<Span, OutputPortIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, OutputPortIdentifier { nodes: (a,) })) Ok((s, OutputPortIdentifier { nodes: (a,) }))
} }
pub fn package_identifier(s: &str) -> IResult<&str, PackageIdentifier> { pub fn package_identifier(s: Span) -> IResult<Span, PackageIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, PackageIdentifier { nodes: (a,) })) Ok((s, PackageIdentifier { nodes: (a,) }))
} }
pub fn package_scope(s: &str) -> IResult<&str, PackageScope> { pub fn package_scope(s: Span) -> IResult<Span, PackageScope> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn parameter_identifier(s: &str) -> IResult<&str, ParameterIdentifier> { pub fn parameter_identifier(s: Span) -> IResult<Span, ParameterIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, ParameterIdentifier { nodes: (a,) })) Ok((s, ParameterIdentifier { nodes: (a,) }))
} }
pub fn port_identifier(s: &str) -> IResult<&str, PortIdentifier> { pub fn port_identifier(s: Span) -> IResult<Span, PortIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, PortIdentifier { nodes: (a,) })) Ok((s, PortIdentifier { nodes: (a,) }))
} }
pub fn production_identifier(s: &str) -> IResult<&str, ProductionIdentifier> { pub fn production_identifier(s: Span) -> IResult<Span, ProductionIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, ProductionIdentifier { nodes: (a,) })) Ok((s, ProductionIdentifier { nodes: (a,) }))
} }
pub fn program_identifier(s: &str) -> IResult<&str, ProgramIdentifier> { pub fn program_identifier(s: Span) -> IResult<Span, ProgramIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, ProgramIdentifier { nodes: (a,) })) Ok((s, ProgramIdentifier { nodes: (a,) }))
} }
pub fn property_identifier(s: &str) -> IResult<&str, PropertyIdentifier> { pub fn property_identifier(s: Span) -> IResult<Span, PropertyIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, PropertyIdentifier { nodes: (a,) })) Ok((s, PropertyIdentifier { nodes: (a,) }))
} }
pub fn ps_class_identifier(s: &str) -> IResult<&str, PsClassIdentifier> { pub fn ps_class_identifier(s: Span) -> IResult<Span, PsClassIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn ps_covergroup_identifier(s: &str) -> IResult<&str, PsCovergroupIdentifier> { pub fn ps_covergroup_identifier(s: Span) -> IResult<Span, PsCovergroupIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn ps_checker_identifier(s: &str) -> IResult<&str, PsCheckerIdentifier> { pub fn ps_checker_identifier(s: Span) -> IResult<Span, PsCheckerIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn ps_identifier(s: &str) -> IResult<&str, PsIdentifier> { pub fn ps_identifier(s: Span) -> IResult<Span, PsIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn ps_or_hierarchical_array_identifier( pub fn ps_or_hierarchical_array_identifier(
s: &str, s: Span,
) -> IResult<&str, PsOrHierarchicalArrayIdentifier> { ) -> IResult<Span, PsOrHierarchicalArrayIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn ps_or_hierarchical_net_identifier(s: &str) -> IResult<&str, PsOrHierarchicalNetIdentifier> { pub fn ps_or_hierarchical_net_identifier(s: Span) -> IResult<Span, PsOrHierarchicalNetIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn ps_or_hierarchical_property_identifier( pub fn ps_or_hierarchical_property_identifier(
s: &str, s: Span,
) -> IResult<&str, PsOrHierarchicalPropertyIdentifier> { ) -> IResult<Span, PsOrHierarchicalPropertyIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn ps_or_hierarchical_sequence_identifier( pub fn ps_or_hierarchical_sequence_identifier(
s: &str, s: Span,
) -> IResult<&str, PsOrHierarchicalSequenceIdentifier> { ) -> IResult<Span, PsOrHierarchicalSequenceIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn ps_or_hierarchical_tf_identifier(s: &str) -> IResult<&str, PsOrHierarchicalTfIdentifier> { pub fn ps_or_hierarchical_tf_identifier(s: Span) -> IResult<Span, PsOrHierarchicalTfIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn ps_parameter_identifier(s: &str) -> IResult<&str, PsParameterIdentifier> { pub fn ps_parameter_identifier(s: Span) -> IResult<Span, PsParameterIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn ps_type_identifier(s: &str) -> IResult<&str, PsTypeIdentifier> { pub fn ps_type_identifier(s: Span) -> IResult<Span, PsTypeIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn sequence_identifier(s: &str) -> IResult<&str, SequenceIdentifier> { pub fn sequence_identifier(s: Span) -> IResult<Span, SequenceIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, SequenceIdentifier { nodes: (a,) })) Ok((s, SequenceIdentifier { nodes: (a,) }))
} }
pub fn signal_identifier(s: &str) -> IResult<&str, SignalIdentifier> { pub fn signal_identifier(s: Span) -> IResult<Span, SignalIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, SignalIdentifier { nodes: (a,) })) Ok((s, SignalIdentifier { nodes: (a,) }))
} }
pub fn simple_identifier(s: &str) -> IResult<&str, SimpleIdentifier> { pub fn simple_identifier(s: Span) -> IResult<Span, SimpleIdentifier> {
ws(simple_identifier_impl)(s) let (s, a) = ws(simple_identifier_impl)(s)?;
Ok((s, SimpleIdentifier { nodes: a }))
} }
pub fn simple_identifier_impl(s: &str) -> IResult<&str, SimpleIdentifier> { pub fn simple_identifier_impl(s: Span) -> IResult<Span, Span> {
let (s, a) = is_a(AZ_)(s)?; let (s, a) = is_a(AZ_)(s)?;
let (s, b) = opt(is_a(AZ09_DOLLAR))(s)?; let (s, b) = opt(is_a(AZ09_DOLLAR))(s)?;
let a = if let Some(b) = b { let a = if let Some(b) = b {
str_concat::concat(a, b).unwrap() concat(a, b).unwrap()
} else { } else {
a a
}; };
Ok((s, SimpleIdentifier { nodes: (a,) })) Ok((s, a))
} }
pub fn specparam_identifier(s: &str) -> IResult<&str, SpecparamIdentifier> { pub fn specparam_identifier(s: Span) -> IResult<Span, SpecparamIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, SpecparamIdentifier { nodes: (a,) })) Ok((s, SpecparamIdentifier { nodes: (a,) }))
} }
pub fn system_tf_identifier(s: &str) -> IResult<&str, SystemTfIdentifier> { pub fn system_tf_identifier(s: Span) -> IResult<Span, SystemTfIdentifier> {
ws(system_tf_identifier_impl)(s) let (s, a) = ws(system_tf_identifier_impl)(s)?;
Ok((s, SystemTfIdentifier { nodes: a }))
} }
pub fn system_tf_identifier_impl(s: &str) -> IResult<&str, SystemTfIdentifier> { pub fn system_tf_identifier_impl(s: Span) -> IResult<Span, Span> {
let (s, a) = tag("$")(s)?; let (s, a) = tag("$")(s)?;
let (s, b) = is_a(AZ09_DOLLAR)(s)?; let (s, b) = is_a(AZ09_DOLLAR)(s)?;
let a = str_concat::concat(a, b).unwrap(); let a = concat(a, b).unwrap();
Ok((s, SystemTfIdentifier { nodes: (a,) })) Ok((s, a))
} }
pub fn task_identifier(s: &str) -> IResult<&str, TaskIdentifier> { pub fn task_identifier(s: Span) -> IResult<Span, TaskIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, TaskIdentifier { nodes: (a,) })) Ok((s, TaskIdentifier { nodes: (a,) }))
} }
pub fn tf_identifier(s: &str) -> IResult<&str, TfIdentifier> { pub fn tf_identifier(s: Span) -> IResult<Span, TfIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, TfIdentifier { nodes: (a,) })) Ok((s, TfIdentifier { nodes: (a,) }))
} }
pub fn terminal_identifier(s: &str) -> IResult<&str, TerminalIdentifier> { pub fn terminal_identifier(s: Span) -> IResult<Span, TerminalIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, TerminalIdentifier { nodes: (a,) })) Ok((s, TerminalIdentifier { nodes: (a,) }))
} }
pub fn topmodule_identifier(s: &str) -> IResult<&str, TopmoduleIdentifier> { pub fn topmodule_identifier(s: Span) -> IResult<Span, TopmoduleIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, TopmoduleIdentifier { nodes: (a,) })) Ok((s, TopmoduleIdentifier { nodes: (a,) }))
} }
pub fn type_identifier(s: &str) -> IResult<&str, TypeIdentifier> { pub fn type_identifier(s: Span) -> IResult<Span, TypeIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, TypeIdentifier { nodes: (a,) })) Ok((s, TypeIdentifier { nodes: (a,) }))
} }
pub fn udp_identifier(s: &str) -> IResult<&str, UdpIdentifier> { pub fn udp_identifier(s: Span) -> IResult<Span, UdpIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, UdpIdentifier { nodes: (a,) })) Ok((s, UdpIdentifier { nodes: (a,) }))
} }
pub fn variable_identifier(s: &str) -> IResult<&str, VariableIdentifier> { pub fn variable_identifier(s: Span) -> IResult<Span, VariableIdentifier> {
let (s, a) = identifier(s)?; let (s, a) = identifier(s)?;
Ok((s, VariableIdentifier { nodes: (a,) })) Ok((s, VariableIdentifier { nodes: (a,) }))
} }
pub fn implicit_class_handle_or_class_scope_or_package_scope( pub fn implicit_class_handle_or_class_scope_or_package_scope(
s: &str, s: Span,
) -> IResult<&str, ImplicitClassHandleOrClassScopeOrPackageScope> { ) -> IResult<Span, ImplicitClassHandleOrClassScopeOrPackageScope> {
alt(( alt((
map(terminated(implicit_class_handle, symbol(".")), |x| { map(terminated(implicit_class_handle, symbol(".")), |x| {
ImplicitClassHandleOrClassScopeOrPackageScope::ImplicitClassHandle(x) ImplicitClassHandleOrClassScopeOrPackageScope::ImplicitClassHandle(x)
@ -968,8 +972,8 @@ pub fn implicit_class_handle_or_class_scope_or_package_scope(
} }
pub fn implicit_class_handle_or_package_scope( pub fn implicit_class_handle_or_package_scope(
s: &str, s: Span,
) -> IResult<&str, ImplicitClassHandleOrPackageScope> { ) -> IResult<Span, ImplicitClassHandleOrPackageScope> {
alt(( alt((
map(terminated(implicit_class_handle, symbol(".")), |x| { map(terminated(implicit_class_handle, symbol(".")), |x| {
ImplicitClassHandleOrPackageScope::ImplicitClassHandle(x) ImplicitClassHandleOrPackageScope::ImplicitClassHandle(x)
@ -981,8 +985,8 @@ pub fn implicit_class_handle_or_package_scope(
} }
pub fn implicit_class_handle_or_class_scope( pub fn implicit_class_handle_or_class_scope(
s: &str, s: Span,
) -> IResult<&str, ImplicitClassHandleOrClassScope> { ) -> IResult<Span, ImplicitClassHandleOrClassScope> {
alt(( alt((
map(terminated(implicit_class_handle, symbol(".")), |x| { map(terminated(implicit_class_handle, symbol(".")), |x| {
ImplicitClassHandleOrClassScope::ImplicitClassHandle(x) ImplicitClassHandleOrClassScope::ImplicitClassHandle(x)
@ -993,7 +997,7 @@ pub fn implicit_class_handle_or_class_scope(
))(s) ))(s)
} }
pub fn package_scope_or_class_scope(s: &str) -> IResult<&str, PackageScopeOrClassScope> { pub fn package_scope_or_class_scope(s: Span) -> IResult<Span, PackageScopeOrClassScope> {
alt(( alt((
map(package_scope, |x| PackageScopeOrClassScope::PackageScope(x)), map(package_scope, |x| PackageScopeOrClassScope::PackageScope(x)),
map(class_scope, |x| PackageScopeOrClassScope::ClassScope(x)), map(class_scope, |x| PackageScopeOrClassScope::ClassScope(x)),
@ -1009,28 +1013,31 @@ mod tests {
#[test] #[test]
fn test() { fn test() {
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(identifier)("shiftreg_a")), format!("{:?}", all_consuming(identifier)(Span::new("shiftreg_a"))),
"Ok((\"\", Identifier { raw: \"shiftreg_a\" }))" "Ok((LocatedSpanEx { offset: 10, line: 1, fragment: \"\", extra: () }, SimpleIdentifier(SimpleIdentifier { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"shiftreg_a\", extra: () }, []) })))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(identifier)("_bus3")), format!("{:?}", all_consuming(identifier)(Span::new("_bus3"))),
"Ok((\"\", Identifier { raw: \"_bus3\" }))" "Ok((LocatedSpanEx { offset: 5, line: 1, fragment: \"\", extra: () }, SimpleIdentifier(SimpleIdentifier { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"_bus3\", extra: () }, []) })))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(identifier)("n$657")), format!("{:?}", all_consuming(identifier)(Span::new("n$657"))),
"Ok((\"\", Identifier { raw: \"n$657\" }))" "Ok((LocatedSpanEx { offset: 5, line: 1, fragment: \"\", extra: () }, SimpleIdentifier(SimpleIdentifier { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"n$657\", extra: () }, []) })))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(identifier)("\\busa+index")), format!("{:?}", all_consuming(identifier)(Span::new("\\busa+index"))),
"Ok((\"\", Identifier { raw: \"\\\\busa+index\" }))" "Ok((LocatedSpanEx { offset: 11, line: 1, fragment: \"\", extra: () }, EscapedIdentifier(EscapedIdentifier { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"\\\\busa+index\", extra: () }, []) })))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(identifier)("\\-clock")), format!("{:?}", all_consuming(identifier)(Span::new("\\-clock"))),
"Ok((\"\", Identifier { raw: \"\\\\-clock\" }))" "Ok((LocatedSpanEx { offset: 7, line: 1, fragment: \"\", extra: () }, EscapedIdentifier(EscapedIdentifier { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"\\\\-clock\", extra: () }, []) })))"
); );
assert_eq!( assert_eq!(
format!("{:?}", all_consuming(system_tf_identifier)("$display")), format!(
"Ok((\"\", Identifier { raw: \"$display\" }))" "{:?}",
all_consuming(system_tf_identifier)(Span::new("$display"))
),
"Ok((LocatedSpanEx { offset: 8, line: 1, fragment: \"\", extra: () }, SystemTfIdentifier { nodes: (LocatedSpanEx { offset: 0, line: 1, fragment: \"$display\", extra: () }, []) }))"
); );
} }
} }

View File

@ -48,7 +48,7 @@ pub struct NamedCheckerPortConnectionAsterisk<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn checker_instantiation(s: &str) -> IResult<&str, CheckerInstantiation> { pub fn checker_instantiation(s: Span) -> IResult<Span, CheckerInstantiation> {
let (s, x) = ps_checker_identifier(s)?; let (s, x) = ps_checker_identifier(s)?;
let (s, y) = name_of_instance(s)?; let (s, y) = name_of_instance(s)?;
let (s, z) = paren(opt(list_of_checker_port_connections))(s)?; let (s, z) = paren(opt(list_of_checker_port_connections))(s)?;
@ -56,7 +56,7 @@ pub fn checker_instantiation(s: &str) -> IResult<&str, CheckerInstantiation> {
Ok((s, CheckerInstantiation { nodes: (x, y, z) })) Ok((s, CheckerInstantiation { nodes: (x, y, z) }))
} }
pub fn list_of_checker_port_connections(s: &str) -> IResult<&str, ListOfCheckerPortConnections> { pub fn list_of_checker_port_connections(s: Span) -> IResult<Span, ListOfCheckerPortConnections> {
alt(( alt((
map( map(
separated_nonempty_list(symbol(","), ordered_checker_port_connection), separated_nonempty_list(symbol(","), ordered_checker_port_connection),
@ -69,13 +69,13 @@ pub fn list_of_checker_port_connections(s: &str) -> IResult<&str, ListOfCheckerP
))(s) ))(s)
} }
pub fn ordered_checker_port_connection(s: &str) -> IResult<&str, OrderedCheckerPortConnection> { pub fn ordered_checker_port_connection(s: Span) -> IResult<Span, OrderedCheckerPortConnection> {
let (s, x) = many0(attribute_instance)(s)?; let (s, x) = many0(attribute_instance)(s)?;
let (s, y) = opt(property_actual_arg)(s)?; let (s, y) = opt(property_actual_arg)(s)?;
Ok((s, OrderedCheckerPortConnection { nodes: (x, y) })) Ok((s, OrderedCheckerPortConnection { nodes: (x, y) }))
} }
pub fn named_checker_port_connection(s: &str) -> IResult<&str, NamedCheckerPortConnection> { pub fn named_checker_port_connection(s: Span) -> IResult<Span, NamedCheckerPortConnection> {
alt(( alt((
named_checker_port_connection_identifier, named_checker_port_connection_identifier,
named_checker_port_connection_asterisk, named_checker_port_connection_asterisk,
@ -83,8 +83,8 @@ pub fn named_checker_port_connection(s: &str) -> IResult<&str, NamedCheckerPortC
} }
pub fn named_checker_port_connection_identifier( pub fn named_checker_port_connection_identifier(
s: &str, s: Span,
) -> IResult<&str, NamedCheckerPortConnection> { ) -> IResult<Span, NamedCheckerPortConnection> {
let (s, x) = many0(attribute_instance)(s)?; let (s, x) = many0(attribute_instance)(s)?;
let (s, _) = symbol(".")(s)?; let (s, _) = symbol(".")(s)?;
let (s, y) = formal_port_identifier(s)?; let (s, y) = formal_port_identifier(s)?;
@ -99,8 +99,8 @@ pub fn named_checker_port_connection_identifier(
} }
pub fn named_checker_port_connection_asterisk( pub fn named_checker_port_connection_asterisk(
s: &str, s: Span,
) -> IResult<&str, NamedCheckerPortConnection> { ) -> IResult<Span, NamedCheckerPortConnection> {
let (s, x) = many0(attribute_instance)(s)?; let (s, x) = many0(attribute_instance)(s)?;
let (s, _) = symbol(".")(s)?; let (s, _) = symbol(".")(s)?;
let (s, _) = symbol("*")(s)?; let (s, _) = symbol("*")(s)?;

View File

@ -39,17 +39,21 @@ pub enum GenvarIteration<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct GenvarIterationAssignment<'a> { pub struct GenvarIterationAssignment<'a> {
pub nodes: (GenvarIdentifier<'a>, Operator<'a>, ConstantExpression<'a>), pub nodes: (
GenvarIdentifier<'a>,
AssignmentOperator<'a>,
ConstantExpression<'a>,
),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct GenvarIterationPrefix<'a> { pub struct GenvarIterationPrefix<'a> {
pub nodes: (Operator<'a>, GenvarIdentifier<'a>), pub nodes: (IncOrDecOperator<'a>, GenvarIdentifier<'a>),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct GenvarIterationSuffix<'a> { pub struct GenvarIterationSuffix<'a> {
pub nodes: (GenvarIdentifier<'a>, Operator<'a>), pub nodes: (GenvarIdentifier<'a>, IncOrDecOperator<'a>),
} }
#[derive(Debug)] #[derive(Debug)]
@ -113,14 +117,14 @@ pub enum GenerateItem<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn generate_region(s: &str) -> IResult<&str, GenerateRegion> { pub fn generate_region(s: Span) -> IResult<Span, GenerateRegion> {
let (s, _) = symbol("generate")(s)?; let (s, _) = symbol("generate")(s)?;
let (s, x) = many0(generate_item)(s)?; let (s, x) = many0(generate_item)(s)?;
let (s, _) = symbol("endgenerate")(s)?; let (s, _) = symbol("endgenerate")(s)?;
Ok((s, GenerateRegion { nodes: (x,) })) Ok((s, GenerateRegion { nodes: (x,) }))
} }
pub fn loop_generate_construct(s: &str) -> IResult<&str, LoopGenerateConstruct> { pub fn loop_generate_construct(s: Span) -> IResult<Span, LoopGenerateConstruct> {
let (s, _) = symbol("for")(s)?; let (s, _) = symbol("for")(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = generate_initialization(s)?; let (s, x) = generate_initialization(s)?;
@ -138,7 +142,7 @@ pub fn loop_generate_construct(s: &str) -> IResult<&str, LoopGenerateConstruct>
)) ))
} }
pub fn generate_initialization(s: &str) -> IResult<&str, GenvarInitialization> { pub fn generate_initialization(s: Span) -> IResult<Span, GenvarInitialization> {
let (s, x) = opt(symbol("genvar"))(s)?; let (s, x) = opt(symbol("genvar"))(s)?;
let (s, y) = genvar_identifier(s)?; let (s, y) = genvar_identifier(s)?;
let (s, _) = symbol("=")(s)?; let (s, _) = symbol("=")(s)?;
@ -151,7 +155,7 @@ pub fn generate_initialization(s: &str) -> IResult<&str, GenvarInitialization> {
)) ))
} }
pub fn genvar_iteration(s: &str) -> IResult<&str, GenvarIteration> { pub fn genvar_iteration(s: Span) -> IResult<Span, GenvarIteration> {
alt(( alt((
genvar_iteration_assignment, genvar_iteration_assignment,
genvar_iteration_prefix, genvar_iteration_prefix,
@ -159,7 +163,7 @@ pub fn genvar_iteration(s: &str) -> IResult<&str, GenvarIteration> {
))(s) ))(s)
} }
pub fn genvar_iteration_assignment(s: &str) -> IResult<&str, GenvarIteration> { pub fn genvar_iteration_assignment(s: Span) -> IResult<Span, GenvarIteration> {
let (s, x) = genvar_identifier(s)?; let (s, x) = genvar_identifier(s)?;
let (s, y) = assignment_operator(s)?; let (s, y) = assignment_operator(s)?;
let (s, z) = genvar_expression(s)?; let (s, z) = genvar_expression(s)?;
@ -169,7 +173,7 @@ pub fn genvar_iteration_assignment(s: &str) -> IResult<&str, GenvarIteration> {
)) ))
} }
pub fn genvar_iteration_prefix(s: &str) -> IResult<&str, GenvarIteration> { pub fn genvar_iteration_prefix(s: Span) -> IResult<Span, GenvarIteration> {
let (s, x) = inc_or_dec_operator(s)?; let (s, x) = inc_or_dec_operator(s)?;
let (s, y) = genvar_identifier(s)?; let (s, y) = genvar_identifier(s)?;
Ok(( Ok((
@ -178,7 +182,7 @@ pub fn genvar_iteration_prefix(s: &str) -> IResult<&str, GenvarIteration> {
)) ))
} }
pub fn genvar_iteration_suffix(s: &str) -> IResult<&str, GenvarIteration> { pub fn genvar_iteration_suffix(s: Span) -> IResult<Span, GenvarIteration> {
let (s, x) = genvar_identifier(s)?; let (s, x) = genvar_identifier(s)?;
let (s, y) = inc_or_dec_operator(s)?; let (s, y) = inc_or_dec_operator(s)?;
Ok(( Ok((
@ -187,7 +191,7 @@ pub fn genvar_iteration_suffix(s: &str) -> IResult<&str, GenvarIteration> {
)) ))
} }
pub fn conditional_generate_construct(s: &str) -> IResult<&str, ConditionalGenerateConstruct> { pub fn conditional_generate_construct(s: Span) -> IResult<Span, ConditionalGenerateConstruct> {
alt(( alt((
map(if_generate_construct, |x| { map(if_generate_construct, |x| {
ConditionalGenerateConstruct::If(x) ConditionalGenerateConstruct::If(x)
@ -198,7 +202,7 @@ pub fn conditional_generate_construct(s: &str) -> IResult<&str, ConditionalGener
))(s) ))(s)
} }
pub fn if_generate_construct(s: &str) -> IResult<&str, IfGenerateConstruct> { pub fn if_generate_construct(s: Span) -> IResult<Span, IfGenerateConstruct> {
let (s, _) = symbol("if")(s)?; let (s, _) = symbol("if")(s)?;
let (s, x) = paren(constant_expression)(s)?; let (s, x) = paren(constant_expression)(s)?;
let (s, y) = generate_block(s)?; let (s, y) = generate_block(s)?;
@ -206,7 +210,7 @@ pub fn if_generate_construct(s: &str) -> IResult<&str, IfGenerateConstruct> {
Ok((s, IfGenerateConstruct { nodes: (x, y, z) })) Ok((s, IfGenerateConstruct { nodes: (x, y, z) }))
} }
pub fn case_generate_construct(s: &str) -> IResult<&str, CaseGenerateConstruct> { pub fn case_generate_construct(s: Span) -> IResult<Span, CaseGenerateConstruct> {
let (s, _) = symbol("case")(s)?; let (s, _) = symbol("case")(s)?;
let (s, x) = paren(constant_expression)(s)?; let (s, x) = paren(constant_expression)(s)?;
let (s, y) = many1(case_generate_item)(s)?; let (s, y) = many1(case_generate_item)(s)?;
@ -214,11 +218,11 @@ pub fn case_generate_construct(s: &str) -> IResult<&str, CaseGenerateConstruct>
Ok((s, CaseGenerateConstruct { nodes: (x, y) })) Ok((s, CaseGenerateConstruct { nodes: (x, y) }))
} }
pub fn case_generate_item(s: &str) -> IResult<&str, CaseGenerateItem> { pub fn case_generate_item(s: Span) -> IResult<Span, CaseGenerateItem> {
alt((case_generate_item_nondefault, case_generate_item_default))(s) alt((case_generate_item_nondefault, case_generate_item_default))(s)
} }
pub fn case_generate_item_nondefault(s: &str) -> IResult<&str, CaseGenerateItem> { pub fn case_generate_item_nondefault(s: Span) -> IResult<Span, CaseGenerateItem> {
let (s, x) = separated_nonempty_list(symbol(","), constant_expression)(s)?; let (s, x) = separated_nonempty_list(symbol(","), constant_expression)(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
let (s, y) = generate_block(s)?; let (s, y) = generate_block(s)?;
@ -228,7 +232,7 @@ pub fn case_generate_item_nondefault(s: &str) -> IResult<&str, CaseGenerateItem>
)) ))
} }
pub fn case_generate_item_default(s: &str) -> IResult<&str, CaseGenerateItem> { pub fn case_generate_item_default(s: Span) -> IResult<Span, CaseGenerateItem> {
let (s, _) = symbol("default")(s)?; let (s, _) = symbol("default")(s)?;
let (s, _) = opt(symbol(":"))(s)?; let (s, _) = opt(symbol(":"))(s)?;
let (s, x) = generate_block(s)?; let (s, x) = generate_block(s)?;
@ -238,16 +242,16 @@ pub fn case_generate_item_default(s: &str) -> IResult<&str, CaseGenerateItem> {
)) ))
} }
pub fn generate_block(s: &str) -> IResult<&str, GenerateBlock> { pub fn generate_block(s: Span) -> IResult<Span, GenerateBlock> {
alt((generate_block_single, generate_block_multiple))(s) alt((generate_block_single, generate_block_multiple))(s)
} }
pub fn generate_block_single(s: &str) -> IResult<&str, GenerateBlock> { pub fn generate_block_single(s: Span) -> IResult<Span, GenerateBlock> {
let (s, x) = generate_item(s)?; let (s, x) = generate_item(s)?;
Ok((s, GenerateBlock::Single(x))) Ok((s, GenerateBlock::Single(x)))
} }
pub fn generate_block_multiple(s: &str) -> IResult<&str, GenerateBlock> { pub fn generate_block_multiple(s: Span) -> IResult<Span, GenerateBlock> {
let (s, x) = opt(terminated(generate_block_identifier, symbol(":")))(s)?; let (s, x) = opt(terminated(generate_block_identifier, symbol(":")))(s)?;
let (s, _) = symbol("begin")(s)?; let (s, _) = symbol("begin")(s)?;
let (s, y) = opt(preceded(symbol(":"), generate_block_identifier))(s)?; let (s, y) = opt(preceded(symbol(":"), generate_block_identifier))(s)?;
@ -262,7 +266,7 @@ pub fn generate_block_multiple(s: &str) -> IResult<&str, GenerateBlock> {
)) ))
} }
pub fn generate_item(s: &str) -> IResult<&str, GenerateItem> { pub fn generate_item(s: Span) -> IResult<Span, GenerateItem> {
alt(( alt((
map(module_or_generate_item, |x| GenerateItem::Module(x)), map(module_or_generate_item, |x| GenerateItem::Module(x)),
map(interface_or_generate_item, |x| GenerateItem::Interface(x)), map(interface_or_generate_item, |x| GenerateItem::Interface(x)),

View File

@ -16,7 +16,7 @@ pub struct InterfaceInstantiation<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn interface_instantiation(s: &str) -> IResult<&str, InterfaceInstantiation> { pub fn interface_instantiation(s: Span) -> IResult<Span, InterfaceInstantiation> {
let (s, x) = interface_identifier(s)?; let (s, x) = interface_identifier(s)?;
let (s, y) = opt(parameter_value_assignment)(s)?; let (s, y) = opt(parameter_value_assignment)(s)?;
let (s, z) = separated_nonempty_list(symbol(","), hierarchical_instance)(s)?; let (s, z) = separated_nonempty_list(symbol(","), hierarchical_instance)(s)?;

View File

@ -79,7 +79,7 @@ pub struct NamedPortConnectionAsterisk<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn module_instantiation(s: &str) -> IResult<&str, ModuleInstantiation> { pub fn module_instantiation(s: Span) -> IResult<Span, ModuleInstantiation> {
let (s, x) = module_identifier(s)?; let (s, x) = module_identifier(s)?;
let (s, y) = opt(parameter_value_assignment)(s)?; let (s, y) = opt(parameter_value_assignment)(s)?;
let (s, z) = separated_nonempty_list(symbol(","), hierarchical_instance)(s)?; let (s, z) = separated_nonempty_list(symbol(","), hierarchical_instance)(s)?;
@ -87,13 +87,13 @@ pub fn module_instantiation(s: &str) -> IResult<&str, ModuleInstantiation> {
Ok((s, ModuleInstantiation { nodes: (x, y, z) })) Ok((s, ModuleInstantiation { nodes: (x, y, z) }))
} }
pub fn parameter_value_assignment(s: &str) -> IResult<&str, ParameterValueAssignment> { pub fn parameter_value_assignment(s: Span) -> IResult<Span, ParameterValueAssignment> {
let (s, _) = symbol("#")(s)?; let (s, _) = symbol("#")(s)?;
let (s, x) = paren(list_of_parameter_assignments)(s)?; let (s, x) = paren(list_of_parameter_assignments)(s)?;
Ok((s, ParameterValueAssignment { nodes: (x,) })) Ok((s, ParameterValueAssignment { nodes: (x,) }))
} }
pub fn list_of_parameter_assignments(s: &str) -> IResult<&str, ListOfParameterAssignments> { pub fn list_of_parameter_assignments(s: Span) -> IResult<Span, ListOfParameterAssignments> {
alt(( alt((
map( map(
separated_nonempty_list(symbol(","), ordered_parameter_assignment), separated_nonempty_list(symbol(","), ordered_parameter_assignment),
@ -106,31 +106,31 @@ pub fn list_of_parameter_assignments(s: &str) -> IResult<&str, ListOfParameterAs
))(s) ))(s)
} }
pub fn ordered_parameter_assignment(s: &str) -> IResult<&str, OrderedParameterAssignment> { pub fn ordered_parameter_assignment(s: Span) -> IResult<Span, OrderedParameterAssignment> {
let (s, x) = param_expression(s)?; let (s, x) = param_expression(s)?;
Ok((s, OrderedParameterAssignment { nodes: (x,) })) Ok((s, OrderedParameterAssignment { nodes: (x,) }))
} }
pub fn named_parameter_assignment(s: &str) -> IResult<&str, NamedParameterAssignment> { pub fn named_parameter_assignment(s: Span) -> IResult<Span, NamedParameterAssignment> {
let (s, _) = symbol(".")(s)?; let (s, _) = symbol(".")(s)?;
let (s, x) = parameter_identifier(s)?; let (s, x) = parameter_identifier(s)?;
let (s, y) = paren(opt(param_expression))(s)?; let (s, y) = paren(opt(param_expression))(s)?;
Ok((s, NamedParameterAssignment { nodes: (x, y) })) Ok((s, NamedParameterAssignment { nodes: (x, y) }))
} }
pub fn hierarchical_instance(s: &str) -> IResult<&str, HierarchicalInstance> { pub fn hierarchical_instance(s: Span) -> IResult<Span, HierarchicalInstance> {
let (s, x) = name_of_instance(s)?; let (s, x) = name_of_instance(s)?;
let (s, y) = paren(opt(list_of_port_connections))(s)?; let (s, y) = paren(opt(list_of_port_connections))(s)?;
Ok((s, HierarchicalInstance { nodes: (x, y) })) Ok((s, HierarchicalInstance { nodes: (x, y) }))
} }
pub fn name_of_instance(s: &str) -> IResult<&str, NameOfInstance> { pub fn name_of_instance(s: Span) -> IResult<Span, NameOfInstance> {
let (s, x) = instance_identifier(s)?; let (s, x) = instance_identifier(s)?;
let (s, y) = many0(unpacked_dimension)(s)?; let (s, y) = many0(unpacked_dimension)(s)?;
Ok((s, NameOfInstance { nodes: (x, y) })) Ok((s, NameOfInstance { nodes: (x, y) }))
} }
pub fn list_of_port_connections(s: &str) -> IResult<&str, ListOfPortConnections> { pub fn list_of_port_connections(s: Span) -> IResult<Span, ListOfPortConnections> {
alt(( alt((
map( map(
separated_nonempty_list(symbol(","), ordered_port_connection), separated_nonempty_list(symbol(","), ordered_port_connection),
@ -143,20 +143,20 @@ pub fn list_of_port_connections(s: &str) -> IResult<&str, ListOfPortConnections>
))(s) ))(s)
} }
pub fn ordered_port_connection(s: &str) -> IResult<&str, OrderedPortConnection> { pub fn ordered_port_connection(s: Span) -> IResult<Span, OrderedPortConnection> {
let (s, x) = many0(attribute_instance)(s)?; let (s, x) = many0(attribute_instance)(s)?;
let (s, y) = opt(expression)(s)?; let (s, y) = opt(expression)(s)?;
Ok((s, OrderedPortConnection { nodes: (x, y) })) Ok((s, OrderedPortConnection { nodes: (x, y) }))
} }
pub fn named_port_connection(s: &str) -> IResult<&str, NamedPortConnection> { pub fn named_port_connection(s: Span) -> IResult<Span, NamedPortConnection> {
alt(( alt((
named_port_connection_identifier, named_port_connection_identifier,
named_port_connection_asterisk, named_port_connection_asterisk,
))(s) ))(s)
} }
pub fn named_port_connection_identifier(s: &str) -> IResult<&str, NamedPortConnection> { pub fn named_port_connection_identifier(s: Span) -> IResult<Span, NamedPortConnection> {
let (s, x) = many0(attribute_instance)(s)?; let (s, x) = many0(attribute_instance)(s)?;
let (s, _) = symbol(".")(s)?; let (s, _) = symbol(".")(s)?;
let (s, y) = port_identifier(s)?; let (s, y) = port_identifier(s)?;
@ -168,7 +168,7 @@ pub fn named_port_connection_identifier(s: &str) -> IResult<&str, NamedPortConne
)) ))
} }
pub fn named_port_connection_asterisk(s: &str) -> IResult<&str, NamedPortConnection> { pub fn named_port_connection_asterisk(s: Span) -> IResult<Span, NamedPortConnection> {
let (s, x) = many0(attribute_instance)(s)?; let (s, x) = many0(attribute_instance)(s)?;
let (s, _) = symbol(".")(s)?; let (s, _) = symbol(".")(s)?;
let (s, _) = symbol("*")(s)?; let (s, _) = symbol("*")(s)?;

View File

@ -16,7 +16,7 @@ pub struct ProgramInstantiation<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn program_instantiation(s: &str) -> IResult<&str, ProgramInstantiation> { pub fn program_instantiation(s: Span) -> IResult<Span, ProgramInstantiation> {
let (s, x) = program_identifier(s)?; let (s, x) = program_identifier(s)?;
let (s, y) = opt(parameter_value_assignment)(s)?; let (s, y) = opt(parameter_value_assignment)(s)?;
let (s, z) = separated_nonempty_list(symbol(","), hierarchical_instance)(s)?; let (s, z) = separated_nonempty_list(symbol(","), hierarchical_instance)(s)?;

View File

@ -13,6 +13,6 @@ pub struct GateInstantiation<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn gate_instantiation(s: &str) -> IResult<&str, GateInstantiation> { pub fn gate_instantiation(s: Span) -> IResult<Span, GateInstantiation> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -82,28 +82,28 @@ pub enum CheckerGenerateItem<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn checker_port_list(s: &str) -> IResult<&str, CheckerPortList> { pub fn checker_port_list(s: Span) -> IResult<Span, CheckerPortList> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn checker_port_item(s: &str) -> IResult<&str, CheckerPortItem> { pub fn checker_port_item(s: Span) -> IResult<Span, CheckerPortItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn checker_port_direction(s: &str) -> IResult<&str, CheckerPortDirection> { pub fn checker_port_direction(s: Span) -> IResult<Span, CheckerPortDirection> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn checker_or_generate_item(s: &str) -> IResult<&str, CheckerOrGenerateItem> { pub fn checker_or_generate_item(s: Span) -> IResult<Span, CheckerOrGenerateItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn checker_or_generate_item_declaration( pub fn checker_or_generate_item_declaration(
s: &str, s: Span,
) -> IResult<&str, CheckerOrGenerateItemDeclaration> { ) -> IResult<Span, CheckerOrGenerateItemDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn checker_generate_item(s: &str) -> IResult<&str, CheckerGenerateItem> { pub fn checker_generate_item(s: Span) -> IResult<Span, CheckerGenerateItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -164,42 +164,42 @@ pub struct New {}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn class_item(s: &str) -> IResult<&str, ClassItem> { pub fn class_item(s: Span) -> IResult<Span, ClassItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn class_property(s: &str) -> IResult<&str, ClassProperty> { pub fn class_property(s: Span) -> IResult<Span, ClassProperty> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn class_method(s: &str) -> IResult<&str, ClassMethod> { pub fn class_method(s: Span) -> IResult<Span, ClassMethod> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn class_constructor_prototype(s: &str) -> IResult<&str, ClassConstructorPrototype> { pub fn class_constructor_prototype(s: Span) -> IResult<Span, ClassConstructorPrototype> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn class_constraint(s: &str) -> IResult<&str, ClassConstraint> { pub fn class_constraint(s: Span) -> IResult<Span, ClassConstraint> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn class_item_qualifier(s: &str) -> IResult<&str, ClassItemQualifier> { pub fn class_item_qualifier(s: Span) -> IResult<Span, ClassItemQualifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn property_qualifier(s: &str) -> IResult<&str, PropertyQualifier> { pub fn property_qualifier(s: Span) -> IResult<Span, PropertyQualifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn random_qualifier(s: &str) -> IResult<&str, RandomQualifier> { pub fn random_qualifier(s: Span) -> IResult<Span, RandomQualifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn method_qualifier(s: &str) -> IResult<&str, MethodQualifier> { pub fn method_qualifier(s: Span) -> IResult<Span, MethodQualifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn class_constructor_declaration(s: &str) -> IResult<&str, ClassConstructorDeclaration> { pub fn class_constructor_declaration(s: Span) -> IResult<Span, ClassConstructorDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -115,38 +115,38 @@ pub struct Config {}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn config_declaration(s: &str) -> IResult<&str, ConfigDeclaration> { pub fn config_declaration(s: Span) -> IResult<Span, ConfigDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn design_statement(s: &str) -> IResult<&str, DesignStatement> { pub fn design_statement(s: Span) -> IResult<Span, DesignStatement> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn config_rule_statement(s: &str) -> IResult<&str, ConfigRuleStatement> { pub fn config_rule_statement(s: Span) -> IResult<Span, ConfigRuleStatement> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn default_clause(s: &str) -> IResult<&str, DefaultClause> { pub fn default_clause(s: Span) -> IResult<Span, DefaultClause> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn inst_clause(s: &str) -> IResult<&str, InstClause> { pub fn inst_clause(s: Span) -> IResult<Span, InstClause> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn inst_name(s: &str) -> IResult<&str, InstName> { pub fn inst_name(s: Span) -> IResult<Span, InstName> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn cell_clause(s: &str) -> IResult<&str, CellClause> { pub fn cell_clause(s: Span) -> IResult<Span, CellClause> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn liblist_clause(s: &str) -> IResult<&str, LiblistClause> { pub fn liblist_clause(s: Span) -> IResult<Span, LiblistClause> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn use_clause(s: &str) -> IResult<&str, UseClause> { pub fn use_clause(s: Span) -> IResult<Span, UseClause> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -164,62 +164,62 @@ pub struct IdentifierList<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn constraint_declaration(s: &str) -> IResult<&str, ConstraintDeclaration> { pub fn constraint_declaration(s: Span) -> IResult<Span, ConstraintDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn constraint_block(s: &str) -> IResult<&str, ConstraintBlock> { pub fn constraint_block(s: Span) -> IResult<Span, ConstraintBlock> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn constraint_block_item(s: &str) -> IResult<&str, ConstraintBlockItem> { pub fn constraint_block_item(s: Span) -> IResult<Span, ConstraintBlockItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn solve_before_list(s: &str) -> IResult<&str, SolveBeforeList> { pub fn solve_before_list(s: Span) -> IResult<Span, SolveBeforeList> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn constraint_primary(s: &str) -> IResult<&str, ConstraintPrimary> { pub fn constraint_primary(s: Span) -> IResult<Span, ConstraintPrimary> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn constraint_expression(s: &str) -> IResult<&str, ConstraintExpression> { pub fn constraint_expression(s: Span) -> IResult<Span, ConstraintExpression> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn uniqueness_constraint(s: &str) -> IResult<&str, UniquenessConstraint> { pub fn uniqueness_constraint(s: Span) -> IResult<Span, UniquenessConstraint> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn constraint_set(s: &str) -> IResult<&str, ConstraintSet> { pub fn constraint_set(s: Span) -> IResult<Span, ConstraintSet> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn dist_list(s: &str) -> IResult<&str, DistList> { pub fn dist_list(s: Span) -> IResult<Span, DistList> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn dist_item(s: &str) -> IResult<&str, DistItem> { pub fn dist_item(s: Span) -> IResult<Span, DistItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn dist_weight(s: &str) -> IResult<&str, DistWeight> { pub fn dist_weight(s: Span) -> IResult<Span, DistWeight> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn constraint_prototype(s: &str) -> IResult<&str, ConstraintPrototype> { pub fn constraint_prototype(s: Span) -> IResult<Span, ConstraintPrototype> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn constraint_prototype_qualifier(s: &str) -> IResult<&str, ConstraintPrototypeQualifier> { pub fn constraint_prototype_qualifier(s: Span) -> IResult<Span, ConstraintPrototypeQualifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn extern_constraint_declaration(s: &str) -> IResult<&str, ExternConstraintDeclaration> { pub fn extern_constraint_declaration(s: Span) -> IResult<Span, ExternConstraintDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn identifier_list(s: &str) -> IResult<&str, IdentifierList> { pub fn identifier_list(s: Span) -> IResult<Span, IdentifierList> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -56,18 +56,18 @@ pub enum NonPortInterfaceItem<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn interface_or_generate_item(s: &str) -> IResult<&str, InterfaceOrGenerateItem> { pub fn interface_or_generate_item(s: Span) -> IResult<Span, InterfaceOrGenerateItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn extern_tf_declaration(s: &str) -> IResult<&str, ExternTfDeclaration> { pub fn extern_tf_declaration(s: Span) -> IResult<Span, ExternTfDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn interface_item(s: &str) -> IResult<&str, InterfaceItem> { pub fn interface_item(s: Span) -> IResult<Span, InterfaceItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn non_port_interface_item(s: &str) -> IResult<&str, NonPortInterfaceItem> { pub fn non_port_interface_item(s: Span) -> IResult<Span, NonPortInterfaceItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -34,23 +34,23 @@ pub struct IncludeStatement<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct FilePathSpec<'a> { pub struct FilePathSpec<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>,),
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn library_text(s: &str) -> IResult<&str, LibraryText> { pub fn library_text(s: Span) -> IResult<Span, LibraryText> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn library_description(s: &str) -> IResult<&str, LibraryDescription> { pub fn library_description(s: Span) -> IResult<Span, LibraryDescription> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn library_declaration(s: &str) -> IResult<&str, LibraryDeclaration> { pub fn library_declaration(s: Span) -> IResult<Span, LibraryDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn include_statement(s: &str) -> IResult<&str, IncludeStatement> { pub fn include_statement(s: Span) -> IResult<Span, IncludeStatement> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -185,56 +185,56 @@ pub enum BindInstantiation<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn elaboration_system_task(s: &str) -> IResult<&str, ElaborationSystemTask> { pub fn elaboration_system_task(s: Span) -> IResult<Span, ElaborationSystemTask> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn finish_number(s: &str) -> IResult<&str, FinishNumber> { pub fn finish_number(s: Span) -> IResult<Span, FinishNumber> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn module_common_item(s: &str) -> IResult<&str, ModuleCommonItem> { pub fn module_common_item(s: Span) -> IResult<Span, ModuleCommonItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn module_item(s: &str) -> IResult<&str, ModuleItem> { pub fn module_item(s: Span) -> IResult<Span, ModuleItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn module_or_generate_item(s: &str) -> IResult<&str, ModuleOrGenerateItem> { pub fn module_or_generate_item(s: Span) -> IResult<Span, ModuleOrGenerateItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn module_or_generate_item_declaration( pub fn module_or_generate_item_declaration(
s: &str, s: Span,
) -> IResult<&str, ModuleOrGenerateItemDeclaration> { ) -> IResult<Span, ModuleOrGenerateItemDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn non_port_module_item(s: &str) -> IResult<&str, NonPortModuleItem> { pub fn non_port_module_item(s: Span) -> IResult<Span, NonPortModuleItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn parameter_override(s: &str) -> IResult<&str, ParameterOverride> { pub fn parameter_override(s: Span) -> IResult<Span, ParameterOverride> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn bind_directive(s: &str) -> IResult<&str, BindDirective> { pub fn bind_directive(s: Span) -> IResult<Span, BindDirective> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn bind_target_scope(s: &str) -> IResult<&str, BindTargetScope> { pub fn bind_target_scope(s: Span) -> IResult<Span, BindTargetScope> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn bind_target_instance(s: &str) -> IResult<&str, BindTargetInstance> { pub fn bind_target_instance(s: Span) -> IResult<Span, BindTargetInstance> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn bind_target_instance_list(s: &str) -> IResult<&str, BindTargetInstanceList> { pub fn bind_target_instance_list(s: Span) -> IResult<Span, BindTargetInstanceList> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn bind_instantiation(s: &str) -> IResult<&str, BindInstantiation> { pub fn bind_instantiation(s: Span) -> IResult<Span, BindInstantiation> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -197,54 +197,54 @@ pub struct AnsiPortDeclarationParen<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn parameter_port_list(s: &str) -> IResult<&str, ParameterPortList> { pub fn parameter_port_list(s: Span) -> IResult<Span, ParameterPortList> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn parameter_port_declaration(s: &str) -> IResult<&str, ParameterPortDeclaration> { pub fn parameter_port_declaration(s: Span) -> IResult<Span, ParameterPortDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_ports(s: &str) -> IResult<&str, ListOfPorts> { pub fn list_of_ports(s: Span) -> IResult<Span, ListOfPorts> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn list_of_port_declarations(s: &str) -> IResult<&str, ListOfPortDeclarations> { pub fn list_of_port_declarations(s: Span) -> IResult<Span, ListOfPortDeclarations> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn port_declaration(s: &str) -> IResult<&str, PortDeclaration> { pub fn port_declaration(s: Span) -> IResult<Span, PortDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn port(s: &str) -> IResult<&str, Port> { pub fn port(s: Span) -> IResult<Span, Port> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn port_expression(s: &str) -> IResult<&str, PortExpression> { pub fn port_expression(s: Span) -> IResult<Span, PortExpression> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn port_reference(s: &str) -> IResult<&str, PortReference> { pub fn port_reference(s: Span) -> IResult<Span, PortReference> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn port_direction(s: &str) -> IResult<&str, PortDirection> { pub fn port_direction(s: Span) -> IResult<Span, PortDirection> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn net_port_header(s: &str) -> IResult<&str, NetPortHeader> { pub fn net_port_header(s: Span) -> IResult<Span, NetPortHeader> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn variable_port_header(s: &str) -> IResult<&str, VariablePortHeader> { pub fn variable_port_header(s: Span) -> IResult<Span, VariablePortHeader> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn interface_port_header(s: &str) -> IResult<&str, InterfacePortHeader> { pub fn interface_port_header(s: Span) -> IResult<Span, InterfacePortHeader> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn ansi_port_declaration(s: &str) -> IResult<&str, AnsiPortDeclaration> { pub fn ansi_port_declaration(s: Span) -> IResult<Span, AnsiPortDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -49,20 +49,20 @@ pub enum AnonymousProgramItem<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn package_item(s: &str) -> IResult<&str, PackageItem> { pub fn package_item(s: Span) -> IResult<Span, PackageItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn package_or_generate_item_declaration( pub fn package_or_generate_item_declaration(
s: &str, s: Span,
) -> IResult<&str, PackageOrGenerateItemDeclaration> { ) -> IResult<Span, PackageOrGenerateItemDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn anonymous_program(s: &str) -> IResult<&str, AnonymousProgram> { pub fn anonymous_program(s: Span) -> IResult<Span, AnonymousProgram> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn anonymous_program_item(s: &str) -> IResult<&str, AnonymousProgramItem> { pub fn anonymous_program_item(s: Span) -> IResult<Span, AnonymousProgramItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -61,14 +61,14 @@ pub enum ProgramGenerateItem<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn program_item(s: &str) -> IResult<&str, ProgramItem> { pub fn program_item(s: Span) -> IResult<Span, ProgramItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn non_port_program_item(s: &str) -> IResult<&str, NonPortProgramItem> { pub fn non_port_program_item(s: Span) -> IResult<Span, NonPortProgramItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn program_generate_item(s: &str) -> IResult<&str, ProgramGenerateItem> { pub fn program_generate_item(s: Span) -> IResult<Span, ProgramGenerateItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -369,82 +369,82 @@ pub struct TimeunitsDeclarationTimeprecisionTimeunit<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn source_text(s: &str) -> IResult<&str, SourceText> { pub fn source_text(s: Span) -> IResult<Span, SourceText> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn description(s: &str) -> IResult<&str, Description> { pub fn description(s: Span) -> IResult<Span, Description> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn module_nonansi_header(s: &str) -> IResult<&str, ModuleNonansiHeader> { pub fn module_nonansi_header(s: Span) -> IResult<Span, ModuleNonansiHeader> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn module_ansi_header(s: &str) -> IResult<&str, ModuleAnsiHeader> { pub fn module_ansi_header(s: Span) -> IResult<Span, ModuleAnsiHeader> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn module_declaration(s: &str) -> IResult<&str, ModuleDeclaration> { pub fn module_declaration(s: Span) -> IResult<Span, ModuleDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn module_keyword(s: &str) -> IResult<&str, ModuleKeyword> { pub fn module_keyword(s: Span) -> IResult<Span, ModuleKeyword> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn interface_declaration(s: &str) -> IResult<&str, InterfaceDeclaration> { pub fn interface_declaration(s: Span) -> IResult<Span, InterfaceDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn interface_nonansi_header(s: &str) -> IResult<&str, InterfaceNonansiHeader> { pub fn interface_nonansi_header(s: Span) -> IResult<Span, InterfaceNonansiHeader> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn interface_ansi_header(s: &str) -> IResult<&str, InterfaceAnsiHeader> { pub fn interface_ansi_header(s: Span) -> IResult<Span, InterfaceAnsiHeader> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn program_declaration(s: &str) -> IResult<&str, ProgramDeclaration> { pub fn program_declaration(s: Span) -> IResult<Span, ProgramDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn program_nonansi_header(s: &str) -> IResult<&str, ProgramNonansiHeader> { pub fn program_nonansi_header(s: Span) -> IResult<Span, ProgramNonansiHeader> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn program_ansi_header(s: &str) -> IResult<&str, ProgramAnsiHeader> { pub fn program_ansi_header(s: Span) -> IResult<Span, ProgramAnsiHeader> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn checker_declaration(s: &str) -> IResult<&str, CheckerDeclaration> { pub fn checker_declaration(s: Span) -> IResult<Span, CheckerDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn class_declaration(s: &str) -> IResult<&str, ClassDeclaration> { pub fn class_declaration(s: Span) -> IResult<Span, ClassDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn interface_class_type(s: &str) -> IResult<&str, InterfaceClassType> { pub fn interface_class_type(s: Span) -> IResult<Span, InterfaceClassType> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn interface_class_declaration(s: &str) -> IResult<&str, InterfaceClassDeclaration> { pub fn interface_class_declaration(s: Span) -> IResult<Span, InterfaceClassDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn interface_class_item(s: &str) -> IResult<&str, InterfaceClassItem> { pub fn interface_class_item(s: Span) -> IResult<Span, InterfaceClassItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn interface_class_method(s: &str) -> IResult<&str, InterfaceClassMethod> { pub fn interface_class_method(s: Span) -> IResult<Span, InterfaceClassMethod> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn package_declaration(s: &str) -> IResult<&str, PackageDeclaration> { pub fn package_declaration(s: Span) -> IResult<Span, PackageDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn timeunit_declaration(s: &str) -> IResult<&str, TimeunitsDeclaration> { pub fn timeunit_declaration(s: Span) -> IResult<Span, TimeunitsDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -13,6 +13,6 @@ pub struct SpecifyBlock<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn specify_block(s: &str) -> IResult<&str, SpecifyBlock> { pub fn specify_block(s: Span) -> IResult<Span, SpecifyBlock> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -42,20 +42,20 @@ pub struct OutputIdentifierInterface<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn specify_input_terminal_descriptor(s: &str) -> IResult<&str, SpecifyInputTerminalDescriptor> { pub fn specify_input_terminal_descriptor(s: Span) -> IResult<Span, SpecifyInputTerminalDescriptor> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn specify_output_terminal_descriptor( pub fn specify_output_terminal_descriptor(
s: &str, s: Span,
) -> IResult<&str, SpecifyOutputTerminalDescriptor> { ) -> IResult<Span, SpecifyOutputTerminalDescriptor> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn input_identifier(s: &str) -> IResult<&str, InputIdentifier> { pub fn input_identifier(s: Span) -> IResult<Span, InputIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }
pub fn output_identifier(s: &str) -> IResult<&str, OutputIdentifier> { pub fn output_identifier(s: Span) -> IResult<Span, OutputIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -13,6 +13,6 @@ pub struct EdgeIdentifier<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn edge_identifier(s: &str) -> IResult<&str, EdgeIdentifier> { pub fn edge_identifier(s: Span) -> IResult<Span, EdgeIdentifier> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -13,6 +13,6 @@ pub struct UdpDeclaration<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn udp_declaration(s: &str) -> IResult<&str, UdpDeclaration> { pub fn udp_declaration(s: Span) -> IResult<Span, UdpDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -13,6 +13,6 @@ pub struct UdpInstantiation<'a> {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn udp_instantiation(s: &str) -> IResult<&str, UdpInstantiation> { pub fn udp_instantiation(s: Span) -> IResult<Span, UdpInstantiation> {
Err(Err::Error(make_error(s, ErrorKind::Fix))) Err(Err::Error(make_error(s, ErrorKind::Fix)))
} }

View File

@ -1,39 +1,46 @@
use crate::parser::*; use crate::parser::*;
use nom::branch::*;
use nom::bytes::complete::*; use nom::bytes::complete::*;
use nom::character::complete::*; use nom::character::complete::*;
use nom::combinator::*; use nom::combinator::*;
use nom::multi::*;
use nom::IResult; use nom::IResult;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#[derive(Debug)] #[derive(Debug)]
pub struct Symbol<'a> { pub struct Symbol<'a> {
pub nodes: (&'a str,), pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
}
#[derive(Debug)]
pub enum WhiteSpace<'a> {
Space(Span<'a>),
Comment(Comment<'a>),
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn ws<'a, O, F>(f: F) -> impl Fn(&'a str) -> IResult<&'a str, O> pub fn ws<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, (O, Vec<WhiteSpace<'a>>)>
where where
F: Fn(&'a str) -> IResult<&'a str, O>, F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
{ {
move |s: &'a str| { move |s: Span<'a>| {
let (s, _) = space0(s)?;
let (s, x) = f(s)?; let (s, x) = f(s)?;
let (s, _) = space0(s)?; let (s, y) = many0(white_space)(s)?;
Ok((s, x)) Ok((s, (x, y)))
} }
} }
pub fn symbol<'a>(t: &'a str) -> impl Fn(&'a str) -> IResult<&'a str, Symbol<'a>> { pub fn symbol<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult<Span<'a>, Symbol<'a>> {
move |s: &'a str| ws(map(tag(t.clone()), |x| Symbol { nodes: (x,) }))(s) move |s: Span<'a>| map(ws(tag(t.clone())), |x| Symbol { nodes: x })(s)
} }
pub fn paren<'a, O, F>(f: F) -> impl Fn(&'a str) -> IResult<&'a str, O> pub fn paren<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, O>
where where
F: Fn(&'a str) -> IResult<&'a str, O>, F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
{ {
move |s: &'a str| { move |s: Span<'a>| {
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, x) = f(s)?; let (s, x) = f(s)?;
let (s, _) = symbol(")")(s)?; let (s, _) = symbol(")")(s)?;
@ -41,11 +48,11 @@ where
} }
} }
pub fn bracket<'a, O, F>(f: F) -> impl Fn(&'a str) -> IResult<&'a str, O> pub fn bracket<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, O>
where where
F: Fn(&'a str) -> IResult<&'a str, O>, F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
{ {
move |s: &'a str| { move |s: Span<'a>| {
let (s, _) = symbol("[")(s)?; let (s, _) = symbol("[")(s)?;
let (s, x) = f(s)?; let (s, x) = f(s)?;
let (s, _) = symbol("]")(s)?; let (s, _) = symbol("]")(s)?;
@ -53,11 +60,11 @@ where
} }
} }
pub fn brace<'a, O, F>(f: F) -> impl Fn(&'a str) -> IResult<&'a str, O> pub fn brace<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, O>
where where
F: Fn(&'a str) -> IResult<&'a str, O>, F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
{ {
move |s: &'a str| { move |s: Span<'a>| {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, x) = f(s)?; let (s, x) = f(s)?;
let (s, _) = symbol("}")(s)?; let (s, _) = symbol("}")(s)?;
@ -65,11 +72,11 @@ where
} }
} }
pub fn apostrophe_brace<'a, O, F>(f: F) -> impl Fn(&'a str) -> IResult<&'a str, O> pub fn apostrophe_brace<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, O>
where where
F: Fn(&'a str) -> IResult<&'a str, O>, F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
{ {
move |s: &'a str| { move |s: Span<'a>| {
let (s, _) = symbol("'{")(s)?; let (s, _) = symbol("'{")(s)?;
let (s, x) = f(s)?; let (s, x) = f(s)?;
let (s, _) = symbol("}")(s)?; let (s, _) = symbol("}")(s)?;
@ -78,3 +85,28 @@ where
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
pub fn white_space(s: Span) -> IResult<Span, WhiteSpace> {
alt((
map(multispace1, |x| WhiteSpace::Space(x)),
map(comment, |x| WhiteSpace::Comment(x)),
))(s)
}
// -----------------------------------------------------------------------------
pub fn concat<'a>(a: Span<'a>, b: Span<'a>) -> Option<Span<'a>> {
let c = str_concat::concat(a.fragment, b.fragment);
if let Ok(c) = c {
Some(Span {
offset: a.offset,
line: a.line,
fragment: c,
extra: a.extra,
})
} else {
None
}
}
// -----------------------------------------------------------------------------