Add ambiguous_alt / keyword

This commit is contained in:
dalance 2019-07-19 16:09:45 +09:00
parent 4a2cc5416c
commit d25b5ad733
52 changed files with 1137 additions and 622 deletions

View File

@ -76,8 +76,3 @@ A parser library for System Verilog.
| general | attributes | x | x | x |
| general | comments | x | x | x |
| general | identifiers | x | x | x |
## TODO
* Exclude reserved keyword from identifiers.
* Implement ambiguous_alt for varirble_port_type.

View File

@ -164,7 +164,7 @@ pub fn simple_immediate_assertion_statement(
#[parser]
pub fn simple_immediate_assert_statement(s: Span) -> IResult<Span, SimpleImmediateAssertStatement> {
let (s, a) = symbol("assert")(s)?;
let (s, a) = keyword("assert")(s)?;
let (s, b) = paren(expression)(s)?;
let (s, c) = action_block(s)?;
Ok((s, SimpleImmediateAssertStatement { nodes: (a, b, c) }))
@ -172,7 +172,7 @@ pub fn simple_immediate_assert_statement(s: Span) -> IResult<Span, SimpleImmedia
#[parser]
pub fn simple_immediate_assume_statement(s: Span) -> IResult<Span, SimpleImmediateAssumeStatement> {
let (s, a) = symbol("assume")(s)?;
let (s, a) = keyword("assume")(s)?;
let (s, b) = paren(expression)(s)?;
let (s, c) = action_block(s)?;
Ok((s, SimpleImmediateAssumeStatement { nodes: (a, b, c) }))
@ -180,7 +180,7 @@ pub fn simple_immediate_assume_statement(s: Span) -> IResult<Span, SimpleImmedia
#[parser]
pub fn simple_immediate_cover_statement(s: Span) -> IResult<Span, SimpleImmediateCoverStatement> {
let (s, a) = symbol("cover")(s)?;
let (s, a) = keyword("cover")(s)?;
let (s, b) = paren(expression)(s)?;
let (s, c) = statement_or_null(s)?;
Ok((s, SimpleImmediateCoverStatement { nodes: (a, b, c) }))
@ -207,7 +207,7 @@ pub fn deferred_immediate_assertion_statement(
pub fn deferred_immediate_assert_statement(
s: Span,
) -> IResult<Span, DeferredImmediateAssertStatement> {
let (s, a) = symbol("assert")(s)?;
let (s, a) = keyword("assert")(s)?;
let (s, b) = assert_timing(s)?;
let (s, c) = paren(expression)(s)?;
let (s, d) = action_block(s)?;
@ -223,7 +223,7 @@ pub fn deferred_immediate_assert_statement(
pub fn deferred_immediate_assume_statement(
s: Span,
) -> IResult<Span, DeferredImmediateAssumeStatement> {
let (s, a) = symbol("assume")(s)?;
let (s, a) = keyword("assume")(s)?;
let (s, b) = assert_timing(s)?;
let (s, c) = paren(expression)(s)?;
let (s, d) = action_block(s)?;
@ -239,7 +239,7 @@ pub fn deferred_immediate_assume_statement(
pub fn deferred_immediate_cover_statement(
s: Span,
) -> IResult<Span, DeferredImmediateCoverStatement> {
let (s, a) = symbol("cover")(s)?;
let (s, a) = keyword("cover")(s)?;
let (s, b) = assert_timing(s)?;
let (s, c) = paren(expression)(s)?;
let (s, d) = statement_or_null(s)?;
@ -255,7 +255,7 @@ pub fn deferred_immediate_cover_statement(
pub fn assert_timing(s: Span) -> IResult<Span, AssertTiming> {
alt((
map(symbol("#0"), |x| AssertTiming::Zero(x)),
map(symbol("final"), |x| AssertTiming::Final(x)),
map(keyword("final"), |x| AssertTiming::Final(x)),
))(s)
}

View File

@ -160,7 +160,7 @@ pub fn case_statement_normal(s: Span) -> IResult<Span, CaseStatement> {
let (s, c) = paren(case_expression)(s)?;
let (s, d) = case_item(s)?;
let (s, e) = many0(case_item)(s)?;
let (s, f) = symbol("endcase")(s)?;
let (s, f) = keyword("endcase")(s)?;
Ok((
s,
CaseStatement::Normal(CaseStatementNormal {
@ -174,10 +174,10 @@ pub fn case_statement_matches(s: Span) -> IResult<Span, CaseStatement> {
let (s, a) = opt(unique_priority)(s)?;
let (s, b) = case_keyword(s)?;
let (s, c) = paren(case_expression)(s)?;
let (s, d) = symbol("matches")(s)?;
let (s, d) = keyword("matches")(s)?;
let (s, e) = case_pattern_item(s)?;
let (s, f) = many0(case_pattern_item)(s)?;
let (s, g) = symbol("endcase")(s)?;
let (s, g) = keyword("endcase")(s)?;
Ok((
s,
CaseStatement::Matches(CaseStatementMatches {
@ -189,12 +189,12 @@ pub fn case_statement_matches(s: Span) -> IResult<Span, CaseStatement> {
#[parser]
pub fn case_statement_inside(s: Span) -> IResult<Span, CaseStatement> {
let (s, a) = opt(unique_priority)(s)?;
let (s, b) = symbol("case")(s)?;
let (s, b) = keyword("case")(s)?;
let (s, c) = paren(case_expression)(s)?;
let (s, d) = symbol("inside")(s)?;
let (s, d) = keyword("inside")(s)?;
let (s, e) = case_inside_item(s)?;
let (s, f) = many0(case_inside_item)(s)?;
let (s, g) = symbol("endcase")(s)?;
let (s, g) = keyword("endcase")(s)?;
Ok((
s,
CaseStatement::Inside(CaseStatementInside {
@ -206,9 +206,9 @@ pub fn case_statement_inside(s: Span) -> IResult<Span, CaseStatement> {
#[parser]
pub fn case_keyword(s: Span) -> IResult<Span, CaseKeyword> {
alt((
map(symbol("casez"), |x| CaseKeyword::Casez(x)),
map(symbol("casex"), |x| CaseKeyword::Casex(x)),
map(symbol("case"), |x| CaseKeyword::Case(x)),
map(keyword("casez"), |x| CaseKeyword::Casez(x)),
map(keyword("casex"), |x| CaseKeyword::Casex(x)),
map(keyword("case"), |x| CaseKeyword::Case(x)),
))(s)
}
@ -239,7 +239,7 @@ pub fn case_item_nondefault(s: Span) -> IResult<Span, CaseItem> {
#[parser]
pub fn case_item_default(s: Span) -> IResult<Span, CaseItemDefault> {
let (s, a) = symbol("default")(s)?;
let (s, a) = keyword("default")(s)?;
let (s, b) = opt(symbol(":"))(s)?;
let (s, c) = statement_or_null(s)?;
Ok((s, CaseItemDefault { nodes: (a, b, c) }))
@ -294,10 +294,10 @@ pub fn case_item_expression(s: Span) -> IResult<Span, CaseItemExpression> {
#[parser]
pub fn randcase_statement(s: Span) -> IResult<Span, RandcaseStatement> {
let (s, a) = symbol("randcase")(s)?;
let (s, a) = keyword("randcase")(s)?;
let (s, b) = randcase_item(s)?;
let (s, c) = many0(randcase_item)(s)?;
let (s, d) = symbol("endcase")(s)?;
let (s, d) = keyword("endcase")(s)?;
Ok((
s,
RandcaseStatement {

View File

@ -210,12 +210,12 @@ pub fn clocking_declaration(s: Span) -> IResult<Span, ClockingDeclaration> {
#[parser]
pub fn clocking_declaration_local(s: Span) -> IResult<Span, ClockingDeclaration> {
let (s, a) = opt(default)(s)?;
let (s, b) = symbol("clocking")(s)?;
let (s, b) = keyword("clocking")(s)?;
let (s, c) = opt(clocking_identifier)(s)?;
let (s, d) = clocking_event(s)?;
let (s, e) = symbol(";")(s)?;
let (s, f) = many0(clocking_item)(s)?;
let (s, g) = symbol("endclocking")(s)?;
let (s, g) = keyword("endclocking")(s)?;
let (s, h) = opt(pair(symbol(":"), clocking_identifier))(s)?;
Ok((
s,
@ -227,18 +227,18 @@ pub fn clocking_declaration_local(s: Span) -> IResult<Span, ClockingDeclaration>
#[parser]
pub fn default(s: Span) -> IResult<Span, Default> {
let (s, a) = symbol("default")(s)?;
let (s, a) = keyword("default")(s)?;
Ok((s, Default { nodes: (a,) }))
}
#[parser]
pub fn clocking_declaration_global(s: Span) -> IResult<Span, ClockingDeclaration> {
let (s, a) = symbol("global")(s)?;
let (s, b) = symbol("clocking")(s)?;
let (s, a) = keyword("global")(s)?;
let (s, b) = keyword("clocking")(s)?;
let (s, c) = opt(clocking_identifier)(s)?;
let (s, d) = clocking_event(s)?;
let (s, e) = symbol(";")(s)?;
let (s, f) = symbol("endclocking")(s)?;
let (s, f) = keyword("endclocking")(s)?;
let (s, g) = opt(pair(symbol(":"), clocking_identifier))(s)?;
Ok((
s,
@ -284,7 +284,7 @@ pub fn clocking_item(s: Span) -> IResult<Span, ClockingItem> {
#[parser]
pub fn clocking_item_default(s: Span) -> IResult<Span, ClockingItem> {
let (s, a) = symbol("default")(s)?;
let (s, a) = keyword("default")(s)?;
let (s, b) = default_skew(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
@ -325,23 +325,23 @@ pub fn default_skew(s: Span) -> IResult<Span, DefaultSkew> {
#[parser]
pub fn default_skew_input(s: Span) -> IResult<Span, DefaultSkew> {
let (s, a) = symbol("input")(s)?;
let (s, a) = keyword("input")(s)?;
let (s, b) = clocking_skew(s)?;
Ok((s, DefaultSkew::Input(DefaultSkewInput { nodes: (a, b) })))
}
#[parser]
pub fn default_skew_output(s: Span) -> IResult<Span, DefaultSkew> {
let (s, a) = symbol("output")(s)?;
let (s, a) = keyword("output")(s)?;
let (s, b) = clocking_skew(s)?;
Ok((s, DefaultSkew::Output(DefaultSkewOutput { nodes: (a, b) })))
}
#[parser]
pub fn default_skew_input_output(s: Span) -> IResult<Span, DefaultSkew> {
let (s, a) = symbol("input")(s)?;
let (s, a) = keyword("input")(s)?;
let (s, b) = clocking_skew(s)?;
let (s, c) = symbol("output")(s)?;
let (s, c) = keyword("output")(s)?;
let (s, d) = clocking_skew(s)?;
Ok((
s,
@ -363,7 +363,7 @@ pub fn clocking_direction(s: Span) -> IResult<Span, ClockingDirection> {
#[parser]
pub fn clocking_direction_input(s: Span) -> IResult<Span, ClockingDirection> {
let (s, a) = symbol("input")(s)?;
let (s, a) = keyword("input")(s)?;
let (s, b) = opt(clocking_skew)(s)?;
Ok((
s,
@ -373,7 +373,7 @@ pub fn clocking_direction_input(s: Span) -> IResult<Span, ClockingDirection> {
#[parser]
pub fn clocking_direction_output(s: Span) -> IResult<Span, ClockingDirection> {
let (s, a) = symbol("output")(s)?;
let (s, a) = keyword("output")(s)?;
let (s, b) = opt(clocking_skew)(s)?;
Ok((
s,
@ -383,9 +383,9 @@ pub fn clocking_direction_output(s: Span) -> IResult<Span, ClockingDirection> {
#[parser]
pub fn clocking_direction_input_output(s: Span) -> IResult<Span, ClockingDirection> {
let (s, a) = symbol("input")(s)?;
let (s, a) = keyword("input")(s)?;
let (s, b) = opt(clocking_skew)(s)?;
let (s, c) = symbol("output")(s)?;
let (s, c) = keyword("output")(s)?;
let (s, d) = opt(clocking_skew)(s)?;
Ok((
s,
@ -397,7 +397,7 @@ pub fn clocking_direction_input_output(s: Span) -> IResult<Span, ClockingDirecti
#[parser]
pub fn clocking_direction_inout(s: Span) -> IResult<Span, ClockingDirection> {
let (s, a) = symbol("inout")(s)?;
let (s, a) = keyword("inout")(s)?;
Ok((s, ClockingDirection::Inout(a)))
}

View File

@ -53,16 +53,16 @@ pub struct CondPattern<'a> {
#[parser]
pub fn conditional_statement(s: Span) -> IResult<Span, ConditionalStatement> {
let (s, a) = opt(unique_priority)(s)?;
let (s, b) = symbol("if")(s)?;
let (s, b) = keyword("if")(s)?;
let (s, c) = paren(cond_predicate)(s)?;
let (s, d) = statement_or_null(s)?;
let (s, e) = many0(tuple((
symbol("else"),
symbol("if"),
keyword("else"),
keyword("if"),
paren(cond_predicate),
statement_or_null,
)))(s)?;
let (s, f) = opt(pair(symbol("else"), statement_or_null))(s)?;
let (s, f) = opt(pair(keyword("else"), statement_or_null))(s)?;
Ok((
s,
@ -75,9 +75,9 @@ pub fn conditional_statement(s: Span) -> IResult<Span, ConditionalStatement> {
#[parser]
pub fn unique_priority(s: Span) -> IResult<Span, UniquePriority> {
alt((
map(symbol("unique0"), |x| UniquePriority::Unique0(x)),
map(symbol("unique"), |x| UniquePriority::Unique(x)),
map(symbol("priority"), |x| UniquePriority::Priority(x)),
map(keyword("unique0"), |x| UniquePriority::Unique0(x)),
map(keyword("unique"), |x| UniquePriority::Unique(x)),
map(keyword("priority"), |x| UniquePriority::Priority(x)),
))(s)
}
@ -98,7 +98,7 @@ pub fn expression_or_cond_pattern(s: Span) -> IResult<Span, ExpressionOrCondPatt
#[parser(MaybeRecursive)]
pub fn cond_pattern(s: Span) -> IResult<Span, CondPattern> {
let (s, a) = expression(s)?;
let (s, b) = symbol("matches")(s)?;
let (s, b) = keyword("matches")(s)?;
let (s, c) = pattern(s)?;
Ok((s, CondPattern { nodes: (a, b, c) }))
}

View File

@ -68,7 +68,7 @@ pub fn continuous_assign(s: Span) -> IResult<Span, ContinuousAssign> {
#[parser]
pub fn continuous_assign_net(s: Span) -> IResult<Span, ContinuousAssign> {
let (s, a) = symbol("assign")(s)?;
let (s, a) = keyword("assign")(s)?;
let (s, b) = opt(drive_strength)(s)?;
let (s, c) = opt(delay3)(s)?;
let (s, d) = list_of_net_assignments(s)?;
@ -84,7 +84,7 @@ pub fn continuous_assign_net(s: Span) -> IResult<Span, ContinuousAssign> {
#[parser]
pub fn continuous_assign_variable(s: Span) -> IResult<Span, ContinuousAssign> {
let (s, a) = symbol("assign")(s)?;
let (s, a) = keyword("assign")(s)?;
let (s, b) = opt(delay_control)(s)?;
let (s, c) = list_of_variable_assignments(s)?;
let (s, d) = symbol(";")(s)?;
@ -111,7 +111,7 @@ pub fn list_of_variable_assignments(s: Span) -> IResult<Span, ListOfVariableAssi
#[parser]
pub fn net_alias(s: Span) -> IResult<Span, NetAlias> {
let (s, a) = symbol("alias")(s)?;
let (s, a) = keyword("alias")(s)?;
let (s, b) = net_lvalue(s)?;
let (s, c) = symbol("=")(s)?;
let (s, d) = list(symbol("="), net_lvalue)(s)?;

View File

@ -134,7 +134,7 @@ pub fn loop_statement(s: Span) -> IResult<Span, LoopStatement> {
#[parser]
pub fn loop_statement_forever(s: Span) -> IResult<Span, LoopStatement> {
let (s, a) = symbol("forever")(s)?;
let (s, a) = keyword("forever")(s)?;
let (s, b) = statement_or_null(s)?;
Ok((
s,
@ -144,7 +144,7 @@ pub fn loop_statement_forever(s: Span) -> IResult<Span, LoopStatement> {
#[parser]
pub fn loop_statement_repeat(s: Span) -> IResult<Span, LoopStatement> {
let (s, a) = symbol("repeat")(s)?;
let (s, a) = keyword("repeat")(s)?;
let (s, b) = paren(expression)(s)?;
let (s, c) = statement_or_null(s)?;
Ok((
@ -155,7 +155,7 @@ pub fn loop_statement_repeat(s: Span) -> IResult<Span, LoopStatement> {
#[parser]
pub fn loop_statement_while(s: Span) -> IResult<Span, LoopStatement> {
let (s, a) = symbol("while")(s)?;
let (s, a) = keyword("while")(s)?;
let (s, b) = paren(expression)(s)?;
let (s, c) = statement_or_null(s)?;
Ok((
@ -166,7 +166,7 @@ pub fn loop_statement_while(s: Span) -> IResult<Span, LoopStatement> {
#[parser]
pub fn loop_statement_for(s: Span) -> IResult<Span, LoopStatement> {
let (s, a) = symbol("for")(s)?;
let (s, a) = keyword("for")(s)?;
let (s, b) = paren(tuple((
opt(for_initialization),
symbol(":"),
@ -180,9 +180,9 @@ pub fn loop_statement_for(s: Span) -> IResult<Span, LoopStatement> {
#[parser]
pub fn loop_statement_do_while(s: Span) -> IResult<Span, LoopStatement> {
let (s, a) = symbol("do")(s)?;
let (s, a) = keyword("do")(s)?;
let (s, b) = statement_or_null(s)?;
let (s, c) = symbol("while")(s)?;
let (s, c) = keyword("while")(s)?;
let (s, d) = paren(expression)(s)?;
let (s, e) = symbol(";")(s)?;
Ok((
@ -195,7 +195,7 @@ pub fn loop_statement_do_while(s: Span) -> IResult<Span, LoopStatement> {
#[parser]
pub fn loop_statement_foreach(s: Span) -> IResult<Span, LoopStatement> {
let (s, a) = symbol("foreach")(s)?;
let (s, a) = keyword("foreach")(s)?;
let (s, b) = paren(pair(
ps_or_hierarchical_array_identifier,
bracket(loop_variables),
@ -239,7 +239,7 @@ pub fn for_variable_declaration(s: Span) -> IResult<Span, ForVariableDeclaration
#[parser]
pub fn var(s: Span) -> IResult<Span, Var> {
let (s, a) = symbol("var")(s)?;
let (s, a) = keyword("var")(s)?;
Ok((s, Var { nodes: (a,) }))
}

View File

@ -63,18 +63,18 @@ pub fn action_block(s: Span) -> IResult<Span, ActionBlock> {
#[parser]
pub fn action_block_else(s: Span) -> IResult<Span, ActionBlock> {
let (s, a) = opt(statement)(s)?;
let (s, b) = symbol("else")(s)?;
let (s, b) = keyword("else")(s)?;
let (s, c) = statement_or_null(s)?;
Ok((s, ActionBlock::Else(ActionBlockElse { nodes: (a, b, c) })))
}
#[parser]
pub fn seq_block(s: Span) -> IResult<Span, SeqBlock> {
let (s, a) = symbol("begin")(s)?;
let (s, a) = keyword("begin")(s)?;
let (s, b) = opt(pair(symbol(":"), block_identifier))(s)?;
let (s, c) = many0(block_item_declaration)(s)?;
let (s, d) = many0(statement_or_null)(s)?;
let (s, e) = symbol("end")(s)?;
let (s, e) = keyword("end")(s)?;
let (s, f) = opt(pair(symbol(":"), block_identifier))(s)?;
Ok((
s,
@ -86,7 +86,7 @@ pub fn seq_block(s: Span) -> IResult<Span, SeqBlock> {
#[parser]
pub fn par_block(s: Span) -> IResult<Span, ParBlock> {
let (s, a) = symbol("fork")(s)?;
let (s, a) = keyword("fork")(s)?;
let (s, b) = opt(pair(symbol(":"), block_identifier))(s)?;
let (s, c) = many0(block_item_declaration)(s)?;
let (s, d) = many0(statement_or_null)(s)?;
@ -103,8 +103,8 @@ pub fn par_block(s: Span) -> IResult<Span, ParBlock> {
#[parser]
pub fn join_keyword(s: Span) -> IResult<Span, JoinKeyword> {
alt((
map(symbol("join_any"), |x| JoinKeyword::JoinAny(x)),
map(symbol("join_none"), |x| JoinKeyword::JoinNone(x)),
map(symbol("join"), |x| JoinKeyword::Join(x)),
map(keyword("join_any"), |x| JoinKeyword::JoinAny(x)),
map(keyword("join_none"), |x| JoinKeyword::JoinNone(x)),
map(keyword("join"), |x| JoinKeyword::Join(x)),
))(s)
}

View File

@ -158,7 +158,7 @@ pub fn pattern_variable(s: Span) -> IResult<Span, Pattern> {
#[parser]
pub fn pattern_tagged(s: Span) -> IResult<Span, Pattern> {
let (s, a) = symbol("tagged")(s)?;
let (s, a) = keyword("tagged")(s)?;
let (s, b) = member_identifier(s)?;
let (s, c) = opt(pattern)(s)?;
Ok((
@ -268,7 +268,7 @@ pub fn array_pattern_key(s: Span) -> IResult<Span, ArrayPatternKey> {
pub fn assignment_pattern_key(s: Span) -> IResult<Span, AssignmentPatternKey> {
alt((
map(simple_type, |x| AssignmentPatternKey::SimpleType(x)),
map(symbol("default"), |x| AssignmentPatternKey::Default(x)),
map(keyword("default"), |x| AssignmentPatternKey::Default(x)),
))(s)
}

View File

@ -132,7 +132,7 @@ pub struct VariableAssignment<'a> {
#[parser]
pub fn initial_construct(s: Span) -> IResult<Span, InitialConstruct> {
let (s, a) = symbol("initial")(s)?;
let (s, a) = keyword("initial")(s)?;
let (s, b) = statement_or_null(s)?;
Ok((s, InitialConstruct { nodes: (a, b) }))
}
@ -147,16 +147,16 @@ pub fn always_construct(s: Span) -> IResult<Span, AlwaysConstruct> {
#[parser]
pub fn always_keyword(s: Span) -> IResult<Span, AlwaysKeyword> {
alt((
map(symbol("always_comb"), |x| AlwaysKeyword::AlwaysComb(x)),
map(symbol("always_latch"), |x| AlwaysKeyword::AlwaysLatch(x)),
map(symbol("always_ff"), |x| AlwaysKeyword::AlwaysFf(x)),
map(symbol("always"), |x| AlwaysKeyword::Always(x)),
map(keyword("always_comb"), |x| AlwaysKeyword::AlwaysComb(x)),
map(keyword("always_latch"), |x| AlwaysKeyword::AlwaysLatch(x)),
map(keyword("always_ff"), |x| AlwaysKeyword::AlwaysFf(x)),
map(keyword("always"), |x| AlwaysKeyword::Always(x)),
))(s)
}
#[parser]
pub fn final_construct(s: Span) -> IResult<Span, FinalConstruct> {
let (s, a) = symbol("final")(s)?;
let (s, a) = keyword("final")(s)?;
let (s, b) = function_statement(s)?;
Ok((s, FinalConstruct { nodes: (a, b) }))
}
@ -272,7 +272,7 @@ pub fn procedural_continuous_assignment(s: Span) -> IResult<Span, ProceduralCont
pub fn procedural_continuous_assignment_assign(
s: Span,
) -> IResult<Span, ProceduralContinuousAssignment> {
let (s, a) = symbol("assign")(s)?;
let (s, a) = keyword("assign")(s)?;
let (s, b) = variable_assignment(s)?;
Ok((
s,
@ -286,7 +286,7 @@ pub fn procedural_continuous_assignment_assign(
pub fn procedural_continuous_assignment_deassign(
s: Span,
) -> IResult<Span, ProceduralContinuousAssignment> {
let (s, a) = symbol("deassign")(s)?;
let (s, a) = keyword("deassign")(s)?;
let (s, b) = variable_lvalue(s)?;
Ok((
s,
@ -300,7 +300,7 @@ pub fn procedural_continuous_assignment_deassign(
pub fn procedural_continuous_assignment_force_variable(
s: Span,
) -> IResult<Span, ProceduralContinuousAssignment> {
let (s, a) = symbol("force")(s)?;
let (s, a) = keyword("force")(s)?;
let (s, b) = variable_assignment(s)?;
Ok((
s,
@ -314,7 +314,7 @@ pub fn procedural_continuous_assignment_force_variable(
pub fn procedural_continuous_assignment_force_net(
s: Span,
) -> IResult<Span, ProceduralContinuousAssignment> {
let (s, a) = symbol("force")(s)?;
let (s, a) = keyword("force")(s)?;
let (s, b) = net_assignment(s)?;
Ok((
s,
@ -328,7 +328,7 @@ pub fn procedural_continuous_assignment_force_net(
pub fn procedural_continuous_assignment_release_variable(
s: Span,
) -> IResult<Span, ProceduralContinuousAssignment> {
let (s, a) = symbol("release")(s)?;
let (s, a) = keyword("release")(s)?;
let (s, b) = variable_lvalue(s)?;
Ok((
s,
@ -342,7 +342,7 @@ pub fn procedural_continuous_assignment_release_variable(
pub fn procedural_continuous_assignment_release_net(
s: Span,
) -> IResult<Span, ProceduralContinuousAssignment> {
let (s, a) = symbol("release")(s)?;
let (s, a) = keyword("release")(s)?;
let (s, b) = net_lvalue(s)?;
Ok((
s,

View File

@ -152,11 +152,11 @@ pub struct RsCaseItemDefault<'a> {
#[parser]
pub fn randsequence_statement(s: Span) -> IResult<Span, RandsequenceStatement> {
let (s, a) = symbol("randsequence")(s)?;
let (s, a) = keyword("randsequence")(s)?;
let (s, b) = paren(opt(production_identifier))(s)?;
let (s, c) = production(s)?;
let (s, d) = many0(production)(s)?;
let (s, e) = symbol("endsequence")(s)?;
let (s, e) = keyword("endsequence")(s)?;
Ok((
s,
RandsequenceStatement {
@ -209,8 +209,8 @@ pub fn rs_production_list_prod(s: Span) -> IResult<Span, RsProductionList> {
#[parser]
pub fn rs_production_list_join(s: Span) -> IResult<Span, RsProductionList> {
let (s, a) = symbol("rand")(s)?;
let (s, b) = symbol("join")(s)?;
let (s, a) = keyword("rand")(s)?;
let (s, b) = keyword("join")(s)?;
let (s, c) = opt(paren(expression))(s)?;
let (s, d) = production_item(s)?;
let (s, e) = production_item(s)?;
@ -267,10 +267,10 @@ pub fn production_item(s: Span) -> IResult<Span, ProductionItem> {
#[parser]
pub fn rs_if_else(s: Span) -> IResult<Span, RsIfElse> {
let (s, a) = symbol("if")(s)?;
let (s, a) = keyword("if")(s)?;
let (s, b) = paren(expression)(s)?;
let (s, c) = production_item(s)?;
let (s, d) = opt(pair(symbol("else"), production_item))(s)?;
let (s, d) = opt(pair(keyword("else"), production_item))(s)?;
Ok((
s,
RsIfElse {
@ -281,7 +281,7 @@ pub fn rs_if_else(s: Span) -> IResult<Span, RsIfElse> {
#[parser]
pub fn rs_repeat(s: Span) -> IResult<Span, RsRepeat> {
let (s, a) = symbol("repeat")(s)?;
let (s, a) = keyword("repeat")(s)?;
let (s, b) = paren(expression)(s)?;
let (s, c) = production_item(s)?;
Ok((s, RsRepeat { nodes: (a, b, c) }))
@ -289,11 +289,11 @@ pub fn rs_repeat(s: Span) -> IResult<Span, RsRepeat> {
#[parser]
pub fn rs_case(s: Span) -> IResult<Span, RsCase> {
let (s, a) = symbol("case")(s)?;
let (s, a) = keyword("case")(s)?;
let (s, b) = paren(case_expression)(s)?;
let (s, c) = rs_case_item(s)?;
let (s, d) = many0(rs_case_item)(s)?;
let (s, e) = symbol("endcase")(s)?;
let (s, e) = keyword("endcase")(s)?;
Ok((
s,
RsCase {
@ -323,7 +323,7 @@ pub fn rs_case_item_nondefault(s: Span) -> IResult<Span, RsCaseItem> {
#[parser]
pub fn rs_case_item_default(s: Span) -> IResult<Span, RsCaseItem> {
let (s, a) = symbol("default")(s)?;
let (s, a) = keyword("default")(s)?;
let (s, b) = opt(symbol(":"))(s)?;
let (s, c) = production_item(s)?;
let (s, d) = symbol(";")(s)?;

View File

@ -37,7 +37,7 @@ pub fn subroutine_call_statement(s: Span) -> IResult<Span, SubroutineCallStateme
#[parser]
pub fn subroutine_call_statement_function(s: Span) -> IResult<Span, SubroutineCallStatement> {
let (s, a) = symbol("void")(s)?;
let (s, a) = keyword("void")(s)?;
let (s, b) = symbol("'")(s)?;
let (s, c) = paren(function_subroutine_call)(s)?;
let (s, d) = symbol(";")(s)?;

View File

@ -232,7 +232,7 @@ pub fn delay_or_event_control(s: Span) -> IResult<Span, DelayOrEventControl> {
#[parser]
pub fn delay_or_event_control_repeat(s: Span) -> IResult<Span, DelayOrEventControl> {
let (s, a) = symbol("repeat")(s)?;
let (s, a) = keyword("repeat")(s)?;
let (s, b) = paren(expression)(s)?;
let (s, c) = event_control(s)?;
Ok((
@ -338,7 +338,7 @@ pub fn event_expression(s: Span) -> IResult<Span, EventExpression> {
pub fn event_expression_expression(s: Span) -> IResult<Span, EventExpression> {
let (s, a) = opt(edge_identifier)(s)?;
let (s, b) = expression(s)?;
let (s, c) = opt(pair(symbol("iff"), expression))(s)?;
let (s, c) = opt(pair(keyword("iff"), expression))(s)?;
Ok((
s,
EventExpression::Expression(Box::new(EventExpressionExpression { nodes: (a, b, c) })),
@ -348,7 +348,7 @@ pub fn event_expression_expression(s: Span) -> IResult<Span, EventExpression> {
#[parser]
pub fn event_expression_sequence(s: Span) -> IResult<Span, EventExpression> {
let (s, a) = sequence_instance(s)?;
let (s, b) = opt(pair(symbol("iff"), expression))(s)?;
let (s, b) = opt(pair(keyword("iff"), expression))(s)?;
Ok((
s,
EventExpression::Sequence(Box::new(EventExpressionSequence { nodes: (a, b) })),
@ -358,7 +358,7 @@ pub fn event_expression_sequence(s: Span) -> IResult<Span, EventExpression> {
#[parser(MaybeRecursive)]
pub fn event_expression_or(s: Span) -> IResult<Span, EventExpression> {
let (s, a) = event_expression(s)?;
let (s, b) = symbol("or")(s)?;
let (s, b) = keyword("or")(s)?;
let (s, c) = event_expression(s)?;
Ok((
s,
@ -406,7 +406,7 @@ pub fn jump_statement(s: Span) -> IResult<Span, JumpStatement> {
#[parser]
pub fn jump_statement_return(s: Span) -> IResult<Span, JumpStatement> {
let (s, a) = symbol("return")(s)?;
let (s, a) = keyword("return")(s)?;
let (s, b) = opt(expression)(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
@ -417,7 +417,7 @@ pub fn jump_statement_return(s: Span) -> IResult<Span, JumpStatement> {
#[parser]
pub fn jump_statement_break(s: Span) -> IResult<Span, JumpStatement> {
let (s, a) = symbol("break")(s)?;
let (s, a) = keyword("break")(s)?;
let (s, b) = symbol(";")(s)?;
Ok((
s,
@ -427,7 +427,7 @@ pub fn jump_statement_break(s: Span) -> IResult<Span, JumpStatement> {
#[parser]
pub fn jump_statement_continue(s: Span) -> IResult<Span, JumpStatement> {
let (s, a) = symbol("continue")(s)?;
let (s, a) = keyword("continue")(s)?;
let (s, b) = symbol(";")(s)?;
Ok((
s,
@ -446,7 +446,7 @@ pub fn wait_statement(s: Span) -> IResult<Span, WaitStatement> {
#[parser]
pub fn wait_statement_wait(s: Span) -> IResult<Span, WaitStatement> {
let (s, a) = symbol("wait")(s)?;
let (s, a) = keyword("wait")(s)?;
let (s, b) = paren(expression)(s)?;
let (s, c) = statement_or_null(s)?;
Ok((
@ -457,8 +457,8 @@ pub fn wait_statement_wait(s: Span) -> IResult<Span, WaitStatement> {
#[parser]
pub fn wait_statement_fork(s: Span) -> IResult<Span, WaitStatement> {
let (s, a) = symbol("wait")(s)?;
let (s, b) = symbol("fork")(s)?;
let (s, a) = keyword("wait")(s)?;
let (s, b) = keyword("fork")(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
s,
@ -468,7 +468,7 @@ pub fn wait_statement_fork(s: Span) -> IResult<Span, WaitStatement> {
#[parser]
pub fn wait_statement_order(s: Span) -> IResult<Span, WaitStatement> {
let (s, a) = symbol("wait_order")(s)?;
let (s, a) = keyword("wait_order")(s)?;
let (s, b) = paren(list(symbol(","), hierarchical_identifier))(s)?;
let (s, c) = action_block(s)?;
Ok((
@ -518,7 +518,7 @@ pub fn disable_statement(s: Span) -> IResult<Span, DisableStatement> {
#[parser]
pub fn disable_statement_task(s: Span) -> IResult<Span, DisableStatement> {
let (s, a) = symbol("disable")(s)?;
let (s, a) = keyword("disable")(s)?;
let (s, b) = hierarchical_task_identifier(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
@ -529,7 +529,7 @@ pub fn disable_statement_task(s: Span) -> IResult<Span, DisableStatement> {
#[parser]
pub fn disable_statement_block(s: Span) -> IResult<Span, DisableStatement> {
let (s, a) = symbol("disable")(s)?;
let (s, a) = keyword("disable")(s)?;
let (s, b) = hierarchical_block_identifier(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
@ -540,8 +540,8 @@ pub fn disable_statement_block(s: Span) -> IResult<Span, DisableStatement> {
#[parser]
pub fn disable_statement_fork(s: Span) -> IResult<Span, DisableStatement> {
let (s, a) = symbol("disable")(s)?;
let (s, b) = symbol("fork")(s)?;
let (s, a) = keyword("disable")(s)?;
let (s, b) = keyword("fork")(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
s,

View File

@ -799,8 +799,8 @@ pub fn concurrent_assertion_statement(s: Span) -> IResult<Span, ConcurrentAssert
#[parser]
pub fn assert_property_statement(s: Span) -> IResult<Span, AssertPropertyStatement> {
let (s, a) = symbol("assert")(s)?;
let (s, b) = symbol("property")(s)?;
let (s, a) = keyword("assert")(s)?;
let (s, b) = keyword("property")(s)?;
let (s, c) = paren(property_spec)(s)?;
let (s, d) = action_block(s)?;
Ok((
@ -813,8 +813,8 @@ pub fn assert_property_statement(s: Span) -> IResult<Span, AssertPropertyStateme
#[parser]
pub fn assume_property_statement(s: Span) -> IResult<Span, AssumePropertyStatement> {
let (s, a) = symbol("assume")(s)?;
let (s, b) = symbol("property")(s)?;
let (s, a) = keyword("assume")(s)?;
let (s, b) = keyword("property")(s)?;
let (s, c) = paren(property_spec)(s)?;
let (s, d) = action_block(s)?;
Ok((
@ -827,8 +827,8 @@ pub fn assume_property_statement(s: Span) -> IResult<Span, AssumePropertyStateme
#[parser]
pub fn cover_property_statement(s: Span) -> IResult<Span, CoverPropertyStatement> {
let (s, a) = symbol("cover")(s)?;
let (s, b) = symbol("property")(s)?;
let (s, a) = keyword("cover")(s)?;
let (s, b) = keyword("property")(s)?;
let (s, c) = paren(property_spec)(s)?;
let (s, d) = statement_or_null(s)?;
Ok((
@ -841,7 +841,7 @@ pub fn cover_property_statement(s: Span) -> IResult<Span, CoverPropertyStatement
#[parser]
pub fn expect_property_statement(s: Span) -> IResult<Span, ExpectPropertyStatement> {
let (s, a) = symbol("expect")(s)?;
let (s, a) = keyword("expect")(s)?;
let (s, b) = paren(property_spec)(s)?;
let (s, c) = action_block(s)?;
Ok((s, ExpectPropertyStatement { nodes: (a, b, c) }))
@ -849,13 +849,13 @@ pub fn expect_property_statement(s: Span) -> IResult<Span, ExpectPropertyStateme
#[parser]
pub fn cover_sequence_statement(s: Span) -> IResult<Span, CoverSequenceStatement> {
let (s, a) = symbol("cover")(s)?;
let (s, b) = symbol("sequence")(s)?;
let (s, a) = keyword("cover")(s)?;
let (s, b) = keyword("sequence")(s)?;
let (s, c) = paren(triple(
opt(clocking_event),
opt(triple(
symbol("disable"),
symbol("iff"),
keyword("disable"),
keyword("iff"),
paren(expression_or_dist),
)),
sequence_expr,
@ -871,8 +871,8 @@ pub fn cover_sequence_statement(s: Span) -> IResult<Span, CoverSequenceStatement
#[parser]
pub fn restrict_property_statement(s: Span) -> IResult<Span, RestrictPropertyStatement> {
let (s, a) = symbol("restrict")(s)?;
let (s, b) = symbol("property")(s)?;
let (s, a) = keyword("restrict")(s)?;
let (s, b) = keyword("property")(s)?;
let (s, c) = paren(property_spec)(s)?;
let (s, d) = symbol(";")(s)?;
Ok((
@ -952,14 +952,14 @@ pub fn assertion_item_declaration(s: Span) -> IResult<Span, AssertionItemDeclara
#[parser]
pub fn property_declaration(s: Span) -> IResult<Span, PropertyDeclaration> {
let (s, a) = symbol("property")(s)?;
let (s, a) = keyword("property")(s)?;
let (s, b) = property_identifier(s)?;
let (s, c) = opt(paren(opt(property_port_list)))(s)?;
let (s, d) = symbol(";")(s)?;
let (s, e) = many0(assertion_variable_declaration)(s)?;
let (s, f) = property_spec(s)?;
let (s, g) = opt(symbol(";"))(s)?;
let (s, h) = symbol("endproperty")(s)?;
let (s, h) = keyword("endproperty")(s)?;
let (s, i) = opt(pair(symbol(":"), property_identifier))(s)?;
Ok((
s,
@ -993,7 +993,7 @@ pub fn property_port_item(s: Span) -> IResult<Span, PropertyPortItem> {
#[parser]
pub fn property_lvar_port_direction(s: Span) -> IResult<Span, PropertyLvarPortDirection> {
let (s, a) = symbol("input")(s)?;
let (s, a) = keyword("input")(s)?;
Ok((s, PropertyLvarPortDirection::Input(a)))
}
@ -1003,7 +1003,7 @@ pub fn property_formal_type(s: Span) -> IResult<Span, PropertyFormalType> {
map(sequence_formal_type, |x| {
PropertyFormalType::SequenceFormalType(x)
}),
map(symbol("property"), |x| PropertyFormalType::Property(x)),
map(keyword("property"), |x| PropertyFormalType::Property(x)),
))(s)
}
@ -1011,8 +1011,8 @@ pub fn property_formal_type(s: Span) -> IResult<Span, PropertyFormalType> {
pub fn property_spec(s: Span) -> IResult<Span, PropertySpec> {
let (s, a) = opt(clocking_event)(s)?;
let (s, b) = opt(triple(
symbol("disable"),
symbol("iff"),
keyword("disable"),
keyword("iff"),
paren(expression_or_dist),
))(s)?;
let (s, c) = property_expr(s)?;
@ -1064,7 +1064,7 @@ pub fn property_expr(s: Span) -> IResult<Span, PropertyExpr> {
#[parser]
pub fn property_expr_strong(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("strong")(s)?;
let (s, a) = keyword("strong")(s)?;
let (s, b) = paren(sequence_expr)(s)?;
Ok((
s,
@ -1074,7 +1074,7 @@ pub fn property_expr_strong(s: Span) -> IResult<Span, PropertyExpr> {
#[parser]
pub fn property_expr_weak(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("weak")(s)?;
let (s, a) = keyword("weak")(s)?;
let (s, b) = paren(sequence_expr)(s)?;
Ok((
s,
@ -1093,7 +1093,7 @@ pub fn property_expr_paren(s: Span) -> IResult<Span, PropertyExpr> {
#[parser]
pub fn property_expr_not(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("not")(s)?;
let (s, a) = keyword("not")(s)?;
let (s, b) = property_expr(s)?;
Ok((
s,
@ -1104,7 +1104,7 @@ pub fn property_expr_not(s: Span) -> IResult<Span, PropertyExpr> {
#[parser(MaybeRecursive)]
pub fn property_expr_or(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = symbol("or")(s)?;
let (s, b) = keyword("or")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
@ -1115,7 +1115,7 @@ pub fn property_expr_or(s: Span) -> IResult<Span, PropertyExpr> {
#[parser(MaybeRecursive)]
pub fn property_expr_and(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = symbol("and")(s)?;
let (s, b) = keyword("and")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
@ -1151,10 +1151,10 @@ pub fn property_expr_implication_nonoverlapped(s: Span) -> IResult<Span, Propert
#[parser]
pub fn property_expr_if(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("if")(s)?;
let (s, a) = keyword("if")(s)?;
let (s, b) = paren(expression_or_dist)(s)?;
let (s, c) = property_expr(s)?;
let (s, d) = opt(pair(symbol("else"), property_expr))(s)?;
let (s, d) = opt(pair(keyword("else"), property_expr))(s)?;
Ok((
s,
PropertyExpr::If(Box::new(PropertyExprIf {
@ -1165,11 +1165,11 @@ pub fn property_expr_if(s: Span) -> IResult<Span, PropertyExpr> {
#[parser]
pub fn property_expr_case(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("case")(s)?;
let (s, a) = keyword("case")(s)?;
let (s, b) = paren(expression_or_dist)(s)?;
let (s, c) = property_case_item(s)?;
let (s, d) = many0(property_case_item)(s)?;
let (s, e) = symbol("endcase")(s)?;
let (s, e) = keyword("endcase")(s)?;
Ok((
s,
PropertyExpr::Case(Box::new(PropertyExprCase {
@ -1206,7 +1206,7 @@ pub fn property_expr_followed_by_nonoverlapped(s: Span) -> IResult<Span, Propert
#[parser]
pub fn property_expr_nexttime(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("nexttime")(s)?;
let (s, a) = keyword("nexttime")(s)?;
let (s, b) = opt(bracket(constant_expression))(s)?;
let (s, c) = property_expr(s)?;
Ok((
@ -1217,7 +1217,7 @@ pub fn property_expr_nexttime(s: Span) -> IResult<Span, PropertyExpr> {
#[parser]
pub fn property_expr_s_nexttime(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("s_nexttime")(s)?;
let (s, a) = keyword("s_nexttime")(s)?;
let (s, b) = opt(bracket(constant_expression))(s)?;
let (s, c) = property_expr(s)?;
Ok((
@ -1228,7 +1228,7 @@ pub fn property_expr_s_nexttime(s: Span) -> IResult<Span, PropertyExpr> {
#[parser]
pub fn property_expr_always(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("always")(s)?;
let (s, a) = keyword("always")(s)?;
let (s, b) = opt(bracket(cycle_delay_const_range_expression))(s)?;
let (s, c) = property_expr(s)?;
Ok((
@ -1239,7 +1239,7 @@ pub fn property_expr_always(s: Span) -> IResult<Span, PropertyExpr> {
#[parser]
pub fn property_expr_s_always(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("s_always")(s)?;
let (s, a) = keyword("s_always")(s)?;
let (s, b) = bracket(cycle_delay_const_range_expression)(s)?;
let (s, c) = property_expr(s)?;
Ok((
@ -1250,7 +1250,7 @@ pub fn property_expr_s_always(s: Span) -> IResult<Span, PropertyExpr> {
#[parser]
pub fn property_expr_eventually(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("eventually")(s)?;
let (s, a) = keyword("eventually")(s)?;
let (s, b) = bracket(constant_range)(s)?;
let (s, c) = property_expr(s)?;
Ok((
@ -1261,7 +1261,7 @@ pub fn property_expr_eventually(s: Span) -> IResult<Span, PropertyExpr> {
#[parser]
pub fn property_expr_s_eventually(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("s_eventually")(s)?;
let (s, a) = keyword("s_eventually")(s)?;
let (s, b) = opt(bracket(cycle_delay_const_range_expression))(s)?;
let (s, c) = property_expr(s)?;
Ok((
@ -1273,7 +1273,7 @@ pub fn property_expr_s_eventually(s: Span) -> IResult<Span, PropertyExpr> {
#[parser(MaybeRecursive)]
pub fn property_expr_until(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = symbol("until")(s)?;
let (s, b) = keyword("until")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
@ -1284,7 +1284,7 @@ pub fn property_expr_until(s: Span) -> IResult<Span, PropertyExpr> {
#[parser(MaybeRecursive)]
pub fn property_expr_s_until(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = symbol("s_until")(s)?;
let (s, b) = keyword("s_until")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
@ -1295,7 +1295,7 @@ pub fn property_expr_s_until(s: Span) -> IResult<Span, PropertyExpr> {
#[parser(MaybeRecursive)]
pub fn property_expr_until_with(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = symbol("until_with")(s)?;
let (s, b) = keyword("until_with")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
@ -1306,7 +1306,7 @@ pub fn property_expr_until_with(s: Span) -> IResult<Span, PropertyExpr> {
#[parser(MaybeRecursive)]
pub fn property_expr_s_until_with(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = symbol("s_until_with")(s)?;
let (s, b) = keyword("s_until_with")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
@ -1317,7 +1317,7 @@ pub fn property_expr_s_until_with(s: Span) -> IResult<Span, PropertyExpr> {
#[parser(MaybeRecursive)]
pub fn property_expr_implies(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = symbol("implies")(s)?;
let (s, b) = keyword("implies")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
@ -1328,7 +1328,7 @@ pub fn property_expr_implies(s: Span) -> IResult<Span, PropertyExpr> {
#[parser(MaybeRecursive)]
pub fn property_expr_iff(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = symbol("iff")(s)?;
let (s, b) = keyword("iff")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
@ -1338,7 +1338,7 @@ pub fn property_expr_iff(s: Span) -> IResult<Span, PropertyExpr> {
#[parser]
pub fn property_expr_accept_on(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("accept_on")(s)?;
let (s, a) = keyword("accept_on")(s)?;
let (s, b) = paren(expression_or_dist)(s)?;
let (s, c) = property_expr(s)?;
Ok((
@ -1349,7 +1349,7 @@ pub fn property_expr_accept_on(s: Span) -> IResult<Span, PropertyExpr> {
#[parser]
pub fn property_expr_reject_on(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("reject_on")(s)?;
let (s, a) = keyword("reject_on")(s)?;
let (s, b) = paren(expression_or_dist)(s)?;
let (s, c) = property_expr(s)?;
Ok((
@ -1360,7 +1360,7 @@ pub fn property_expr_reject_on(s: Span) -> IResult<Span, PropertyExpr> {
#[parser]
pub fn property_expr_sync_accept_on(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("sync_accept_on")(s)?;
let (s, a) = keyword("sync_accept_on")(s)?;
let (s, b) = paren(expression_or_dist)(s)?;
let (s, c) = property_expr(s)?;
Ok((
@ -1371,7 +1371,7 @@ pub fn property_expr_sync_accept_on(s: Span) -> IResult<Span, PropertyExpr> {
#[parser]
pub fn property_expr_sync_reject_on(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = symbol("sync_reject_on")(s)?;
let (s, a) = keyword("sync_reject_on")(s)?;
let (s, b) = paren(expression_or_dist)(s)?;
let (s, c) = property_expr(s)?;
Ok((
@ -1411,7 +1411,7 @@ pub fn property_case_item_nondefault(s: Span) -> IResult<Span, PropertyCaseItem>
#[parser]
pub fn property_case_item_default(s: Span) -> IResult<Span, PropertyCaseItem> {
let (s, a) = symbol("default")(s)?;
let (s, a) = keyword("default")(s)?;
let (s, b) = opt(symbol(":"))(s)?;
let (s, c) = property_expr(s)?;
let (s, d) = symbol(";")(s)?;
@ -1425,14 +1425,14 @@ pub fn property_case_item_default(s: Span) -> IResult<Span, PropertyCaseItem> {
#[parser]
pub fn sequence_declaration(s: Span) -> IResult<Span, SequenceDeclaration> {
let (s, a) = symbol("sequence")(s)?;
let (s, a) = keyword("sequence")(s)?;
let (s, b) = sequence_identifier(s)?;
let (s, c) = opt(paren(opt(sequence_port_list)))(s)?;
let (s, d) = symbol(";")(s)?;
let (s, e) = many0(assertion_variable_declaration)(s)?;
let (s, f) = sequence_expr(s)?;
let (s, g) = opt(symbol(";"))(s)?;
let (s, h) = symbol("endsequence")(s)?;
let (s, h) = keyword("endsequence")(s)?;
let (s, i) = opt(pair(symbol(":"), sequence_identifier))(s)?;
Ok((
s,
@ -1467,9 +1467,9 @@ pub fn sequence_port_item(s: Span) -> IResult<Span, SequencePortItem> {
#[parser]
pub fn sequence_lvar_port_direction(s: Span) -> IResult<Span, SequenceLvarPortDirection> {
alt((
map(symbol("input"), |x| SequenceLvarPortDirection::Input(x)),
map(symbol("inout"), |x| SequenceLvarPortDirection::Inout(x)),
map(symbol("output"), |x| SequenceLvarPortDirection::Output(x)),
map(keyword("input"), |x| SequenceLvarPortDirection::Input(x)),
map(keyword("inout"), |x| SequenceLvarPortDirection::Inout(x)),
map(keyword("output"), |x| SequenceLvarPortDirection::Output(x)),
))(s)
}
@ -1479,8 +1479,8 @@ pub fn sequence_formal_type(s: Span) -> IResult<Span, SequenceFormalType> {
map(data_type_or_implicit, |x| {
SequenceFormalType::DataTypeOrImplicit(x)
}),
map(symbol("sequence"), |x| SequenceFormalType::Sequence(x)),
map(symbol("untyped"), |x| SequenceFormalType::Untyped(x)),
map(keyword("sequence"), |x| SequenceFormalType::Sequence(x)),
map(keyword("untyped"), |x| SequenceFormalType::Untyped(x)),
))(s)
}
@ -1563,7 +1563,7 @@ pub fn sequence_expr_paren(s: Span) -> IResult<Span, SequenceExpr> {
#[parser(MaybeRecursive)]
pub fn sequence_expr_and(s: Span) -> IResult<Span, SequenceExpr> {
let (s, a) = sequence_expr(s)?;
let (s, b) = symbol("and")(s)?;
let (s, b) = keyword("and")(s)?;
let (s, c) = sequence_expr(s)?;
Ok((
s,
@ -1574,7 +1574,7 @@ pub fn sequence_expr_and(s: Span) -> IResult<Span, SequenceExpr> {
#[parser(MaybeRecursive)]
pub fn sequence_expr_intersect(s: Span) -> IResult<Span, SequenceExpr> {
let (s, a) = sequence_expr(s)?;
let (s, b) = symbol("intersect")(s)?;
let (s, b) = keyword("intersect")(s)?;
let (s, c) = sequence_expr(s)?;
Ok((
s,
@ -1585,7 +1585,7 @@ pub fn sequence_expr_intersect(s: Span) -> IResult<Span, SequenceExpr> {
#[parser(MaybeRecursive)]
pub fn sequence_expr_or(s: Span) -> IResult<Span, SequenceExpr> {
let (s, a) = sequence_expr(s)?;
let (s, b) = symbol("or")(s)?;
let (s, b) = keyword("or")(s)?;
let (s, c) = sequence_expr(s)?;
Ok((
s,
@ -1595,7 +1595,7 @@ pub fn sequence_expr_or(s: Span) -> IResult<Span, SequenceExpr> {
#[parser]
pub fn sequence_expr_first_match(s: Span) -> IResult<Span, SequenceExpr> {
let (s, a) = symbol("first_match")(s)?;
let (s, a) = keyword("first_match")(s)?;
let (s, b) = paren(pair(
sequence_expr,
many0(pair(symbol(","), sequence_match_item)),
@ -1609,7 +1609,7 @@ pub fn sequence_expr_first_match(s: Span) -> IResult<Span, SequenceExpr> {
#[parser(MaybeRecursive)]
pub fn sequence_expr_throughout(s: Span) -> IResult<Span, SequenceExpr> {
let (s, a) = expression_or_dist(s)?;
let (s, b) = symbol("throughout")(s)?;
let (s, b) = keyword("throughout")(s)?;
let (s, c) = sequence_expr(s)?;
Ok((
s,
@ -1620,7 +1620,7 @@ pub fn sequence_expr_throughout(s: Span) -> IResult<Span, SequenceExpr> {
#[parser(MaybeRecursive)]
pub fn sequence_expr_within(s: Span) -> IResult<Span, SequenceExpr> {
let (s, a) = sequence_expr(s)?;
let (s, b) = symbol("within")(s)?;
let (s, b) = keyword("within")(s)?;
let (s, c) = sequence_expr(s)?;
Ok((
s,
@ -1881,7 +1881,7 @@ pub fn cycle_delay_const_range_expression_dollar(
#[parser(MaybeRecursive)]
pub fn expression_or_dist(s: Span) -> IResult<Span, ExpressionOrDist> {
let (s, a) = expression(s)?;
let (s, b) = opt(pair(symbol("dist"), brace(dist_list)))(s)?;
let (s, b) = opt(pair(keyword("dist"), brace(dist_list)))(s)?;
Ok((s, ExpressionOrDist { nodes: (a, b) }))
}

View File

@ -523,13 +523,13 @@ pub struct CovergroupExpression<'a> {
#[parser]
pub fn covergroup_declaration(s: Span) -> IResult<Span, CovergroupDeclaration> {
let (s, a) = symbol("covergroup")(s)?;
let (s, a) = keyword("covergroup")(s)?;
let (s, b) = covergroup_identifier(s)?;
let (s, c) = opt(paren(opt(tf_port_list)))(s)?;
let (s, d) = opt(coverage_event)(s)?;
let (s, e) = symbol(";")(s)?;
let (s, f) = many0(coverage_spec_or_option)(s)?;
let (s, g) = symbol("endgroup")(s)?;
let (s, g) = keyword("endgroup")(s)?;
let (s, h) = opt(pair(symbol(":"), covergroup_identifier))(s)?;
Ok((
s,
@ -572,7 +572,7 @@ pub fn coverage_option(s: Span) -> IResult<Span, CoverageOption> {
#[parser]
pub fn coverage_option_option(s: Span) -> IResult<Span, CoverageOption> {
let (s, a) = symbol("option")(s)?;
let (s, a) = keyword("option")(s)?;
let (s, b) = symbol(".")(s)?;
let (s, c) = member_identifier(s)?;
let (s, d) = symbol("=")(s)?;
@ -587,7 +587,7 @@ pub fn coverage_option_option(s: Span) -> IResult<Span, CoverageOption> {
#[parser]
pub fn coverage_option_type_option(s: Span) -> IResult<Span, CoverageOption> {
let (s, a) = symbol("type_option")(s)?;
let (s, a) = keyword("type_option")(s)?;
let (s, b) = symbol(".")(s)?;
let (s, c) = member_identifier(s)?;
let (s, d) = symbol("=")(s)?;
@ -619,9 +619,9 @@ pub fn coverage_event(s: Span) -> IResult<Span, CoverageEvent> {
#[parser]
pub fn coverage_event_sample(s: Span) -> IResult<Span, CoverageEvent> {
let (s, a) = symbol("with")(s)?;
let (s, b) = symbol("function")(s)?;
let (s, c) = symbol("sample")(s)?;
let (s, a) = keyword("with")(s)?;
let (s, b) = keyword("function")(s)?;
let (s, c) = keyword("sample")(s)?;
let (s, d) = paren(opt(tf_port_list))(s)?;
Ok((
s,
@ -650,7 +650,7 @@ pub fn block_event_expression(s: Span) -> IResult<Span, BlockEventExpression> {
#[parser(MaybeRecursive)]
pub fn block_event_expression_or(s: Span) -> IResult<Span, BlockEventExpression> {
let (s, a) = block_event_expression(s)?;
let (s, b) = symbol("or")(s)?;
let (s, b) = keyword("or")(s)?;
let (s, c) = block_event_expression(s)?;
Ok((
s,
@ -660,7 +660,7 @@ pub fn block_event_expression_or(s: Span) -> IResult<Span, BlockEventExpression>
#[parser]
pub fn block_event_expression_begin(s: Span) -> IResult<Span, BlockEventExpression> {
let (s, a) = symbol("begin")(s)?;
let (s, a) = keyword("begin")(s)?;
let (s, b) = hierarchical_btf_identifier(s)?;
Ok((
s,
@ -670,7 +670,7 @@ pub fn block_event_expression_begin(s: Span) -> IResult<Span, BlockEventExpressi
#[parser]
pub fn block_event_expression_end(s: Span) -> IResult<Span, BlockEventExpression> {
let (s, a) = symbol("end")(s)?;
let (s, a) = keyword("end")(s)?;
let (s, b) = hierarchical_btf_identifier(s)?;
Ok((
s,
@ -722,9 +722,9 @@ pub fn cover_point(s: Span) -> IResult<Span, CoverPoint> {
cover_point_identifier,
symbol(":"),
))(s)?;
let (s, b) = symbol("coverpoint")(s)?;
let (s, b) = keyword("coverpoint")(s)?;
let (s, c) = expression(s)?;
let (s, d) = opt(pair(symbol("iff"), paren(expression)))(s)?;
let (s, d) = opt(pair(keyword("iff"), paren(expression)))(s)?;
let (s, e) = bins_or_empty(s)?;
Ok((
s,
@ -775,8 +775,8 @@ pub fn bins_or_options_covergroup(s: Span) -> IResult<Span, BinsOrOptions> {
let (s, d) = opt(bracket(opt(covergroup_expression)))(s)?;
let (s, e) = symbol("=")(s)?;
let (s, f) = brace(covergroup_range_list)(s)?;
let (s, g) = opt(pair(symbol("with"), paren(with_covergroup_expression)))(s)?;
let (s, h) = opt(pair(symbol("iff"), paren(expression)))(s)?;
let (s, g) = opt(pair(keyword("with"), paren(with_covergroup_expression)))(s)?;
let (s, h) = opt(pair(keyword("iff"), paren(expression)))(s)?;
Ok((
s,
BinsOrOptions::Covergroup(BinsOrOptionsCovergroup {
@ -787,7 +787,7 @@ pub fn bins_or_options_covergroup(s: Span) -> IResult<Span, BinsOrOptions> {
#[parser]
pub fn wildcard(s: Span) -> IResult<Span, Wildcard> {
let (s, a) = symbol("wildcard")(s)?;
let (s, a) = keyword("wildcard")(s)?;
Ok((s, Wildcard { nodes: (a,) }))
}
@ -799,9 +799,9 @@ pub fn bins_or_options_cover_point(s: Span) -> IResult<Span, BinsOrOptions> {
let (s, d) = opt(bracket(opt(covergroup_expression)))(s)?;
let (s, e) = symbol("=")(s)?;
let (s, f) = cover_point_identifier(s)?;
let (s, g) = symbol("with")(s)?;
let (s, g) = keyword("with")(s)?;
let (s, h) = paren(with_covergroup_expression)(s)?;
let (s, i) = opt(pair(symbol("iff"), paren(expression)))(s)?;
let (s, i) = opt(pair(keyword("iff"), paren(expression)))(s)?;
Ok((
s,
BinsOrOptions::CoverPoint(BinsOrOptionsCoverPoint {
@ -818,7 +818,7 @@ pub fn bins_or_options_set_covergroup(s: Span) -> IResult<Span, BinsOrOptions> {
let (s, d) = opt(bracket(opt(covergroup_expression)))(s)?;
let (s, e) = symbol("=")(s)?;
let (s, f) = set_covergroup_expression(s)?;
let (s, g) = opt(pair(symbol("iff"), paren(expression)))(s)?;
let (s, g) = opt(pair(keyword("iff"), paren(expression)))(s)?;
Ok((
s,
BinsOrOptions::SetCovergroup(BinsOrOptionsSetCovergroup {
@ -835,7 +835,7 @@ pub fn bins_or_options_trans_list(s: Span) -> IResult<Span, BinsOrOptions> {
let (s, d) = opt(pair(symbol("["), symbol("]")))(s)?;
let (s, e) = symbol("=")(s)?;
let (s, f) = trans_list(s)?;
let (s, g) = opt(pair(symbol("iff"), paren(expression)))(s)?;
let (s, g) = opt(pair(keyword("iff"), paren(expression)))(s)?;
Ok((
s,
BinsOrOptions::TransList(BinsOrOptionsTransList {
@ -850,8 +850,8 @@ pub fn bins_or_options_default(s: Span) -> IResult<Span, BinsOrOptions> {
let (s, b) = bin_identifier(s)?;
let (s, c) = opt(bracket(opt(covergroup_expression)))(s)?;
let (s, d) = symbol("=")(s)?;
let (s, e) = symbol("default")(s)?;
let (s, f) = opt(pair(symbol("iff"), paren(expression)))(s)?;
let (s, e) = keyword("default")(s)?;
let (s, f) = opt(pair(keyword("iff"), paren(expression)))(s)?;
Ok((
s,
BinsOrOptions::Default(BinsOrOptionsDefault {
@ -865,9 +865,9 @@ pub fn bins_or_options_default_sequence(s: Span) -> IResult<Span, BinsOrOptions>
let (s, a) = bins_keyword(s)?;
let (s, b) = bin_identifier(s)?;
let (s, c) = symbol("=")(s)?;
let (s, d) = symbol("default")(s)?;
let (s, e) = symbol("sequence")(s)?;
let (s, f) = opt(pair(symbol("iff"), paren(expression)))(s)?;
let (s, d) = keyword("default")(s)?;
let (s, e) = keyword("sequence")(s)?;
let (s, f) = opt(pair(keyword("iff"), paren(expression)))(s)?;
Ok((
s,
BinsOrOptions::DefaultSequence(BinsOrOptionsDefaultSequence {
@ -879,9 +879,9 @@ pub fn bins_or_options_default_sequence(s: Span) -> IResult<Span, BinsOrOptions>
#[parser]
pub fn bins_keyword(s: Span) -> IResult<Span, BinsKeyword> {
alt((
map(symbol("bins"), |x| BinsKeyword::Bins(x)),
map(symbol("illegal_bins"), |x| BinsKeyword::IllegalBins(x)),
map(symbol("ignore_bins"), |x| BinsKeyword::IgnoreBins(x)),
map(keyword("bins"), |x| BinsKeyword::Bins(x)),
map(keyword("illegal_bins"), |x| BinsKeyword::IllegalBins(x)),
map(keyword("ignore_bins"), |x| BinsKeyword::IgnoreBins(x)),
))(s)
}
@ -967,9 +967,9 @@ pub fn repeat_range_binary(s: Span) -> IResult<Span, RepeatRange> {
#[parser]
pub fn cover_cross(s: Span) -> IResult<Span, CoverCross> {
let (s, a) = opt(pair(cross_identifier, symbol(":")))(s)?;
let (s, b) = symbol("cross")(s)?;
let (s, b) = keyword("cross")(s)?;
let (s, c) = list_of_cross_items(s)?;
let (s, d) = opt(pair(symbol("iff"), paren(expression)))(s)?;
let (s, d) = opt(pair(keyword("iff"), paren(expression)))(s)?;
let (s, e) = cross_body(s)?;
Ok((
s,
@ -1056,7 +1056,7 @@ pub fn bins_selection(s: Span) -> IResult<Span, BinsSelection> {
let (s, b) = bin_identifier(s)?;
let (s, c) = symbol("=")(s)?;
let (s, d) = select_expression(s)?;
let (s, e) = opt(pair(symbol("iff"), paren(expression)))(s)?;
let (s, e) = opt(pair(keyword("iff"), paren(expression)))(s)?;
Ok((
s,
BinsSelection {
@ -1123,9 +1123,9 @@ pub fn select_expression_paren(s: Span) -> IResult<Span, SelectExpression> {
#[parser(MaybeRecursive)]
pub fn select_expression_with(s: Span) -> IResult<Span, SelectExpression> {
let (s, a) = select_expression(s)?;
let (s, b) = symbol("with")(s)?;
let (s, b) = keyword("with")(s)?;
let (s, c) = paren(with_covergroup_expression)(s)?;
let (s, d) = opt(pair(symbol("matches"), integer_covergroup_expression))(s)?;
let (s, d) = opt(pair(keyword("matches"), integer_covergroup_expression))(s)?;
Ok((
s,
SelectExpression::With(Box::new(SelectExpressionWith {
@ -1137,7 +1137,7 @@ pub fn select_expression_with(s: Span) -> IResult<Span, SelectExpression> {
#[parser(MaybeRecursive)]
pub fn select_expression_cross_set(s: Span) -> IResult<Span, SelectExpression> {
let (s, a) = cross_set_expression(s)?;
let (s, b) = opt(pair(symbol("matches"), integer_covergroup_expression))(s)?;
let (s, b) = opt(pair(keyword("matches"), integer_covergroup_expression))(s)?;
Ok((
s,
SelectExpression::CrossSet(SelectExpressionCrossSet { nodes: (a, b) }),
@ -1146,9 +1146,9 @@ pub fn select_expression_cross_set(s: Span) -> IResult<Span, SelectExpression> {
#[parser]
pub fn select_condition(s: Span) -> IResult<Span, SelectCondition> {
let (s, a) = symbol("binsof")(s)?;
let (s, a) = keyword("binsof")(s)?;
let (s, b) = paren(bins_expression)(s)?;
let (s, c) = opt(pair(symbol("intersect"), brace(covergroup_range_list)))(s)?;
let (s, c) = opt(pair(keyword("intersect"), brace(covergroup_range_list)))(s)?;
Ok((s, SelectCondition { nodes: (a, b, c) }))
}

View File

@ -339,14 +339,14 @@ pub fn class_new(s: Span) -> IResult<Span, ClassNew> {
#[parser]
pub fn class_new_argument(s: Span) -> IResult<Span, ClassNew> {
let (s, a) = opt(class_scope)(s)?;
let (s, b) = symbol("new")(s)?;
let (s, b) = keyword("new")(s)?;
let (s, c) = opt(paren(list_of_arguments))(s)?;
Ok((s, ClassNew::Argument(ClassNewArgument { nodes: (a, b, c) })))
}
#[parser]
pub fn class_new_expression(s: Span) -> IResult<Span, ClassNew> {
let (s, a) = symbol("new")(s)?;
let (s, a) = keyword("new")(s)?;
let (s, b) = expression(s)?;
Ok((
s,
@ -356,7 +356,7 @@ pub fn class_new_expression(s: Span) -> IResult<Span, ClassNew> {
#[parser]
pub fn dynamic_array_new(s: Span) -> IResult<Span, DynamicArrayNew> {
let (s, a) = symbol("new")(s)?;
let (s, a) = keyword("new")(s)?;
let (s, b) = bracket(expression)(s)?;
let (s, c) = opt(paren(expression))(s)?;
Ok((s, DynamicArrayNew { nodes: (a, b, c) }))

View File

@ -127,6 +127,6 @@ pub fn delay_value(s: Span) -> IResult<Span, DelayValue> {
map(real_number, |x| DelayValue::RealNumber(x)),
map(ps_identifier, |x| DelayValue::PsIdentifier(x)),
map(time_literal, |x| DelayValue::TimeLiteral(x)),
map(symbol("1step"), |x| DelayValue::Step1(x)),
map(keyword("1step"), |x| DelayValue::Step1(x)),
))(s)
}

View File

@ -173,7 +173,7 @@ pub fn function_data_type_or_implicit(s: Span) -> IResult<Span, FunctionDataType
#[parser]
pub fn function_declaration(s: Span) -> IResult<Span, FunctionDeclaration> {
let (s, a) = symbol("function")(s)?;
let (s, a) = keyword("function")(s)?;
let (s, b) = opt(lifetime)(s)?;
let (s, c) = function_body_declaration(s)?;
Ok((s, FunctionDeclaration { nodes: (a, b, c) }))
@ -195,7 +195,7 @@ pub fn function_body_declaration_without_port(s: Span) -> IResult<Span, Function
let (s, d) = symbol(";")(s)?;
let (s, e) = many0(tf_item_declaration)(s)?;
let (s, f) = many0(function_statement_or_null)(s)?;
let (s, g) = symbol("endfunction")(s)?;
let (s, g) = keyword("endfunction")(s)?;
let (s, h) = opt(pair(symbol(":"), function_identifier))(s)?;
Ok((
s,
@ -214,7 +214,7 @@ pub fn function_body_declaration_with_port(s: Span) -> IResult<Span, FunctionBod
let (s, e) = symbol(";")(s)?;
let (s, f) = many0(block_item_declaration)(s)?;
let (s, g) = many0(function_statement_or_null)(s)?;
let (s, h) = symbol("endfunction")(s)?;
let (s, h) = keyword("endfunction")(s)?;
let (s, i) = opt(pair(symbol(":"), function_identifier))(s)?;
Ok((
s,
@ -240,7 +240,7 @@ pub fn interface_identifier_or_class_scope(
#[parser]
pub fn function_prototype(s: Span) -> IResult<Span, FunctionPrototype> {
let (s, a) = symbol("function")(s)?;
let (s, a) = keyword("function")(s)?;
let (s, b) = data_type_or_void(s)?;
let (s, c) = function_identifier(s)?;
let (s, d) = opt(paren(opt(tf_port_list)))(s)?;
@ -264,7 +264,7 @@ pub fn dpi_import_export(s: Span) -> IResult<Span, DpiImportExport> {
#[parser]
pub fn dpi_import_export_import_function(s: Span) -> IResult<Span, DpiImportExport> {
let (s, a) = symbol("import")(s)?;
let (s, a) = keyword("import")(s)?;
let (s, b) = dpi_spec_string(s)?;
let (s, c) = opt(dpi_function_import_property)(s)?;
let (s, d) = opt(pair(c_identifier, symbol("=")))(s)?;
@ -280,7 +280,7 @@ pub fn dpi_import_export_import_function(s: Span) -> IResult<Span, DpiImportExpo
#[parser]
pub fn dpi_import_export_import_task(s: Span) -> IResult<Span, DpiImportExport> {
let (s, a) = symbol("import")(s)?;
let (s, a) = keyword("import")(s)?;
let (s, b) = dpi_spec_string(s)?;
let (s, c) = opt(dpi_task_import_property)(s)?;
let (s, d) = opt(pair(c_identifier, symbol("=")))(s)?;
@ -296,10 +296,10 @@ pub fn dpi_import_export_import_task(s: Span) -> IResult<Span, DpiImportExport>
#[parser]
pub fn dpi_import_export_export_function(s: Span) -> IResult<Span, DpiImportExport> {
let (s, a) = symbol("export")(s)?;
let (s, a) = keyword("export")(s)?;
let (s, b) = dpi_spec_string(s)?;
let (s, c) = opt(pair(c_identifier, symbol("=")))(s)?;
let (s, d) = symbol("function")(s)?;
let (s, d) = keyword("function")(s)?;
let (s, e) = function_identifier(s)?;
let (s, f) = symbol(";")(s)?;
Ok((
@ -312,10 +312,10 @@ pub fn dpi_import_export_export_function(s: Span) -> IResult<Span, DpiImportExpo
#[parser]
pub fn dpi_import_export_export_task(s: Span) -> IResult<Span, DpiImportExport> {
let (s, a) = symbol("export")(s)?;
let (s, a) = keyword("export")(s)?;
let (s, b) = dpi_spec_string(s)?;
let (s, c) = opt(pair(c_identifier, symbol("=")))(s)?;
let (s, d) = symbol("task")(s)?;
let (s, d) = keyword("task")(s)?;
let (s, e) = task_identifier(s)?;
let (s, f) = symbol(";")(s)?;
Ok((
@ -329,22 +329,24 @@ pub fn dpi_import_export_export_task(s: Span) -> IResult<Span, DpiImportExport>
#[parser]
pub fn dpi_spec_string(s: Span) -> IResult<Span, DpiSpecString> {
alt((
map(symbol("DPI-C"), |x| DpiSpecString::DpiC(x)),
map(symbol("DPI"), |x| DpiSpecString::Dpi(x)),
map(keyword("DPI-C"), |x| DpiSpecString::DpiC(x)),
map(keyword("DPI"), |x| DpiSpecString::Dpi(x)),
))(s)
}
#[parser]
pub fn dpi_function_import_property(s: Span) -> IResult<Span, DpiFunctionImportProperty> {
alt((
map(symbol("context"), |x| DpiFunctionImportProperty::Context(x)),
map(symbol("pure"), |x| DpiFunctionImportProperty::Pure(x)),
map(keyword("context"), |x| {
DpiFunctionImportProperty::Context(x)
}),
map(keyword("pure"), |x| DpiFunctionImportProperty::Pure(x)),
))(s)
}
#[parser]
pub fn dpi_task_import_property(s: Span) -> IResult<Span, DpiTaskImportProperty> {
let (s, a) = symbol("context")(s)?;
let (s, a) = keyword("context")(s)?;
Ok((s, DpiTaskImportProperty::Context(a)))
}

View File

@ -96,7 +96,7 @@ pub enum ImportExport<'a> {
#[parser]
pub fn modport_declaration(s: Span) -> IResult<Span, ModportDeclaration> {
let (s, a) = symbol("modport")(s)?;
let (s, a) = keyword("modport")(s)?;
let (s, b) = list(symbol(","), modport_item)(s)?;
let (s, c) = symbol(";")(s)?;
Ok((s, ModportDeclaration { nodes: (a, b, c) }))
@ -150,7 +150,7 @@ pub fn modport_ports_declaration_clocking(s: Span) -> IResult<Span, ModportPorts
#[parser]
pub fn modport_clocking_declaration(s: Span) -> IResult<Span, ModportClockingDeclaration> {
let (s, a) = symbol("clocking")(s)?;
let (s, a) = keyword("clocking")(s)?;
let (s, b) = clocking_identifier(s)?;
Ok((s, ModportClockingDeclaration { nodes: (a, b) }))
}
@ -205,7 +205,7 @@ pub fn modport_tf_port(s: Span) -> IResult<Span, ModportTfPort> {
#[parser]
pub fn import_export(s: Span) -> IResult<Span, ImportExport> {
alt((
map(symbol("import"), |x| ImportExport::Import(x)),
map(symbol("export"), |x| ImportExport::Export(x)),
map(keyword("import"), |x| ImportExport::Import(x)),
map(keyword("export"), |x| ImportExport::Export(x)),
))(s)
}

View File

@ -98,7 +98,7 @@ pub struct LetActualArg<'a> {
#[parser]
pub fn let_declaration(s: Span) -> IResult<Span, LetDeclaration> {
let (s, a) = symbol("let")(s)?;
let (s, a) = keyword("let")(s)?;
let (s, b) = let_identifier(s)?;
let (s, c) = opt(paren(opt(let_port_list)))(s)?;
let (s, d) = symbol("=")(s)?;
@ -145,7 +145,7 @@ pub fn let_formal_type(s: Span) -> IResult<Span, LetFormalType> {
map(data_type_or_implicit, |x| {
LetFormalType::DataTypeOrImplicit(x)
}),
map(symbol("untyped"), |x| LetFormalType::Untyped(x)),
map(keyword("untyped"), |x| LetFormalType::Untyped(x)),
))(s)
}

View File

@ -68,7 +68,7 @@ pub fn local_parameter_declaration(s: Span) -> IResult<Span, LocalParameterDecla
#[parser(Ambiguous)]
pub fn local_parameter_declaration_param(s: Span) -> IResult<Span, LocalParameterDeclaration> {
let (s, a) = symbol("localparam")(s)?;
let (s, a) = keyword("localparam")(s)?;
let (s, b) = ambiguous_opt(data_type_or_implicit)(s)?;
let (s, c) = list_of_param_assignments(s)?;
Ok((
@ -79,8 +79,8 @@ pub fn local_parameter_declaration_param(s: Span) -> IResult<Span, LocalParamete
#[parser]
pub fn local_parameter_declaration_type(s: Span) -> IResult<Span, LocalParameterDeclaration> {
let (s, a) = symbol("localparam")(s)?;
let (s, b) = symbol("type")(s)?;
let (s, a) = keyword("localparam")(s)?;
let (s, b) = keyword("type")(s)?;
let (s, c) = list_of_type_assignments(s)?;
Ok((
s,
@ -95,7 +95,7 @@ pub fn parameter_declaration(s: Span) -> IResult<Span, ParameterDeclaration> {
#[parser(Ambiguous)]
pub fn parameter_declaration_param(s: Span) -> IResult<Span, ParameterDeclaration> {
let (s, a) = symbol("parameter")(s)?;
let (s, a) = keyword("parameter")(s)?;
let (s, b) = ambiguous_opt(data_type_or_implicit)(s)?;
let (s, c) = list_of_param_assignments(s)?;
Ok((
@ -106,8 +106,8 @@ pub fn parameter_declaration_param(s: Span) -> IResult<Span, ParameterDeclaratio
#[parser]
pub fn parameter_declaration_type(s: Span) -> IResult<Span, ParameterDeclaration> {
let (s, a) = symbol("parameter")(s)?;
let (s, b) = symbol("type")(s)?;
let (s, a) = keyword("parameter")(s)?;
let (s, b) = keyword("type")(s)?;
let (s, c) = list_of_type_assignments(s)?;
Ok((
s,
@ -117,7 +117,7 @@ pub fn parameter_declaration_type(s: Span) -> IResult<Span, ParameterDeclaration
#[parser]
pub fn specparam_declaration(s: Span) -> IResult<Span, SpecparamDeclaration> {
let (s, a) = symbol("specparam")(s)?;
let (s, a) = keyword("specparam")(s)?;
let (s, b) = opt(packed_dimension)(s)?;
let (s, c) = list_of_specparam_assignments(s)?;
let (s, d) = symbol(";")(s)?;

View File

@ -305,8 +305,8 @@ pub fn casting_type(s: Span) -> IResult<Span, CastingType> {
CastingType::ConstantPrimary(Box::new(x))
}),
map(signing, |x| CastingType::Signing(Box::new(x))),
map(symbol("string"), |x| CastingType::String(x)),
map(symbol("const"), |x| CastingType::Const(x)),
map(keyword("string"), |x| CastingType::String(x)),
map(keyword("const"), |x| CastingType::Const(x)),
))(s)
}
@ -318,12 +318,12 @@ pub fn data_type(s: Span) -> IResult<Span, DataType> {
map(non_integer_type, |x| DataType::NonIntegerType(x)),
data_type_union,
data_type_enum,
map(symbol("string"), |x| DataType::String(x)),
map(symbol("chandle"), |x| DataType::Chandle(x)),
map(keyword("string"), |x| DataType::String(x)),
map(keyword("chandle"), |x| DataType::Chandle(x)),
data_type_virtual,
data_type_type,
map(class_type, |x| DataType::ClassType(x)),
map(symbol("event"), |x| DataType::Chandle(x)),
map(keyword("event"), |x| DataType::Chandle(x)),
map(ps_covergroup_identifier, |x| {
DataType::PsCovergroupIdentifier(x)
}),
@ -362,13 +362,13 @@ pub fn data_type_union(s: Span) -> IResult<Span, DataType> {
#[parser]
pub fn packed(s: Span) -> IResult<Span, Packed> {
let (s, a) = symbol("packed")(s)?;
let (s, a) = keyword("packed")(s)?;
Ok((s, Packed { nodes: (a,) }))
}
#[parser]
pub fn data_type_enum(s: Span) -> IResult<Span, DataType> {
let (s, a) = symbol("enum")(s)?;
let (s, a) = keyword("enum")(s)?;
let (s, b) = opt(enum_base_type)(s)?;
let (s, c) = brace(list(symbol(","), enum_name_declaration))(s)?;
let (s, d) = many0(packed_dimension)(s)?;
@ -382,7 +382,7 @@ pub fn data_type_enum(s: Span) -> IResult<Span, DataType> {
#[parser]
pub fn data_type_virtual(s: Span) -> IResult<Span, DataType> {
let (s, a) = symbol("virtual")(s)?;
let (s, a) = keyword("virtual")(s)?;
let (s, b) = opt(interface)(s)?;
let (s, c) = interface_identifier(s)?;
let (s, d) = opt(parameter_value_assignment)(s)?;
@ -397,7 +397,7 @@ pub fn data_type_virtual(s: Span) -> IResult<Span, DataType> {
#[parser]
pub fn interface(s: Span) -> IResult<Span, Interface> {
let (s, a) = symbol("interface")(s)?;
let (s, a) = keyword("interface")(s)?;
Ok((s, Interface { nodes: (a,) }))
}
@ -501,48 +501,48 @@ pub fn integer_type(s: Span) -> IResult<Span, IntegerType> {
#[parser]
pub fn integer_atom_type(s: Span) -> IResult<Span, IntegerAtomType> {
alt((
map(symbol("byte"), |x| IntegerAtomType::Byte(x)),
map(symbol("shortint"), |x| IntegerAtomType::Shortint(x)),
map(symbol("int"), |x| IntegerAtomType::Int(x)),
map(symbol("longint"), |x| IntegerAtomType::Longint(x)),
map(symbol("integer"), |x| IntegerAtomType::Integer(x)),
map(symbol("time"), |x| IntegerAtomType::Time(x)),
map(keyword("byte"), |x| IntegerAtomType::Byte(x)),
map(keyword("shortint"), |x| IntegerAtomType::Shortint(x)),
map(keyword("int"), |x| IntegerAtomType::Int(x)),
map(keyword("longint"), |x| IntegerAtomType::Longint(x)),
map(keyword("integer"), |x| IntegerAtomType::Integer(x)),
map(keyword("time"), |x| IntegerAtomType::Time(x)),
))(s)
}
#[parser]
pub fn integer_vector_type(s: Span) -> IResult<Span, IntegerVectorType> {
alt((
map(symbol("bit"), |x| IntegerVectorType::Bit(x)),
map(symbol("logic"), |x| IntegerVectorType::Logic(x)),
map(symbol("reg"), |x| IntegerVectorType::Reg(x)),
map(keyword("bit"), |x| IntegerVectorType::Bit(x)),
map(keyword("logic"), |x| IntegerVectorType::Logic(x)),
map(keyword("reg"), |x| IntegerVectorType::Reg(x)),
))(s)
}
#[parser]
pub fn non_integer_type(s: Span) -> IResult<Span, NonIntegerType> {
alt((
map(symbol("shortreal"), |x| NonIntegerType::Shortreal(x)),
map(symbol("realtime"), |x| NonIntegerType::Realtime(x)),
map(symbol("real"), |x| NonIntegerType::Real(x)),
map(keyword("shortreal"), |x| NonIntegerType::Shortreal(x)),
map(keyword("realtime"), |x| NonIntegerType::Realtime(x)),
map(keyword("real"), |x| NonIntegerType::Real(x)),
))(s)
}
#[parser]
pub fn net_type(s: Span) -> IResult<Span, NetType> {
alt((
map(symbol("supply0"), |x| NetType::Supply0(x)),
map(symbol("supply1"), |x| NetType::Supply1(x)),
map(symbol("triand"), |x| NetType::Triand(x)),
map(symbol("trior"), |x| NetType::Trior(x)),
map(symbol("trireg"), |x| NetType::Trireg(x)),
map(symbol("tri0"), |x| NetType::Tri0(x)),
map(symbol("tri1"), |x| NetType::Tri1(x)),
map(symbol("tri"), |x| NetType::Tri(x)),
map(symbol("uwire"), |x| NetType::Uwire(x)),
map(symbol("wire"), |x| NetType::Wire(x)),
map(symbol("wand"), |x| NetType::Wand(x)),
map(symbol("wor"), |x| NetType::Wor(x)),
map(keyword("supply0"), |x| NetType::Supply0(x)),
map(keyword("supply1"), |x| NetType::Supply1(x)),
map(keyword("triand"), |x| NetType::Triand(x)),
map(keyword("trior"), |x| NetType::Trior(x)),
map(keyword("trireg"), |x| NetType::Trireg(x)),
map(keyword("tri0"), |x| NetType::Tri0(x)),
map(keyword("tri1"), |x| NetType::Tri1(x)),
map(keyword("tri"), |x| NetType::Tri(x)),
map(keyword("uwire"), |x| NetType::Uwire(x)),
map(keyword("wire"), |x| NetType::Wire(x)),
map(keyword("wand"), |x| NetType::Wand(x)),
map(keyword("wor"), |x| NetType::Wor(x)),
))(s)
}
@ -567,7 +567,7 @@ pub fn net_port_type_data_type(s: Span) -> IResult<Span, NetPortType> {
#[parser]
pub fn net_port_type_interconnect(s: Span) -> IResult<Span, NetPortType> {
let (s, a) = symbol("interconnect")(s)?;
let (s, a) = keyword("interconnect")(s)?;
let (s, b) = implicit_data_type(s)?;
Ok((
s,
@ -591,7 +591,7 @@ pub fn var_data_type(s: Span) -> IResult<Span, VarDataType> {
#[parser]
pub fn var_data_type_var(s: Span) -> IResult<Span, VarDataType> {
let (s, a) = symbol("var")(s)?;
let (s, a) = keyword("var")(s)?;
let (s, b) = data_type_or_implicit(s)?;
Ok((s, VarDataType::Var(VarDataTypeVar { nodes: (a, b) })))
}
@ -599,8 +599,8 @@ pub fn var_data_type_var(s: Span) -> IResult<Span, VarDataType> {
#[parser]
pub fn signing(s: Span) -> IResult<Span, Signing> {
alt((
map(symbol("signed"), |x| Signing::Signed(x)),
map(symbol("unsigned"), |x| Signing::Unsigned(x)),
map(keyword("signed"), |x| Signing::Signed(x)),
map(keyword("unsigned"), |x| Signing::Unsigned(x)),
))(s)
}
@ -635,18 +635,18 @@ pub fn struct_union_member(s: Span) -> IResult<Span, StructUnionMember> {
pub fn data_type_or_void(s: Span) -> IResult<Span, DataTypeOrVoid> {
alt((
map(data_type, |x| DataTypeOrVoid::DataType(x)),
map(symbol("void"), |x| DataTypeOrVoid::Void(x)),
map(keyword("void"), |x| DataTypeOrVoid::Void(x)),
))(s)
}
#[parser]
pub fn struct_union(s: Span) -> IResult<Span, StructUnion> {
alt((
map(symbol("struct"), |x| StructUnion::Struct(x)),
map(pair(symbol("union"), symbol("tagged")), |x| {
map(keyword("struct"), |x| StructUnion::Struct(x)),
map(pair(keyword("union"), keyword("tagged")), |x| {
StructUnion::UnionTagged(x)
}),
map(symbol("union"), |x| StructUnion::Union(x)),
map(keyword("union"), |x| StructUnion::Union(x)),
))(s)
}
@ -657,7 +657,7 @@ pub fn type_reference(s: Span) -> IResult<Span, TypeReference> {
#[parser]
pub fn type_reference_expression(s: Span) -> IResult<Span, TypeReference> {
let (s, a) = symbol("type")(s)?;
let (s, a) = keyword("type")(s)?;
let (s, b) = paren(expression)(s)?;
Ok((
s,
@ -667,7 +667,7 @@ pub fn type_reference_expression(s: Span) -> IResult<Span, TypeReference> {
#[parser]
pub fn type_reference_data_type(s: Span) -> IResult<Span, TypeReference> {
let (s, a) = symbol("type")(s)?;
let (s, a) = keyword("type")(s)?;
let (s, b) = paren(data_type)(s)?;
Ok((
s,

View File

@ -86,7 +86,7 @@ pub struct RefDeclaration<'a> {
#[parser(Ambiguous)]
pub fn inout_declaration(s: Span) -> IResult<Span, InoutDeclaration> {
let (s, a) = symbol("inout")(s)?;
let (s, a) = keyword("inout")(s)?;
let (s, b) = ambiguous_opt(net_port_type)(s)?;
let (s, c) = list_of_port_identifiers(s)?;
Ok((s, InoutDeclaration { nodes: (a, b, c) }))
@ -99,7 +99,7 @@ pub fn input_declaration(s: Span) -> IResult<Span, InputDeclaration> {
#[parser(Ambiguous)]
pub fn input_declaration_net(s: Span) -> IResult<Span, InputDeclaration> {
let (s, a) = symbol("input")(s)?;
let (s, a) = keyword("input")(s)?;
let (s, b) = ambiguous_opt(net_port_type)(s)?;
let (s, c) = list_of_port_identifiers(s)?;
Ok((
@ -108,10 +108,10 @@ pub fn input_declaration_net(s: Span) -> IResult<Span, InputDeclaration> {
))
}
#[parser]
#[parser(Ambiguous)]
pub fn input_declaration_variable(s: Span) -> IResult<Span, InputDeclaration> {
let (s, a) = symbol("input")(s)?;
let (s, b) = variable_port_type(s)?;
let (s, a) = keyword("input")(s)?;
let (s, b) = ambiguous_alt(variable_port_type, implicit_var)(s)?;
let (s, c) = list_of_variable_identifiers(s)?;
Ok((
s,
@ -126,7 +126,7 @@ pub fn output_declaration(s: Span) -> IResult<Span, OutputDeclaration> {
#[parser(Ambiguous)]
pub fn output_declaration_net(s: Span) -> IResult<Span, OutputDeclaration> {
let (s, a) = symbol("output")(s)?;
let (s, a) = keyword("output")(s)?;
let (s, b) = ambiguous_opt(net_port_type)(s)?;
let (s, c) = list_of_port_identifiers(s)?;
Ok((
@ -135,10 +135,10 @@ pub fn output_declaration_net(s: Span) -> IResult<Span, OutputDeclaration> {
))
}
#[parser]
#[parser(Ambiguous)]
pub fn output_declaration_variable(s: Span) -> IResult<Span, OutputDeclaration> {
let (s, a) = symbol("output")(s)?;
let (s, b) = variable_port_type(s)?;
let (s, a) = keyword("output")(s)?;
let (s, b) = ambiguous_alt(variable_port_type, implicit_var)(s)?;
let (s, c) = list_of_variable_identifiers(s)?;
Ok((
s,
@ -154,14 +154,32 @@ pub fn interface_port_declaration(s: Span) -> IResult<Span, InterfacePortDeclara
Ok((s, InterfacePortDeclaration { nodes: (a, b, c) }))
}
#[parser]
#[parser(Ambiguous)]
pub fn ref_declaration(s: Span) -> IResult<Span, RefDeclaration> {
let (s, a) = symbol("ref")(s)?;
let (s, b) = variable_port_type(s)?;
let (s, a) = keyword("ref")(s)?;
let (s, b) = ambiguous_alt(variable_port_type, implicit_var)(s)?;
let (s, c) = list_of_variable_identifiers(s)?;
Ok((s, RefDeclaration { nodes: (a, b, c) }))
}
#[parser]
pub fn implicit_var(s: Span) -> IResult<Span, VariablePortType> {
let (s, a) = keyword("var")(s)?;
Ok((
s,
VariablePortType {
nodes: (VarDataType::Var(VarDataTypeVar {
nodes: (
a,
DataTypeOrImplicit::ImplicitDataType(ImplicitDataType {
nodes: (None, vec![]),
}),
),
}),),
},
))
}
// -----------------------------------------------------------------------------
#[cfg(test)]
@ -173,6 +191,5 @@ mod tests {
parser_test!(inout_declaration, "inout a", Ok((_, _)));
parser_test!(inout_declaration, "inout [7:0] a", Ok((_, _)));
parser_test!(inout_declaration, "inout signed [7:0] a", Ok((_, _)));
parser_test!(inout_declaration, "inout var a", Ok((_, _)));
}
}

View File

@ -118,7 +118,7 @@ pub fn drive_strength10(s: Span) -> IResult<Span, DriveStrength> {
#[parser]
pub fn drive_strength0z(s: Span) -> IResult<Span, DriveStrength> {
let (s, a) = paren(triple(strength0, symbol(","), symbol("highz1")))(s)?;
let (s, a) = paren(triple(strength0, symbol(","), keyword("highz1")))(s)?;
Ok((
s,
DriveStrength::Strength0z(DriveStrength0z { nodes: (a,) }),
@ -127,7 +127,7 @@ pub fn drive_strength0z(s: Span) -> IResult<Span, DriveStrength> {
#[parser]
pub fn drive_strength1z(s: Span) -> IResult<Span, DriveStrength> {
let (s, a) = paren(triple(strength1, symbol(","), symbol("highz0")))(s)?;
let (s, a) = paren(triple(strength1, symbol(","), keyword("highz0")))(s)?;
Ok((
s,
DriveStrength::Strength1z(DriveStrength1z { nodes: (a,) }),
@ -136,7 +136,7 @@ pub fn drive_strength1z(s: Span) -> IResult<Span, DriveStrength> {
#[parser]
pub fn drive_strengthz1(s: Span) -> IResult<Span, DriveStrength> {
let (s, a) = paren(triple(symbol("highz0"), symbol(","), strength1))(s)?;
let (s, a) = paren(triple(keyword("highz0"), symbol(","), strength1))(s)?;
Ok((
s,
DriveStrength::Strengthz1(DriveStrengthz1 { nodes: (a,) }),
@ -145,7 +145,7 @@ pub fn drive_strengthz1(s: Span) -> IResult<Span, DriveStrength> {
#[parser]
pub fn drive_strengthz0(s: Span) -> IResult<Span, DriveStrength> {
let (s, a) = paren(triple(symbol("highz1"), symbol(","), strength0))(s)?;
let (s, a) = paren(triple(keyword("highz1"), symbol(","), strength0))(s)?;
Ok((
s,
DriveStrength::Strengthz0(DriveStrengthz0 { nodes: (a,) }),
@ -155,20 +155,20 @@ pub fn drive_strengthz0(s: Span) -> IResult<Span, DriveStrength> {
#[parser]
pub fn strength0(s: Span) -> IResult<Span, Strength0> {
alt((
map(symbol("supply0"), |x| Strength0::Supply0(x)),
map(symbol("strong0"), |x| Strength0::Strong0(x)),
map(symbol("pull0"), |x| Strength0::Pull0(x)),
map(symbol("weak0"), |x| Strength0::Weak0(x)),
map(keyword("supply0"), |x| Strength0::Supply0(x)),
map(keyword("strong0"), |x| Strength0::Strong0(x)),
map(keyword("pull0"), |x| Strength0::Pull0(x)),
map(keyword("weak0"), |x| Strength0::Weak0(x)),
))(s)
}
#[parser]
pub fn strength1(s: Span) -> IResult<Span, Strength1> {
alt((
map(symbol("supply1"), |x| Strength1::Supply1(x)),
map(symbol("strong1"), |x| Strength1::Strong1(x)),
map(symbol("pull1"), |x| Strength1::Pull1(x)),
map(symbol("weak1"), |x| Strength1::Weak1(x)),
map(keyword("supply1"), |x| Strength1::Supply1(x)),
map(keyword("strong1"), |x| Strength1::Strong1(x)),
map(keyword("pull1"), |x| Strength1::Pull1(x)),
map(keyword("weak1"), |x| Strength1::Weak1(x)),
))(s)
}
@ -183,7 +183,7 @@ pub fn charge_strength(s: Span) -> IResult<Span, ChargeStrength> {
#[parser]
pub fn charge_strength_small(s: Span) -> IResult<Span, ChargeStrength> {
let (s, a) = paren(symbol("small"))(s)?;
let (s, a) = paren(keyword("small"))(s)?;
Ok((
s,
ChargeStrength::Small(ChargeStrengthSmall { nodes: (a,) }),
@ -192,7 +192,7 @@ pub fn charge_strength_small(s: Span) -> IResult<Span, ChargeStrength> {
#[parser]
pub fn charge_strength_medium(s: Span) -> IResult<Span, ChargeStrength> {
let (s, a) = paren(symbol("medium"))(s)?;
let (s, a) = paren(keyword("medium"))(s)?;
Ok((
s,
ChargeStrength::Medium(ChargeStrengthMedium { nodes: (a,) }),
@ -201,7 +201,7 @@ pub fn charge_strength_medium(s: Span) -> IResult<Span, ChargeStrength> {
#[parser]
pub fn charge_strength_large(s: Span) -> IResult<Span, ChargeStrength> {
let (s, a) = paren(symbol("large"))(s)?;
let (s, a) = paren(keyword("large"))(s)?;
Ok((
s,
ChargeStrength::Large(ChargeStrengthLarge { nodes: (a,) }),

View File

@ -103,7 +103,7 @@ pub struct TaskPrototype<'a> {
#[parser]
pub fn task_declaration(s: Span) -> IResult<Span, TaskDeclaration> {
let (s, a) = symbol("task")(s)?;
let (s, a) = keyword("task")(s)?;
let (s, b) = opt(lifetime)(s)?;
let (s, c) = task_body_declaration(s)?;
Ok((s, TaskDeclaration { nodes: (a, b, c) }))
@ -124,7 +124,7 @@ pub fn task_body_declaration_without_port(s: Span) -> IResult<Span, TaskBodyDecl
let (s, c) = symbol(";")(s)?;
let (s, d) = many0(tf_item_declaration)(s)?;
let (s, e) = many0(statement_or_null)(s)?;
let (s, f) = symbol("endtask")(s)?;
let (s, f) = keyword("endtask")(s)?;
let (s, g) = opt(pair(symbol(":"), task_identifier))(s)?;
Ok((
s,
@ -142,7 +142,7 @@ pub fn task_body_declaration_with_port(s: Span) -> IResult<Span, TaskBodyDeclara
let (s, d) = symbol(";")(s)?;
let (s, e) = many0(block_item_declaration)(s)?;
let (s, f) = many0(statement_or_null)(s)?;
let (s, g) = symbol("endtask")(s)?;
let (s, g) = keyword("endtask")(s)?;
let (s, h) = opt(pair(symbol(":"), task_identifier))(s)?;
Ok((
s,
@ -193,7 +193,7 @@ pub fn tf_port_item(s: Span) -> IResult<Span, TfPortItem> {
pub fn tf_port_direction(s: Span) -> IResult<Span, TfPortDirection> {
alt((
map(port_direction, |x| TfPortDirection::PortDirection(x)),
map(pair(symbol("const"), symbol("ref")), |x| {
map(pair(keyword("const"), keyword("ref")), |x| {
TfPortDirection::ConstRef(x)
}),
))(s)
@ -217,7 +217,7 @@ pub fn tf_port_declaration(s: Span) -> IResult<Span, TfPortDeclaration> {
#[parser]
pub fn task_prototype(s: Span) -> IResult<Span, TaskPrototype> {
let (s, a) = symbol("task")(s)?;
let (s, a) = keyword("task")(s)?;
let (s, b) = task_identifier(s)?;
let (s, c) = opt(paren(opt(tf_port_list)))(s)?;
Ok((s, TaskPrototype { nodes: (a, b, c) }))

View File

@ -173,7 +173,7 @@ pub struct TypeDeclarationInterface<'a> {
pub struct TypeDeclarationReserved<'a> {
pub nodes: (
Symbol<'a>,
TypeDeclarationKeyword<'a>,
Option<TypeDeclarationKeyword<'a>>,
TypeIdentifier<'a>,
Symbol<'a>,
),
@ -260,13 +260,13 @@ pub fn data_declaration_variable(s: Span) -> IResult<Span, DataDeclaration> {
#[parser]
pub fn r#const(s: Span) -> IResult<Span, Const> {
let (s, a) = symbol("const")(s)?;
let (s, a) = keyword("const")(s)?;
Ok((s, Const { nodes: (a,) }))
}
#[parser]
pub fn package_import_declaration(s: Span) -> IResult<Span, PackageImportDeclaration> {
let (s, a) = symbol("import")(s)?;
let (s, a) = keyword("import")(s)?;
let (s, b) = list(symbol(","), package_import_item)(s)?;
let (s, c) = symbol(";")(s)?;
Ok((s, PackageImportDeclaration { nodes: (a, b, c) }))
@ -309,7 +309,7 @@ pub fn package_export_declaration(s: Span) -> IResult<Span, PackageExportDeclara
#[parser]
pub fn package_export_declaration_asterisk(s: Span) -> IResult<Span, PackageExportDeclaration> {
let (s, a) = symbol("export")(s)?;
let (s, a) = keyword("export")(s)?;
let (s, b) = symbol("*::*")(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
@ -320,7 +320,7 @@ pub fn package_export_declaration_asterisk(s: Span) -> IResult<Span, PackageExpo
#[parser]
pub fn package_export_declaration_item(s: Span) -> IResult<Span, PackageExportDeclaration> {
let (s, a) = symbol("export")(s)?;
let (s, a) = keyword("export")(s)?;
let (s, b) = list(symbol(","), package_import_item)(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
@ -331,7 +331,7 @@ pub fn package_export_declaration_item(s: Span) -> IResult<Span, PackageExportDe
#[parser]
pub fn genvar_declaration(s: Span) -> IResult<Span, GenvarDeclaration> {
let (s, a) = symbol("genvar")(s)?;
let (s, a) = keyword("genvar")(s)?;
let (s, b) = list_of_genvar_identifiers(s)?;
let (s, c) = symbol(";")(s)?;
Ok((s, GenvarDeclaration { nodes: (a, b, c) }))
@ -374,8 +374,8 @@ pub fn strength(s: Span) -> IResult<Span, Strength> {
#[parser]
pub fn vector_scalar(s: Span) -> IResult<Span, VectorScalar> {
alt((
map(symbol("vectored"), |x| VectorScalar::Vectored(x)),
map(symbol("scalared"), |x| VectorScalar::Scalared(x)),
map(keyword("vectored"), |x| VectorScalar::Vectored(x)),
map(keyword("scalared"), |x| VectorScalar::Scalared(x)),
))(s)
}
@ -395,7 +395,7 @@ pub fn net_declaration_net_type_identifier(s: Span) -> IResult<Span, NetDeclarat
#[parser]
pub fn net_declaration_interconnect(s: Span) -> IResult<Span, NetDeclaration> {
let (s, a) = symbol("interconnect")(s)?;
let (s, a) = keyword("interconnect")(s)?;
let (s, b) = implicit_data_type(s)?;
let (s, c) = opt(pair(symbol("#"), delay_value))(s)?;
let (s, d) = net_identifier(s)?;
@ -425,7 +425,7 @@ pub fn type_declaration(s: Span) -> IResult<Span, TypeDeclaration> {
#[parser]
pub fn type_declaration_data_type(s: Span) -> IResult<Span, TypeDeclaration> {
let (s, a) = symbol("typedef")(s)?;
let (s, a) = keyword("typedef")(s)?;
let (s, b) = data_type(s)?;
let (s, c) = type_identifier(s)?;
let (s, d) = many0(variable_dimension)(s)?;
@ -440,7 +440,7 @@ pub fn type_declaration_data_type(s: Span) -> IResult<Span, TypeDeclaration> {
#[parser]
pub fn type_declaration_interface(s: Span) -> IResult<Span, TypeDeclaration> {
let (s, a) = symbol("typedef")(s)?;
let (s, a) = keyword("typedef")(s)?;
let (s, b) = interface_instance_identifier(s)?;
let (s, c) = constant_bit_select(s)?;
let (s, d) = symbol(".")(s)?;
@ -457,8 +457,8 @@ pub fn type_declaration_interface(s: Span) -> IResult<Span, TypeDeclaration> {
#[parser]
pub fn type_declaration_reserved(s: Span) -> IResult<Span, TypeDeclaration> {
let (s, a) = symbol("typedef")(s)?;
let (s, b) = type_declaration_keyword(s)?;
let (s, a) = keyword("typedef")(s)?;
let (s, b) = opt(type_declaration_keyword)(s)?;
let (s, c) = type_identifier(s)?;
let (s, d) = symbol(";")(s)?;
Ok((
@ -472,11 +472,11 @@ pub fn type_declaration_reserved(s: Span) -> IResult<Span, TypeDeclaration> {
#[parser]
pub fn type_declaration_keyword(s: Span) -> IResult<Span, TypeDeclarationKeyword> {
alt((
map(symbol("enum"), |x| TypeDeclarationKeyword::Enum(x)),
map(symbol("struct"), |x| TypeDeclarationKeyword::Struct(x)),
map(symbol("union"), |x| TypeDeclarationKeyword::Union(x)),
map(symbol("class"), |x| TypeDeclarationKeyword::Class(x)),
map(pair(symbol("interface"), symbol("class")), |x| {
map(keyword("enum"), |x| TypeDeclarationKeyword::Enum(x)),
map(keyword("struct"), |x| TypeDeclarationKeyword::Struct(x)),
map(keyword("union"), |x| TypeDeclarationKeyword::Union(x)),
map(keyword("class"), |x| TypeDeclarationKeyword::Class(x)),
map(pair(keyword("interface"), keyword("class")), |x| {
TypeDeclarationKeyword::InterfaceClass(x)
}),
))(s)
@ -492,11 +492,11 @@ pub fn net_type_declaration(s: Span) -> IResult<Span, NetTypeDeclaration> {
#[parser]
pub fn net_type_declaration_data_type(s: Span) -> IResult<Span, NetTypeDeclaration> {
let (s, a) = symbol("nettype")(s)?;
let (s, a) = keyword("nettype")(s)?;
let (s, b) = data_type(s)?;
let (s, c) = net_type_identifier(s)?;
let (s, d) = opt(triple(
symbol("with"),
keyword("with"),
opt(package_scope_or_class_scope),
tf_identifier,
))(s)?;
@ -511,7 +511,7 @@ pub fn net_type_declaration_data_type(s: Span) -> IResult<Span, NetTypeDeclarati
#[parser]
pub fn net_type_declaration_net_type(s: Span) -> IResult<Span, NetTypeDeclaration> {
let (s, a) = symbol("nettype")(s)?;
let (s, a) = keyword("nettype")(s)?;
let (s, b) = opt(package_scope_or_class_scope)(s)?;
let (s, c) = net_type_identifier(s)?;
let (s, d) = net_type_identifier(s)?;
@ -527,8 +527,8 @@ pub fn net_type_declaration_net_type(s: Span) -> IResult<Span, NetTypeDeclaratio
#[parser]
pub fn lifetime(s: Span) -> IResult<Span, Lifetime> {
alt((
map(symbol("static"), |x| Lifetime::Static(x)),
map(symbol("automatic"), |x| Lifetime::Automatic(x)),
map(keyword("static"), |x| Lifetime::Static(x)),
map(keyword("automatic"), |x| Lifetime::Automatic(x)),
))(s)
}
@ -601,5 +601,189 @@ mod tests {
);
parser_test!(net_declaration, "interconnect logic [3:0] w4;", Err(_));
parser_test!(net_declaration, "interconnect #(1,2,3) w5;", Err(_));
parser_test!(
net_declaration,
"wand w;",
Ok((_, NetDeclaration::NetType(_)))
);
parser_test!(
net_declaration,
"tri [15:0] busa;",
Ok((_, NetDeclaration::NetType(_)))
);
parser_test!(
net_declaration,
"trireg (small) storeit;",
Ok((_, NetDeclaration::NetType(_)))
);
parser_test!(
net_declaration,
"wire w1, w2;",
Ok((_, NetDeclaration::NetType(_)))
);
parser_test!(
net_declaration,
"tri1 scalared [63:0] bus64;",
Ok((_, NetDeclaration::NetType(_)))
);
parser_test!(
net_declaration,
"tri vectored [31:0] data;",
Ok((_, NetDeclaration::NetType(_)))
);
}
#[test]
fn test_data_declaration() {
parser_test!(
data_declaration,
"shortint s1, s2[0:9];",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"var byte my_byte;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"var v;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"var [15:0] vw;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"var enum bit { clear, error } status;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"var reg r;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"int i = 0;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"logic a;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"logic[3:0] v;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"logic signed [3:0] signed_reg;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"logic [-1:4] b;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"logic [4:0] x, y, z;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"int unsigned ui;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"int signed si;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"string myName = default_name;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"byte c = \"A\";",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"bit [10:0] b = \"x41\";",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"bit [1:4][7:0] h = \"hello\" ;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"event done;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"event done_too = done;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"event empty = null;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"typedef int intP;",
Ok((_, DataDeclaration::TypeDeclaration(_)))
);
parser_test!(
data_declaration,
"intP a, b;",
Ok((_, DataDeclaration::Variable(_)))
);
parser_test!(
data_declaration,
"typedef enum type_identifier;",
Ok((_, DataDeclaration::TypeDeclaration(_)))
);
parser_test!(
data_declaration,
"typedef struct type_identifier;",
Ok((_, DataDeclaration::TypeDeclaration(_)))
);
parser_test!(
data_declaration,
"typedef union type_identifier;",
Ok((_, DataDeclaration::TypeDeclaration(_)))
);
parser_test!(
data_declaration,
"typedef class type_identifier;",
Ok((_, DataDeclaration::TypeDeclaration(_)))
);
parser_test!(
data_declaration,
"typedef interface class type_identifier;",
Ok((_, DataDeclaration::TypeDeclaration(_)))
);
parser_test!(
data_declaration,
"typedef type_identifier;",
Ok((_, DataDeclaration::TypeDeclaration(_)))
);
parser_test!(
data_declaration,
"typedef C::T c_t;",
Ok((_, DataDeclaration::TypeDeclaration(_)))
);
}
}

View File

@ -178,7 +178,7 @@ pub fn stream_concatenation(s: Span) -> IResult<Span, StreamConcatenation> {
#[parser(MaybeRecursive)]
pub fn stream_expression(s: Span) -> IResult<Span, StreamExpression> {
let (s, a) = expression(s)?;
let (s, b) = opt(pair(symbol("with"), bracket(array_range_expression)))(s)?;
let (s, b) = opt(pair(keyword("with"), bracket(array_range_expression)))(s)?;
Ok((s, StreamExpression { nodes: (a, b) }))
}

View File

@ -522,7 +522,7 @@ pub fn expression_binary(s: Span) -> IResult<Span, Expression> {
#[parser]
pub fn tagged_union_expression(s: Span) -> IResult<Span, TaggedUnionExpression> {
let (s, a) = symbol("tagged")(s)?;
let (s, a) = keyword("tagged")(s)?;
let (s, b) = member_identifier(s)?;
let (s, c) = opt(expression)(s)?;
Ok((s, TaggedUnionExpression { nodes: (a, b, c) }))
@ -531,7 +531,7 @@ pub fn tagged_union_expression(s: Span) -> IResult<Span, TaggedUnionExpression>
#[parser(MaybeRecursive)]
pub fn inside_expression(s: Span) -> IResult<Span, InsideExpression> {
let (s, a) = expression(s)?;
let (s, b) = symbol("inside")(s)?;
let (s, b) = keyword("inside")(s)?;
let (s, c) = brace(open_range_list)(s)?;
Ok((s, InsideExpression { nodes: (a, b, c) }))
}

View File

@ -264,7 +264,7 @@ pub struct Cast<'a> {
#[parser]
pub fn constant_primary(s: Span) -> IResult<Span, ConstantPrimary> {
alt((
map(symbol("null"), |x| ConstantPrimary::Null(x)),
map(keyword("null"), |x| ConstantPrimary::Null(x)),
map(primary_literal, |x| ConstantPrimary::PrimaryLiteral(x)),
constant_primary_ps_parameter,
constant_primary_specparam,
@ -389,9 +389,9 @@ pub fn module_path_primary_mintypmax_expression(s: Span) -> IResult<Span, Module
#[parser]
pub fn primary(s: Span) -> IResult<Span, Primary> {
alt((
map(symbol("this"), |x| Primary::This(x)),
map(keyword("this"), |x| Primary::This(x)),
map(symbol("$"), |x| Primary::Dollar(x)),
map(symbol("null"), |x| Primary::Null(x)),
map(keyword("null"), |x| Primary::Null(x)),
map(primary_literal, |x| Primary::PrimaryLiteral(x)),
primary_hierarchical,
map(empty_unpacked_array_concatenation, |x| {
@ -521,12 +521,12 @@ pub fn time_literal_fixed_point(s: Span) -> IResult<Span, TimeLiteral> {
#[parser]
pub fn time_unit(s: Span) -> IResult<Span, TimeUnit> {
alt((
map(symbol("s"), |x| TimeUnit::S(x)),
map(symbol("ms"), |x| TimeUnit::MS(x)),
map(symbol("us"), |x| TimeUnit::US(x)),
map(symbol("ns"), |x| TimeUnit::NS(x)),
map(symbol("ps"), |x| TimeUnit::PS(x)),
map(symbol("fs"), |x| TimeUnit::FS(x)),
map(keyword("s"), |x| TimeUnit::S(x)),
map(keyword("ms"), |x| TimeUnit::MS(x)),
map(keyword("us"), |x| TimeUnit::US(x)),
map(keyword("ns"), |x| TimeUnit::NS(x)),
map(keyword("ps"), |x| TimeUnit::PS(x)),
map(keyword("fs"), |x| TimeUnit::FS(x)),
))(s)
}
@ -534,11 +534,11 @@ pub fn time_unit(s: Span) -> IResult<Span, TimeUnit> {
pub fn implicit_class_handle(s: Span) -> IResult<Span, ImplicitClassHandle> {
alt((
map(
triple(symbol("this"), symbol("."), symbol("super")),
triple(keyword("this"), symbol("."), keyword("super")),
|(x, y, z)| ImplicitClassHandle::ThisSuper((x, y, z)),
),
map(symbol("this"), |x| ImplicitClassHandle::This(x)),
map(symbol("super"), |x| ImplicitClassHandle::Super(x)),
map(keyword("this"), |x| ImplicitClassHandle::This(x)),
map(keyword("super"), |x| ImplicitClassHandle::Super(x)),
))(s)
}

View File

@ -254,7 +254,7 @@ pub fn subroutine_call(s: Span) -> IResult<Span, SubroutineCall> {
#[parser]
pub fn subroutine_call_randomize(s: Span) -> IResult<Span, SubroutineCall> {
let (s, a) = opt(pair(symbol("std"), symbol("::")))(s)?;
let (s, a) = opt(pair(keyword("std"), symbol("::")))(s)?;
let (s, b) = randomize_call(s)?;
Ok((
s,
@ -351,7 +351,7 @@ pub fn array_manipulation_call(s: Span) -> IResult<Span, ArrayManipulationCall>
let (s, a) = array_method_name(s)?;
let (s, b) = many0(attribute_instance)(s)?;
let (s, c) = opt(paren(list_of_arguments))(s)?;
let (s, d) = opt(pair(symbol("with"), paren(expression)))(s)?;
let (s, d) = opt(pair(keyword("with"), paren(expression)))(s)?;
Ok((
s,
ArrayManipulationCall {
@ -362,11 +362,11 @@ pub fn array_manipulation_call(s: Span) -> IResult<Span, ArrayManipulationCall>
#[parser]
pub fn randomize_call(s: Span) -> IResult<Span, RandomizeCall> {
let (s, a) = symbol("randomize")(s)?;
let (s, a) = keyword("randomize")(s)?;
let (s, b) = many0(attribute_instance)(s)?;
let (s, c) = opt(paren(opt(variable_identifier_list_or_null)))(s)?;
let (s, d) = opt(triple(
symbol("with"),
keyword("with"),
opt(paren(opt(identifier_list))),
constraint_block,
))(s)?;
@ -384,7 +384,7 @@ pub fn variable_identifier_list_or_null(s: Span) -> IResult<Span, VariableIdenti
map(variable_identifier_list, |x| {
VariableIdentifierListOrNull::VariableIdentifierList(x)
}),
map(symbol("null"), |x| VariableIdentifierListOrNull::Null(x)),
map(keyword("null"), |x| VariableIdentifierListOrNull::Null(x)),
))(s)
}
@ -401,10 +401,10 @@ pub fn method_call_root(s: Span) -> IResult<Span, MethodCallRoot> {
#[parser]
pub fn array_method_name(s: Span) -> IResult<Span, ArrayMethodName> {
alt((
map(symbol("unique"), |x| ArrayMethodName::Unique(x)),
map(symbol("and"), |x| ArrayMethodName::And(x)),
map(symbol("or"), |x| ArrayMethodName::Or(x)),
map(symbol("xor"), |x| ArrayMethodName::Xor(x)),
map(keyword("unique"), |x| ArrayMethodName::Unique(x)),
map(keyword("and"), |x| ArrayMethodName::And(x)),
map(keyword("or"), |x| ArrayMethodName::Or(x)),
map(keyword("xor"), |x| ArrayMethodName::Xor(x)),
map(method_identifier, |x| ArrayMethodName::MethodIdentifier(x)),
))(s)
}

View File

@ -3,15 +3,16 @@ use crate::parser::*;
use nom::branch::*;
use nom::bytes::complete::*;
use nom::combinator::*;
use nom::error::*;
use nom::multi::*;
use nom::sequence::*;
use nom::IResult;
use nom::{Err, IResult};
// -----------------------------------------------------------------------------
const AZ_: &str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
const AZ09_: &str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
const AZ09_DOLLAR: &str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$";
pub const AZ_: &str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
pub const AZ09_: &str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
pub const AZ09_DOLLAR: &str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$";
#[derive(Debug, Node)]
pub struct ArrayIdentifier<'a> {
@ -577,7 +578,11 @@ pub fn c_identifier_impl(s: Span) -> IResult<Span, Span> {
} else {
a
};
if is_keyword(&a) {
Err(Err::Error(make_error(s, ErrorKind::Fix)))
} else {
Ok((s, a))
}
}
#[parser]
@ -736,7 +741,7 @@ pub fn hierarchical_identifier(s: Span) -> IResult<Span, HierarchicalIdentifier>
#[parser]
pub fn root(s: Span) -> IResult<Span, Root> {
let (s, a) = symbol("$root")(s)?;
let (s, a) = keyword("$root")(s)?;
let (s, b) = symbol(".")(s)?;
Ok((s, Root { nodes: (a, b) }))
}
@ -900,7 +905,7 @@ pub fn package_scope_package(s: Span) -> IResult<Span, PackageScope> {
#[parser]
pub fn unit(s: Span) -> IResult<Span, Unit> {
let (s, a) = symbol("$unit")(s)?;
let (s, a) = keyword("$unit")(s)?;
let (s, b) = symbol("::")(s)?;
Ok((s, Unit { nodes: (a, b) }))
}
@ -1138,7 +1143,11 @@ pub fn simple_identifier_impl(s: Span) -> IResult<Span, Span> {
} else {
a
};
if is_keyword(&a) {
Err(Err::Error(make_error(s, ErrorKind::Fix)))
} else {
Ok((s, a))
}
}
#[parser]
@ -1273,7 +1282,7 @@ pub fn local_or_package_scope_or_class_scope(
#[parser]
pub fn local(s: Span) -> IResult<Span, Local> {
let (s, a) = symbol("local")(s)?;
let (s, a) = keyword("local")(s)?;
let (s, b) = symbol("::")(s)?;
Ok((s, Local { nodes: (a, b) }))
}

View File

@ -147,15 +147,15 @@ pub enum GenerateItem<'a> {
#[parser]
pub fn generate_region(s: Span) -> IResult<Span, GenerateRegion> {
let (s, a) = symbol("generate")(s)?;
let (s, a) = keyword("generate")(s)?;
let (s, b) = many0(generate_item)(s)?;
let (s, c) = symbol("endgenerate")(s)?;
let (s, c) = keyword("endgenerate")(s)?;
Ok((s, GenerateRegion { nodes: (a, b, c) }))
}
#[parser]
pub fn loop_generate_construct(s: Span) -> IResult<Span, LoopGenerateConstruct> {
let (s, a) = symbol("for")(s)?;
let (s, a) = keyword("for")(s)?;
let (s, b) = paren(tuple((
generate_initialization,
symbol(";"),
@ -169,7 +169,7 @@ pub fn loop_generate_construct(s: Span) -> IResult<Span, LoopGenerateConstruct>
#[parser]
pub fn generate_initialization(s: Span) -> IResult<Span, GenvarInitialization> {
let (s, a) = opt(map(symbol("genvar"), |x| Genvar { nodes: (x,) }))(s)?;
let (s, a) = opt(map(keyword("genvar"), |x| Genvar { nodes: (x,) }))(s)?;
let (s, b) = genvar_identifier(s)?;
let (s, c) = symbol("=")(s)?;
let (s, d) = constant_expression(s)?;
@ -235,10 +235,10 @@ pub fn conditional_generate_construct(s: Span) -> IResult<Span, ConditionalGener
#[parser]
pub fn if_generate_construct(s: Span) -> IResult<Span, IfGenerateConstruct> {
let (s, a) = symbol("if")(s)?;
let (s, a) = keyword("if")(s)?;
let (s, b) = paren(constant_expression)(s)?;
let (s, c) = generate_block(s)?;
let (s, d) = opt(pair(symbol("else"), generate_block))(s)?;
let (s, d) = opt(pair(keyword("else"), generate_block))(s)?;
Ok((
s,
IfGenerateConstruct {
@ -249,10 +249,10 @@ pub fn if_generate_construct(s: Span) -> IResult<Span, IfGenerateConstruct> {
#[parser]
pub fn case_generate_construct(s: Span) -> IResult<Span, CaseGenerateConstruct> {
let (s, a) = symbol("case")(s)?;
let (s, a) = keyword("case")(s)?;
let (s, b) = paren(constant_expression)(s)?;
let (s, c) = many1(case_generate_item)(s)?;
let (s, d) = symbol("endcase")(s)?;
let (s, d) = keyword("endcase")(s)?;
Ok((
s,
CaseGenerateConstruct {
@ -279,7 +279,7 @@ pub fn case_generate_item_nondefault(s: Span) -> IResult<Span, CaseGenerateItem>
#[parser]
pub fn case_generate_item_default(s: Span) -> IResult<Span, CaseGenerateItem> {
let (s, a) = symbol("default")(s)?;
let (s, a) = keyword("default")(s)?;
let (s, b) = opt(symbol(":"))(s)?;
let (s, c) = generate_block(s)?;
Ok((
@ -299,10 +299,10 @@ pub fn generate_block(s: Span) -> IResult<Span, GenerateBlock> {
#[parser]
pub fn generate_block_multiple(s: Span) -> IResult<Span, GenerateBlock> {
let (s, a) = opt(pair(generate_block_identifier, symbol(":")))(s)?;
let (s, b) = symbol("begin")(s)?;
let (s, b) = keyword("begin")(s)?;
let (s, c) = opt(pair(symbol(":"), generate_block_identifier))(s)?;
let (s, d) = many0(generate_item)(s)?;
let (s, e) = symbol("end")(s)?;
let (s, e) = keyword("end")(s)?;
let (s, f) = opt(pair(symbol(":"), generate_block_identifier))(s)?;
Ok((
s,

View File

@ -44,17 +44,17 @@ pub struct PassSwitchtype<'a> {
#[parser]
pub fn cmos_switchtype(s: Span) -> IResult<Span, CmosSwitchtype> {
let (s, a) = alt((symbol("cmos"), symbol("rcmos")))(s)?;
let (s, a) = alt((keyword("cmos"), keyword("rcmos")))(s)?;
Ok((s, CmosSwitchtype { nodes: (a,) }))
}
#[parser]
pub fn enable_gatetype(s: Span) -> IResult<Span, EnableGatetype> {
let (s, a) = alt((
symbol("bufif0"),
symbol("bufif1"),
symbol("notif0"),
symbol("notif1"),
keyword("bufif0"),
keyword("bufif1"),
keyword("notif0"),
keyword("notif1"),
))(s)?;
Ok((s, EnableGatetype { nodes: (a,) }))
}
@ -62,10 +62,10 @@ pub fn enable_gatetype(s: Span) -> IResult<Span, EnableGatetype> {
#[parser]
pub fn mos_switchtype(s: Span) -> IResult<Span, MosSwitchtype> {
let (s, a) = alt((
symbol("nmos"),
symbol("pmos"),
symbol("rnmos"),
symbol("rpmos"),
keyword("nmos"),
keyword("pmos"),
keyword("rnmos"),
keyword("rpmos"),
))(s)?;
Ok((s, MosSwitchtype { nodes: (a,) }))
}
@ -73,36 +73,36 @@ pub fn mos_switchtype(s: Span) -> IResult<Span, MosSwitchtype> {
#[parser]
pub fn n_input_gatetype(s: Span) -> IResult<Span, NInputGatetype> {
let (s, a) = alt((
symbol("and"),
symbol("nand"),
symbol("or"),
symbol("nor"),
symbol("xor"),
symbol("xnor"),
keyword("and"),
keyword("nand"),
keyword("or"),
keyword("nor"),
keyword("xor"),
keyword("xnor"),
))(s)?;
Ok((s, NInputGatetype { nodes: (a,) }))
}
#[parser]
pub fn n_output_gatetype(s: Span) -> IResult<Span, NOutputGatetype> {
let (s, a) = alt((symbol("buf"), symbol("not")))(s)?;
let (s, a) = alt((keyword("buf"), keyword("not")))(s)?;
Ok((s, NOutputGatetype { nodes: (a,) }))
}
#[parser]
pub fn pass_en_switchtype(s: Span) -> IResult<Span, PassEnSwitchtype> {
let (s, a) = alt((
symbol("tranif0"),
symbol("tranif1"),
symbol("rtranif0"),
symbol("rtranif1"),
keyword("tranif0"),
keyword("tranif1"),
keyword("rtranif0"),
keyword("rtranif1"),
))(s)?;
Ok((s, PassEnSwitchtype { nodes: (a,) }))
}
#[parser]
pub fn pass_switchtype(s: Span) -> IResult<Span, PassSwitchtype> {
let (s, a) = alt((symbol("tran"), symbol("rtran")))(s)?;
let (s, a) = alt((keyword("tran"), keyword("rtran")))(s)?;
Ok((s, PassSwitchtype { nodes: (a,) }))
}

View File

@ -117,8 +117,8 @@ pub fn checker_port_item(s: Span) -> IResult<Span, CheckerPortItem> {
#[parser]
pub fn checker_port_direction(s: Span) -> IResult<Span, CheckerPortDirection> {
alt((
map(symbol("input"), |x| CheckerPortDirection::Input(x)),
map(symbol("output"), |x| CheckerPortDirection::Output(x)),
map(keyword("input"), |x| CheckerPortDirection::Input(x)),
map(keyword("output"), |x| CheckerPortDirection::Output(x)),
))(s)
}
@ -193,7 +193,7 @@ pub fn checker_or_generate_item_declaration_data(
#[parser]
pub fn rand(s: Span) -> IResult<Span, Rand> {
let (s, a) = symbol("rand")(s)?;
let (s, a) = keyword("rand")(s)?;
Ok((s, Rand { nodes: (a,) }))
}
@ -201,8 +201,8 @@ pub fn rand(s: Span) -> IResult<Span, Rand> {
pub fn checker_or_generate_item_declaration_clocking(
s: Span,
) -> IResult<Span, CheckerOrGenerateItemDeclaration> {
let (s, a) = symbol("default")(s)?;
let (s, b) = symbol("clocking")(s)?;
let (s, a) = keyword("default")(s)?;
let (s, b) = keyword("clocking")(s)?;
let (s, c) = clocking_identifier(s)?;
let (s, d) = symbol(";")(s)?;
Ok((
@ -217,9 +217,9 @@ pub fn checker_or_generate_item_declaration_clocking(
pub fn checker_or_generate_item_declaration_disable(
s: Span,
) -> IResult<Span, CheckerOrGenerateItemDeclaration> {
let (s, a) = symbol("default")(s)?;
let (s, b) = symbol("disable")(s)?;
let (s, c) = symbol("iff")(s)?;
let (s, a) = keyword("default")(s)?;
let (s, b) = keyword("disable")(s)?;
let (s, c) = keyword("iff")(s)?;
let (s, d) = expression_or_dist(s)?;
let (s, e) = symbol(";")(s)?;
Ok((

View File

@ -279,7 +279,7 @@ pub fn class_property_non_const(s: Span) -> IResult<Span, ClassProperty> {
#[parser]
pub fn class_property_const(s: Span) -> IResult<Span, ClassProperty> {
let (s, a) = symbol("const")(s)?;
let (s, a) = keyword("const")(s)?;
let (s, b) = many0(class_item_qualifier)(s)?;
let (s, c) = data_type(s)?;
let (s, d) = const_identifier(s)?;
@ -324,8 +324,8 @@ pub fn class_method_function(s: Span) -> IResult<Span, ClassMethod> {
#[parser]
pub fn class_method_pure_virtual(s: Span) -> IResult<Span, ClassMethod> {
let (s, a) = symbol("pure")(s)?;
let (s, b) = symbol("virtual")(s)?;
let (s, a) = keyword("pure")(s)?;
let (s, b) = keyword("virtual")(s)?;
let (s, c) = many0(class_item_qualifier)(s)?;
let (s, d) = method_prototype(s)?;
let (s, e) = symbol(";")(s)?;
@ -339,7 +339,7 @@ pub fn class_method_pure_virtual(s: Span) -> IResult<Span, ClassMethod> {
#[parser]
pub fn class_method_extern_method(s: Span) -> IResult<Span, ClassMethod> {
let (s, a) = symbol("extern")(s)?;
let (s, a) = keyword("extern")(s)?;
let (s, b) = many0(method_qualifier)(s)?;
let (s, c) = method_prototype(s)?;
let (s, d) = symbol(";")(s)?;
@ -363,7 +363,7 @@ pub fn class_method_constructor(s: Span) -> IResult<Span, ClassMethod> {
#[parser]
pub fn class_method_extern_constructor(s: Span) -> IResult<Span, ClassMethod> {
let (s, a) = symbol("extern")(s)?;
let (s, a) = keyword("extern")(s)?;
let (s, b) = many0(method_qualifier)(s)?;
let (s, c) = class_constructor_prototype(s)?;
Ok((
@ -374,8 +374,8 @@ pub fn class_method_extern_constructor(s: Span) -> IResult<Span, ClassMethod> {
#[parser]
pub fn class_constructor_prototype(s: Span) -> IResult<Span, ClassConstructorPrototype> {
let (s, a) = symbol("function")(s)?;
let (s, b) = symbol("new")(s)?;
let (s, a) = keyword("function")(s)?;
let (s, b) = keyword("new")(s)?;
let (s, c) = opt(paren(opt(tf_port_list)))(s)?;
let (s, d) = symbol(";")(s)?;
Ok((
@ -401,9 +401,9 @@ pub fn class_constraint(s: Span) -> IResult<Span, ClassConstraint> {
#[parser]
pub fn class_item_qualifier(s: Span) -> IResult<Span, ClassItemQualifier> {
alt((
map(symbol("static"), |x| ClassItemQualifier::Static(x)),
map(symbol("protected"), |x| ClassItemQualifier::Protected(x)),
map(symbol("local"), |x| ClassItemQualifier::Local(x)),
map(keyword("static"), |x| ClassItemQualifier::Static(x)),
map(keyword("protected"), |x| ClassItemQualifier::Protected(x)),
map(keyword("local"), |x| ClassItemQualifier::Local(x)),
))(s)
}
@ -420,18 +420,18 @@ pub fn property_qualifier(s: Span) -> IResult<Span, PropertyQualifier> {
#[parser]
pub fn random_qualifier(s: Span) -> IResult<Span, RandomQualifier> {
alt((
map(symbol("randc"), |x| RandomQualifier::Randc(x)),
map(symbol("rand"), |x| RandomQualifier::Rand(x)),
map(keyword("randc"), |x| RandomQualifier::Randc(x)),
map(keyword("rand"), |x| RandomQualifier::Rand(x)),
))(s)
}
#[parser]
pub fn method_qualifier(s: Span) -> IResult<Span, MethodQualifier> {
alt((
map(pair(symbol("pure"), symbol("virtual")), |x| {
map(pair(keyword("pure"), keyword("virtual")), |x| {
MethodQualifier::PureVirtual(x)
}),
map(symbol("virtual"), |x| MethodQualifier::Virtual(x)),
map(keyword("virtual"), |x| MethodQualifier::Virtual(x)),
map(class_item_qualifier, |x| {
MethodQualifier::ClassItemQualifier(x)
}),
@ -450,21 +450,21 @@ pub fn method_prototype(s: Span) -> IResult<Span, MethodPrototype> {
#[parser]
pub fn class_constructor_declaration(s: Span) -> IResult<Span, ClassConstructorDeclaration> {
let (s, a) = symbol("function")(s)?;
let (s, a) = keyword("function")(s)?;
let (s, b) = opt(class_scope)(s)?;
let (s, c) = symbol("new")(s)?;
let (s, c) = keyword("new")(s)?;
let (s, d) = opt(paren(opt(tf_port_list)))(s)?;
let (s, e) = symbol(";")(s)?;
let (s, f) = many0(block_item_declaration)(s)?;
let (s, g) = opt(tuple((
symbol("super"),
keyword("super"),
symbol("."),
symbol("new"),
keyword("new"),
opt(paren(list_of_arguments)),
symbol(";"),
)))(s)?;
let (s, h) = many0(function_statement_or_null)(s)?;
let (s, i) = symbol("end")(s)?;
let (s, i) = keyword("end")(s)?;
let (s, j) = opt(pair(symbol(":"), new))(s)?;
Ok((
s,
@ -476,6 +476,6 @@ pub fn class_constructor_declaration(s: Span) -> IResult<Span, ClassConstructorD
#[parser]
pub fn new(s: Span) -> IResult<Span, New> {
let (s, a) = symbol("new")(s)?;
let (s, a) = keyword("new")(s)?;
Ok((s, New { nodes: (a,) }))
}

View File

@ -146,13 +146,13 @@ pub struct Config<'a> {
#[parser]
pub fn config_declaration(s: Span) -> IResult<Span, ConfigDeclaration> {
let (s, a) = symbol("config")(s)?;
let (s, a) = keyword("config")(s)?;
let (s, b) = config_identifier(s)?;
let (s, c) = symbol(";")(s)?;
let (s, d) = many0(pair(local_parameter_declaration, symbol(";")))(s)?;
let (s, e) = design_statement(s)?;
let (s, f) = many0(config_rule_statement)(s)?;
let (s, g) = symbol("endconfig")(s)?;
let (s, g) = keyword("endconfig")(s)?;
let (s, h) = opt(pair(symbol(":"), config_identifier))(s)?;
Ok((
s,
@ -164,7 +164,7 @@ pub fn config_declaration(s: Span) -> IResult<Span, ConfigDeclaration> {
#[parser]
pub fn design_statement(s: Span) -> IResult<Span, DesignStatement> {
let (s, a) = symbol("design")(s)?;
let (s, a) = keyword("design")(s)?;
let (s, b) = many0(pair(
opt(pair(library_identifier, symbol("."))),
cell_identifier,
@ -241,13 +241,13 @@ pub fn config_rule_statement_cell_use(s: Span) -> IResult<Span, ConfigRuleStatem
#[parser]
pub fn default_clause(s: Span) -> IResult<Span, DefaultClause> {
let (s, a) = symbol("default")(s)?;
let (s, a) = keyword("default")(s)?;
Ok((s, DefaultClause { nodes: (a,) }))
}
#[parser]
pub fn inst_clause(s: Span) -> IResult<Span, InstClause> {
let (s, a) = symbol("instance")(s)?;
let (s, a) = keyword("instance")(s)?;
let (s, b) = inst_name(s)?;
Ok((s, InstClause { nodes: (a, b) }))
}
@ -261,7 +261,7 @@ pub fn inst_name(s: Span) -> IResult<Span, InstName> {
#[parser]
pub fn cell_clause(s: Span) -> IResult<Span, CellClause> {
let (s, a) = symbol("cell")(s)?;
let (s, a) = keyword("cell")(s)?;
let (s, b) = opt(pair(library_identifier, symbol(".")))(s)?;
let (s, c) = cell_identifier(s)?;
Ok((s, CellClause { nodes: (a, b, c) }))
@ -269,7 +269,7 @@ pub fn cell_clause(s: Span) -> IResult<Span, CellClause> {
#[parser]
pub fn liblist_clause(s: Span) -> IResult<Span, LiblistClause> {
let (s, a) = symbol("liblist")(s)?;
let (s, a) = keyword("liblist")(s)?;
let (s, b) = many0(library_identifier)(s)?;
Ok((s, LiblistClause { nodes: (a, b) }))
}
@ -281,7 +281,7 @@ pub fn use_clause(s: Span) -> IResult<Span, UseClause> {
#[parser]
pub fn use_clause_cell(s: Span) -> IResult<Span, UseClause> {
let (s, a) = symbol("use")(s)?;
let (s, a) = keyword("use")(s)?;
let (s, b) = opt(pair(library_identifier, symbol(".")))(s)?;
let (s, c) = cell_identifier(s)?;
let (s, d) = opt(pair(symbol(":"), config))(s)?;
@ -295,7 +295,7 @@ pub fn use_clause_cell(s: Span) -> IResult<Span, UseClause> {
#[parser]
pub fn use_clause_named(s: Span) -> IResult<Span, UseClause> {
let (s, a) = symbol("use")(s)?;
let (s, a) = keyword("use")(s)?;
let (s, b) = list(symbol(","), named_parameter_assignment)(s)?;
let (s, c) = opt(pair(symbol(":"), config))(s)?;
Ok((s, UseClause::Named(UseClauseNamed { nodes: (a, b, c) })))
@ -303,7 +303,7 @@ pub fn use_clause_named(s: Span) -> IResult<Span, UseClause> {
#[parser]
pub fn use_clause_cell_named(s: Span) -> IResult<Span, UseClause> {
let (s, a) = symbol("use")(s)?;
let (s, a) = keyword("use")(s)?;
let (s, b) = opt(pair(library_identifier, symbol(".")))(s)?;
let (s, c) = cell_identifier(s)?;
let (s, d) = list(symbol(","), named_parameter_assignment)(s)?;
@ -318,6 +318,6 @@ pub fn use_clause_cell_named(s: Span) -> IResult<Span, UseClause> {
#[parser]
pub fn config(s: Span) -> IResult<Span, Config> {
let (s, a) = symbol("config")(s)?;
let (s, a) = keyword("config")(s)?;
Ok((s, Config { nodes: (a,) }))
}

View File

@ -194,7 +194,7 @@ pub struct IdentifierList<'a> {
#[parser]
pub fn constraint_declaration(s: Span) -> IResult<Span, ConstraintDeclaration> {
let (s, a) = opt(r#static)(s)?;
let (s, b) = symbol("constraint")(s)?;
let (s, b) = keyword("constraint")(s)?;
let (s, c) = constraint_identifier(s)?;
let (s, d) = constraint_block(s)?;
Ok((
@ -207,7 +207,7 @@ pub fn constraint_declaration(s: Span) -> IResult<Span, ConstraintDeclaration> {
#[parser]
pub fn r#static(s: Span) -> IResult<Span, Static> {
let (s, a) = symbol("static")(s)?;
let (s, a) = keyword("static")(s)?;
Ok((s, Static { nodes: (a,) }))
}
@ -229,9 +229,9 @@ pub fn constraint_block_item(s: Span) -> IResult<Span, ConstraintBlockItem> {
#[parser]
pub fn constraint_block_item_solve(s: Span) -> IResult<Span, ConstraintBlockItem> {
let (s, a) = symbol("solve")(s)?;
let (s, a) = keyword("solve")(s)?;
let (s, b) = solve_before_list(s)?;
let (s, c) = symbol("before")(s)?;
let (s, c) = keyword("before")(s)?;
let (s, d) = solve_before_list(s)?;
let (s, e) = symbol(";")(s)?;
Ok((
@ -283,7 +283,7 @@ pub fn constraint_expression_expression(s: Span) -> IResult<Span, ConstraintExpr
#[parser]
pub fn soft(s: Span) -> IResult<Span, Soft> {
let (s, a) = symbol("soft")(s)?;
let (s, a) = keyword("soft")(s)?;
Ok((s, Soft { nodes: (a,) }))
}
@ -300,10 +300,10 @@ pub fn constraint_expression_arrow(s: Span) -> IResult<Span, ConstraintExpressio
#[parser]
pub fn constraint_expression_if(s: Span) -> IResult<Span, ConstraintExpression> {
let (s, a) = symbol("if")(s)?;
let (s, a) = keyword("if")(s)?;
let (s, b) = paren(expression)(s)?;
let (s, c) = constraint_set(s)?;
let (s, d) = opt(pair(symbol("else"), constraint_set))(s)?;
let (s, d) = opt(pair(keyword("else"), constraint_set))(s)?;
Ok((
s,
ConstraintExpression::If(ConstraintExpressionIf {
@ -314,7 +314,7 @@ pub fn constraint_expression_if(s: Span) -> IResult<Span, ConstraintExpression>
#[parser]
pub fn constraint_expression_foreach(s: Span) -> IResult<Span, ConstraintExpression> {
let (s, a) = symbol("foreach")(s)?;
let (s, a) = keyword("foreach")(s)?;
let (s, b) = paren(pair(
ps_or_hierarchical_array_identifier,
bracket(loop_variables),
@ -328,8 +328,8 @@ pub fn constraint_expression_foreach(s: Span) -> IResult<Span, ConstraintExpress
#[parser]
pub fn constraint_expression_disable(s: Span) -> IResult<Span, ConstraintExpression> {
let (s, a) = symbol("disable")(s)?;
let (s, b) = symbol("soft")(s)?;
let (s, a) = keyword("disable")(s)?;
let (s, b) = keyword("soft")(s)?;
let (s, c) = constraint_primary(s)?;
let (s, d) = symbol(";")(s)?;
Ok((
@ -342,7 +342,7 @@ pub fn constraint_expression_disable(s: Span) -> IResult<Span, ConstraintExpress
#[parser]
pub fn uniqueness_constraint(s: Span) -> IResult<Span, UniquenessConstraint> {
let (s, a) = symbol("unique")(s)?;
let (s, a) = keyword("unique")(s)?;
let (s, b) = brace(open_range_list)(s)?;
Ok((s, UniquenessConstraint { nodes: (a, b) }))
}
@ -399,7 +399,7 @@ pub fn dist_weight_divide(s: Span) -> IResult<Span, DistWeight> {
pub fn constraint_prototype(s: Span) -> IResult<Span, ConstraintPrototype> {
let (s, a) = opt(constraint_prototype_qualifier)(s)?;
let (s, b) = opt(r#static)(s)?;
let (s, c) = symbol("constraint")(s)?;
let (s, c) = keyword("constraint")(s)?;
let (s, d) = constraint_identifier(s)?;
let (s, e) = symbol(";")(s)?;
Ok((
@ -413,17 +413,17 @@ pub fn constraint_prototype(s: Span) -> IResult<Span, ConstraintPrototype> {
#[parser]
pub fn constraint_prototype_qualifier(s: Span) -> IResult<Span, ConstraintPrototypeQualifier> {
alt((
map(symbol("extern"), |x| {
map(keyword("extern"), |x| {
ConstraintPrototypeQualifier::Extern(x)
}),
map(symbol("pure"), |x| ConstraintPrototypeQualifier::Pure(x)),
map(keyword("pure"), |x| ConstraintPrototypeQualifier::Pure(x)),
))(s)
}
#[parser]
pub fn extern_constraint_declaration(s: Span) -> IResult<Span, ExternConstraintDeclaration> {
let (s, a) = opt(r#static)(s)?;
let (s, b) = symbol("constraint")(s)?;
let (s, b) = keyword("constraint")(s)?;
let (s, c) = class_scope(s)?;
let (s, d) = constraint_identifier(s)?;
let (s, e) = constraint_block(s)?;

View File

@ -93,7 +93,7 @@ pub fn extern_tf_declaration(s: Span) -> IResult<Span, ExternTfDeclaration> {
#[parser]
pub fn extern_tf_declaration_method(s: Span) -> IResult<Span, ExternTfDeclaration> {
let (s, a) = symbol("extern")(s)?;
let (s, a) = keyword("extern")(s)?;
let (s, b) = method_prototype(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
@ -104,8 +104,8 @@ pub fn extern_tf_declaration_method(s: Span) -> IResult<Span, ExternTfDeclaratio
#[parser]
pub fn extern_tf_declaration_task(s: Span) -> IResult<Span, ExternTfDeclaration> {
let (s, a) = symbol("extern")(s)?;
let (s, b) = symbol("forkjoin")(s)?;
let (s, a) = keyword("extern")(s)?;
let (s, b) = keyword("forkjoin")(s)?;
let (s, c) = task_prototype(s)?;
let (s, d) = symbol(";")(s)?;
Ok((

View File

@ -68,10 +68,10 @@ pub fn library_description(s: Span) -> IResult<Span, LibraryDescription> {
#[parser]
pub fn library_declaration(s: Span) -> IResult<Span, LibraryDeclaration> {
let (s, a) = symbol("library")(s)?;
let (s, a) = keyword("library")(s)?;
let (s, b) = library_identifier(s)?;
let (s, c) = list(symbol(","), file_path_spec)(s)?;
let (s, d) = opt(pair(symbol("-incdir"), list(symbol(","), file_path_spec)))(s)?;
let (s, d) = opt(pair(keyword("-incdir"), list(symbol(","), file_path_spec)))(s)?;
let (s, e) = symbol(";")(s)?;
Ok((
s,
@ -83,7 +83,7 @@ pub fn library_declaration(s: Span) -> IResult<Span, LibraryDeclaration> {
#[parser]
pub fn include_statement(s: Span) -> IResult<Span, IncludeStatement> {
let (s, a) = symbol("include")(s)?;
let (s, a) = keyword("include")(s)?;
let (s, b) = file_path_spec(s)?;
let (s, c) = symbol(";")(s)?;
Ok((s, IncludeStatement { nodes: (a, b, c) }))

View File

@ -228,7 +228,7 @@ pub fn elaboration_system_task(s: Span) -> IResult<Span, ElaborationSystemTask>
#[parser]
pub fn elaboration_system_task_fatal(s: Span) -> IResult<Span, ElaborationSystemTask> {
let (s, a) = symbol("$fatal")(s)?;
let (s, a) = keyword("$fatal")(s)?;
let (s, b) = opt(paren(pair(
finish_number,
opt(pair(symbol(","), list_of_arguments)),
@ -242,7 +242,7 @@ pub fn elaboration_system_task_fatal(s: Span) -> IResult<Span, ElaborationSystem
#[parser]
pub fn elaboration_system_task_error(s: Span) -> IResult<Span, ElaborationSystemTask> {
let (s, a) = symbol("$error")(s)?;
let (s, a) = keyword("$error")(s)?;
let (s, b) = opt(paren(opt(list_of_arguments)))(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
@ -253,7 +253,7 @@ pub fn elaboration_system_task_error(s: Span) -> IResult<Span, ElaborationSystem
#[parser]
pub fn elaboration_system_task_warning(s: Span) -> IResult<Span, ElaborationSystemTask> {
let (s, a) = symbol("$warning")(s)?;
let (s, a) = keyword("$warning")(s)?;
let (s, b) = opt(paren(opt(list_of_arguments)))(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
@ -264,7 +264,7 @@ pub fn elaboration_system_task_warning(s: Span) -> IResult<Span, ElaborationSyst
#[parser]
pub fn elaboration_system_task_info(s: Span) -> IResult<Span, ElaborationSystemTask> {
let (s, a) = symbol("$info")(s)?;
let (s, a) = keyword("$info")(s)?;
let (s, b) = opt(paren(opt(list_of_arguments)))(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
@ -409,8 +409,8 @@ pub fn module_or_generate_item_declaration(
pub fn module_or_generate_item_declaration_clocking(
s: Span,
) -> IResult<Span, ModuleOrGenerateItemDeclaration> {
let (s, a) = symbol("default")(s)?;
let (s, b) = symbol("clocking")(s)?;
let (s, a) = keyword("default")(s)?;
let (s, b) = keyword("clocking")(s)?;
let (s, c) = clocking_identifier(s)?;
let (s, d) = symbol(";")(s)?;
Ok((
@ -425,9 +425,9 @@ pub fn module_or_generate_item_declaration_clocking(
pub fn module_or_generate_item_declaration_disable(
s: Span,
) -> IResult<Span, ModuleOrGenerateItemDeclaration> {
let (s, a) = symbol("default")(s)?;
let (s, b) = symbol("disable")(s)?;
let (s, c) = symbol("iff")(s)?;
let (s, a) = keyword("default")(s)?;
let (s, b) = keyword("disable")(s)?;
let (s, c) = keyword("iff")(s)?;
let (s, d) = expression_or_dist(s)?;
let (s, e) = symbol(";")(s)?;
Ok((
@ -474,7 +474,7 @@ pub fn non_port_module_item_specparam(s: Span) -> IResult<Span, NonPortModuleIte
#[parser]
pub fn parameter_override(s: Span) -> IResult<Span, ParameterOverride> {
let (s, a) = symbol("defparam")(s)?;
let (s, a) = keyword("defparam")(s)?;
let (s, b) = list_of_defparam_assignments(s)?;
let (s, c) = symbol(";")(s)?;
Ok((s, ParameterOverride { nodes: (a, b, c) }))
@ -487,7 +487,7 @@ pub fn bind_directive(s: Span) -> IResult<Span, BindDirective> {
#[parser]
pub fn bind_directive_scope(s: Span) -> IResult<Span, BindDirective> {
let (s, a) = symbol("bind")(s)?;
let (s, a) = keyword("bind")(s)?;
let (s, b) = bind_target_scope(s)?;
let (s, c) = opt(pair(symbol(":"), bind_target_instance_list))(s)?;
let (s, d) = bind_instantiation(s)?;
@ -502,7 +502,7 @@ pub fn bind_directive_scope(s: Span) -> IResult<Span, BindDirective> {
#[parser]
pub fn bind_directive_instance(s: Span) -> IResult<Span, BindDirective> {
let (s, a) = symbol("bind")(s)?;
let (s, a) = keyword("bind")(s)?;
let (s, b) = bind_target_instance(s)?;
let (s, c) = bind_instantiation(s)?;
let (s, d) = symbol(";")(s)?;

View File

@ -284,7 +284,7 @@ pub fn parameter_port_declaration_param_list(s: Span) -> IResult<Span, Parameter
#[parser]
pub fn parameter_port_declaration_type_list(s: Span) -> IResult<Span, ParameterPortDeclaration> {
let (s, a) = symbol("type")(s)?;
let (s, a) = keyword("type")(s)?;
let (s, b) = list_of_type_assignments(s)?;
Ok((
s,
@ -414,10 +414,10 @@ pub fn port_reference(s: Span) -> IResult<Span, PortReference> {
#[parser]
pub fn port_direction(s: Span) -> IResult<Span, PortDirection> {
alt((
map(symbol("input"), |x| PortDirection::Input(x)),
map(symbol("output"), |x| PortDirection::Output(x)),
map(symbol("inout"), |x| PortDirection::Inout(x)),
map(symbol("ref"), |x| PortDirection::Ref(x)),
map(keyword("input"), |x| PortDirection::Input(x)),
map(keyword("output"), |x| PortDirection::Output(x)),
map(keyword("inout"), |x| PortDirection::Inout(x)),
map(keyword("ref"), |x| PortDirection::Ref(x)),
))(s)
}
@ -455,7 +455,7 @@ pub fn interface_port_header_identifier(s: Span) -> IResult<Span, InterfacePortH
#[parser]
pub fn interface_port_header_interface(s: Span) -> IResult<Span, InterfacePortHeader> {
let (s, a) = symbol("interface")(s)?;
let (s, a) = keyword("interface")(s)?;
let (s, b) = opt(pair(symbol("."), modport_identifier))(s)?;
Ok((
s,

View File

@ -122,10 +122,10 @@ pub fn package_or_generate_item_declaration(
#[parser]
pub fn anonymous_program(s: Span) -> IResult<Span, AnonymousProgram> {
let (s, a) = symbol("program")(s)?;
let (s, a) = keyword("program")(s)?;
let (s, b) = symbol(";")(s)?;
let (s, c) = many0(anonymous_program_item)(s)?;
let (s, d) = symbol("endprogram")(s)?;
let (s, d) = keyword("endprogram")(s)?;
Ok((
s,
AnonymousProgram {

View File

@ -532,7 +532,7 @@ pub fn module_declaration_nonansi(s: Span) -> IResult<Span, ModuleDeclaration> {
let (s, a) = module_nonansi_header(s)?;
let (s, b) = opt(timeunits_declaration)(s)?;
let (s, c) = many0(module_item)(s)?;
let (s, d) = symbol("endmodule")(s)?;
let (s, d) = keyword("endmodule")(s)?;
let (s, e) = opt(pair(symbol(":"), module_identifier))(s)?;
Ok((
s,
@ -547,7 +547,7 @@ pub fn module_declaration_ansi(s: Span) -> IResult<Span, ModuleDeclaration> {
let (s, a) = module_ansi_header(s)?;
let (s, b) = opt(timeunits_declaration)(s)?;
let (s, c) = many0(non_port_module_item)(s)?;
let (s, d) = symbol("endmodule")(s)?;
let (s, d) = keyword("endmodule")(s)?;
let (s, e) = opt(pair(symbol(":"), module_identifier))(s)?;
Ok((
s,
@ -567,7 +567,7 @@ pub fn module_declaration_wildcard(s: Span) -> IResult<Span, ModuleDeclaration>
let (s, f) = symbol(";")(s)?;
let (s, g) = opt(timeunits_declaration)(s)?;
let (s, h) = many0(module_item)(s)?;
let (s, i) = symbol("endmodule")(s)?;
let (s, i) = keyword("endmodule")(s)?;
let (s, j) = opt(pair(symbol(":"), module_identifier))(s)?;
Ok((
s,
@ -579,7 +579,7 @@ pub fn module_declaration_wildcard(s: Span) -> IResult<Span, ModuleDeclaration>
#[parser]
pub fn module_declaration_extern_nonansi(s: Span) -> IResult<Span, ModuleDeclaration> {
let (s, a) = symbol("extern")(s)?;
let (s, a) = keyword("extern")(s)?;
let (s, b) = module_nonansi_header(s)?;
Ok((
s,
@ -589,7 +589,7 @@ pub fn module_declaration_extern_nonansi(s: Span) -> IResult<Span, ModuleDeclara
#[parser]
pub fn module_declaration_extern_ansi(s: Span) -> IResult<Span, ModuleDeclaration> {
let (s, a) = symbol("extern")(s)?;
let (s, a) = keyword("extern")(s)?;
let (s, b) = module_ansi_header(s)?;
Ok((
s,
@ -600,8 +600,8 @@ pub fn module_declaration_extern_ansi(s: Span) -> IResult<Span, ModuleDeclaratio
#[parser]
pub fn module_keyword(s: Span) -> IResult<Span, ModuleKeyword> {
alt((
map(symbol("module"), |x| ModuleKeyword::Module(x)),
map(symbol("macromodule"), |x| ModuleKeyword::Macromodule(x)),
map(keyword("module"), |x| ModuleKeyword::Module(x)),
map(keyword("macromodule"), |x| ModuleKeyword::Macromodule(x)),
))(s)
}
@ -621,7 +621,7 @@ pub fn interface_declaration_nonansi(s: Span) -> IResult<Span, InterfaceDeclarat
let (s, a) = interface_nonansi_header(s)?;
let (s, b) = opt(timeunits_declaration)(s)?;
let (s, c) = many0(interface_item)(s)?;
let (s, d) = symbol("endinterface")(s)?;
let (s, d) = keyword("endinterface")(s)?;
let (s, e) = opt(pair(symbol(":"), interface_identifier))(s)?;
Ok((
s,
@ -636,7 +636,7 @@ pub fn interface_declaration_ansi(s: Span) -> IResult<Span, InterfaceDeclaration
let (s, a) = interface_ansi_header(s)?;
let (s, b) = opt(timeunits_declaration)(s)?;
let (s, c) = many0(non_port_interface_item)(s)?;
let (s, d) = symbol("endinterface")(s)?;
let (s, d) = keyword("endinterface")(s)?;
let (s, e) = opt(pair(symbol(":"), interface_identifier))(s)?;
Ok((
s,
@ -649,14 +649,14 @@ pub fn interface_declaration_ansi(s: Span) -> IResult<Span, InterfaceDeclaration
#[parser]
pub fn interface_declaration_wildcard(s: Span) -> IResult<Span, InterfaceDeclaration> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("interface")(s)?;
let (s, b) = keyword("interface")(s)?;
let (s, c) = opt(lifetime)(s)?;
let (s, d) = interface_identifier(s)?;
let (s, e) = paren(symbol(".*"))(s)?;
let (s, f) = symbol(";")(s)?;
let (s, g) = opt(timeunits_declaration)(s)?;
let (s, h) = many0(interface_item)(s)?;
let (s, i) = symbol("endinterface")(s)?;
let (s, i) = keyword("endinterface")(s)?;
let (s, j) = opt(pair(symbol(":"), interface_identifier))(s)?;
Ok((
s,
@ -668,7 +668,7 @@ pub fn interface_declaration_wildcard(s: Span) -> IResult<Span, InterfaceDeclara
#[parser]
pub fn interface_declaration_extern_nonansi(s: Span) -> IResult<Span, InterfaceDeclaration> {
let (s, a) = symbol("extern")(s)?;
let (s, a) = keyword("extern")(s)?;
let (s, b) = interface_nonansi_header(s)?;
Ok((
s,
@ -678,7 +678,7 @@ pub fn interface_declaration_extern_nonansi(s: Span) -> IResult<Span, InterfaceD
#[parser]
pub fn interface_declaration_extern_ansi(s: Span) -> IResult<Span, InterfaceDeclaration> {
let (s, a) = symbol("extern")(s)?;
let (s, a) = keyword("extern")(s)?;
let (s, b) = interface_ansi_header(s)?;
Ok((
s,
@ -689,7 +689,7 @@ pub fn interface_declaration_extern_ansi(s: Span) -> IResult<Span, InterfaceDecl
#[parser]
pub fn interface_nonansi_header(s: Span) -> IResult<Span, InterfaceNonansiHeader> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("interface")(s)?;
let (s, b) = keyword("interface")(s)?;
let (s, c) = opt(lifetime)(s)?;
let (s, d) = interface_identifier(s)?;
let (s, e) = many0(package_import_declaration)(s)?;
@ -707,7 +707,7 @@ pub fn interface_nonansi_header(s: Span) -> IResult<Span, InterfaceNonansiHeader
#[parser]
pub fn interface_ansi_header(s: Span) -> IResult<Span, InterfaceAnsiHeader> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("interface")(s)?;
let (s, b) = keyword("interface")(s)?;
let (s, c) = opt(lifetime)(s)?;
let (s, d) = interface_identifier(s)?;
let (s, e) = many0(package_import_declaration)(s)?;
@ -738,7 +738,7 @@ pub fn program_declaration_nonansi(s: Span) -> IResult<Span, ProgramDeclaration>
let (s, a) = program_nonansi_header(s)?;
let (s, b) = opt(timeunits_declaration)(s)?;
let (s, c) = many0(program_item)(s)?;
let (s, d) = symbol("endprogram")(s)?;
let (s, d) = keyword("endprogram")(s)?;
let (s, e) = opt(pair(symbol(":"), program_identifier))(s)?;
Ok((
s,
@ -753,7 +753,7 @@ pub fn program_declaration_ansi(s: Span) -> IResult<Span, ProgramDeclaration> {
let (s, a) = program_ansi_header(s)?;
let (s, b) = opt(timeunits_declaration)(s)?;
let (s, c) = many0(non_port_program_item)(s)?;
let (s, d) = symbol("endprogram")(s)?;
let (s, d) = keyword("endprogram")(s)?;
let (s, e) = opt(pair(symbol(":"), program_identifier))(s)?;
Ok((
s,
@ -766,13 +766,13 @@ pub fn program_declaration_ansi(s: Span) -> IResult<Span, ProgramDeclaration> {
#[parser]
pub fn program_declaration_wildcard(s: Span) -> IResult<Span, ProgramDeclaration> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("program")(s)?;
let (s, b) = keyword("program")(s)?;
let (s, c) = program_identifier(s)?;
let (s, d) = paren(symbol(".*"))(s)?;
let (s, e) = symbol(";")(s)?;
let (s, f) = opt(timeunits_declaration)(s)?;
let (s, g) = many0(program_item)(s)?;
let (s, h) = symbol("endprogram")(s)?;
let (s, h) = keyword("endprogram")(s)?;
let (s, i) = opt(pair(symbol(":"), program_identifier))(s)?;
Ok((
s,
@ -784,7 +784,7 @@ pub fn program_declaration_wildcard(s: Span) -> IResult<Span, ProgramDeclaration
#[parser]
pub fn program_declaration_extern_nonansi(s: Span) -> IResult<Span, ProgramDeclaration> {
let (s, a) = symbol("extern")(s)?;
let (s, a) = keyword("extern")(s)?;
let (s, b) = program_nonansi_header(s)?;
Ok((
s,
@ -794,7 +794,7 @@ pub fn program_declaration_extern_nonansi(s: Span) -> IResult<Span, ProgramDecla
#[parser]
pub fn program_declaration_extern_ansi(s: Span) -> IResult<Span, ProgramDeclaration> {
let (s, a) = symbol("extern")(s)?;
let (s, a) = keyword("extern")(s)?;
let (s, b) = program_ansi_header(s)?;
Ok((
s,
@ -805,7 +805,7 @@ pub fn program_declaration_extern_ansi(s: Span) -> IResult<Span, ProgramDeclarat
#[parser]
pub fn program_nonansi_header(s: Span) -> IResult<Span, ProgramNonansiHeader> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("prgogram")(s)?;
let (s, b) = keyword("prgogram")(s)?;
let (s, c) = opt(lifetime)(s)?;
let (s, d) = program_identifier(s)?;
let (s, e) = many0(package_import_declaration)(s)?;
@ -823,7 +823,7 @@ pub fn program_nonansi_header(s: Span) -> IResult<Span, ProgramNonansiHeader> {
#[parser]
pub fn program_ansi_header(s: Span) -> IResult<Span, ProgramAnsiHeader> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("program")(s)?;
let (s, b) = keyword("program")(s)?;
let (s, c) = opt(lifetime)(s)?;
let (s, d) = program_identifier(s)?;
let (s, e) = many0(package_import_declaration)(s)?;
@ -840,12 +840,12 @@ pub fn program_ansi_header(s: Span) -> IResult<Span, ProgramAnsiHeader> {
#[parser]
pub fn checker_declaration(s: Span) -> IResult<Span, CheckerDeclaration> {
let (s, a) = symbol("checker")(s)?;
let (s, a) = keyword("checker")(s)?;
let (s, b) = checker_identifier(s)?;
let (s, c) = opt(paren(opt(checker_port_list)))(s)?;
let (s, d) = symbol(";")(s)?;
let (s, e) = many0(pair(many0(attribute_instance), checker_or_generate_item))(s)?;
let (s, f) = symbol("endchecker")(s)?;
let (s, f) = keyword("endchecker")(s)?;
let (s, g) = opt(pair(symbol(":"), checker_identifier))(s)?;
Ok((
s,
@ -857,23 +857,23 @@ pub fn checker_declaration(s: Span) -> IResult<Span, CheckerDeclaration> {
#[parser]
pub fn class_declaration(s: Span) -> IResult<Span, ClassDeclaration> {
let (s, a) = opt(map(symbol("virtual"), |x| Virtual { nodes: (x,) }))(s)?;
let (s, b) = symbol("class")(s)?;
let (s, a) = opt(map(keyword("virtual"), |x| Virtual { nodes: (x,) }))(s)?;
let (s, b) = keyword("class")(s)?;
let (s, c) = opt(lifetime)(s)?;
let (s, d) = class_identifier(s)?;
let (s, e) = opt(parameter_port_list)(s)?;
let (s, f) = opt(triple(
symbol("extends"),
keyword("extends"),
class_type,
opt(paren(list_of_arguments)),
))(s)?;
let (s, g) = opt(pair(
symbol("implements"),
keyword("implements"),
list(symbol(","), interface_class_type),
))(s)?;
let (s, h) = symbol(";")(s)?;
let (s, i) = many0(class_item)(s)?;
let (s, j) = symbol("endclass")(s)?;
let (s, j) = keyword("endclass")(s)?;
let (s, k) = opt(pair(symbol(":"), class_identifier))(s)?;
Ok((
s,
@ -892,17 +892,17 @@ pub fn interface_class_type(s: Span) -> IResult<Span, InterfaceClassType> {
#[parser]
pub fn interface_class_declaration(s: Span) -> IResult<Span, InterfaceClassDeclaration> {
let (s, a) = symbol("interface")(s)?;
let (s, b) = symbol("class")(s)?;
let (s, a) = keyword("interface")(s)?;
let (s, b) = keyword("class")(s)?;
let (s, c) = class_identifier(s)?;
let (s, d) = opt(parameter_port_list)(s)?;
let (s, e) = opt(pair(
symbol("extends"),
keyword("extends"),
list(symbol(","), interface_class_type),
))(s)?;
let (s, f) = symbol(";")(s)?;
let (s, g) = many0(interface_class_item)(s)?;
let (s, h) = symbol("endclass")(s)?;
let (s, h) = keyword("endclass")(s)?;
let (s, i) = opt(pair(symbol(":"), class_identifier))(s)?;
Ok((
s,
@ -939,8 +939,8 @@ pub fn interface_class_item_method(s: Span) -> IResult<Span, InterfaceClassItem>
#[parser]
pub fn interface_class_method(s: Span) -> IResult<Span, InterfaceClassMethod> {
let (s, a) = symbol("pure")(s)?;
let (s, b) = symbol("virtual")(s)?;
let (s, a) = keyword("pure")(s)?;
let (s, b) = keyword("virtual")(s)?;
let (s, c) = method_prototype(s)?;
let (s, d) = symbol(";")(s)?;
Ok((
@ -954,13 +954,13 @@ pub fn interface_class_method(s: Span) -> IResult<Span, InterfaceClassMethod> {
#[parser]
pub fn package_declaration(s: Span) -> IResult<Span, PackageDeclaration> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("package")(s)?;
let (s, b) = keyword("package")(s)?;
let (s, c) = opt(lifetime)(s)?;
let (s, d) = package_identifier(s)?;
let (s, e) = symbol(";")(s)?;
let (s, f) = opt(timeunits_declaration)(s)?;
let (s, g) = many0(pair(many0(attribute_instance), package_item))(s)?;
let (s, h) = symbol("endpackage")(s)?;
let (s, h) = keyword("endpackage")(s)?;
let (s, i) = opt(pair(symbol(":"), package_identifier))(s)?;
Ok((
s,
@ -982,7 +982,7 @@ pub fn timeunits_declaration(s: Span) -> IResult<Span, TimeunitsDeclaration> {
#[parser]
pub fn timeunits_declaration_timeunit(s: Span) -> IResult<Span, TimeunitsDeclaration> {
let (s, a) = symbol("timeunit")(s)?;
let (s, a) = keyword("timeunit")(s)?;
let (s, b) = time_literal(s)?;
let (s, c) = opt(pair(symbol("/"), time_literal))(s)?;
let (s, d) = symbol(";")(s)?;
@ -996,7 +996,7 @@ pub fn timeunits_declaration_timeunit(s: Span) -> IResult<Span, TimeunitsDeclara
#[parser]
pub fn timeunits_declaration_timeprecision(s: Span) -> IResult<Span, TimeunitsDeclaration> {
let (s, a) = symbol("timeprecision")(s)?;
let (s, a) = keyword("timeprecision")(s)?;
let (s, b) = time_literal(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
@ -1009,10 +1009,10 @@ pub fn timeunits_declaration_timeprecision(s: Span) -> IResult<Span, TimeunitsDe
pub fn timeunits_declaration_timeunit_timeprecision(
s: Span,
) -> IResult<Span, TimeunitsDeclaration> {
let (s, a) = symbol("timeunit")(s)?;
let (s, a) = keyword("timeunit")(s)?;
let (s, b) = time_literal(s)?;
let (s, c) = symbol(";")(s)?;
let (s, d) = symbol("timeprecision")(s)?;
let (s, d) = keyword("timeprecision")(s)?;
let (s, e) = time_literal(s)?;
let (s, f) = symbol(";")(s)?;
Ok((
@ -1027,10 +1027,10 @@ pub fn timeunits_declaration_timeunit_timeprecision(
pub fn timeunits_declaration_timeprecision_timeunit(
s: Span,
) -> IResult<Span, TimeunitsDeclaration> {
let (s, a) = symbol("timeprecision")(s)?;
let (s, a) = keyword("timeprecision")(s)?;
let (s, b) = time_literal(s)?;
let (s, c) = symbol(";")(s)?;
let (s, d) = symbol("timeunit")(s)?;
let (s, d) = keyword("timeunit")(s)?;
let (s, e) = time_literal(s)?;
let (s, f) = symbol(";")(s)?;
Ok((

View File

@ -35,9 +35,9 @@ pub struct ShowcancelledDeclaration<'a> {
#[parser]
pub fn specify_block(s: Span) -> IResult<Span, SpecifyBlock> {
let (s, a) = symbol("specify")(s)?;
let (s, a) = keyword("specify")(s)?;
let (s, b) = many0(specify_item)(s)?;
let (s, c) = symbol("endspecify")(s)?;
let (s, c) = keyword("endspecify")(s)?;
Ok((s, SpecifyBlock { nodes: (a, b, c) }))
}
@ -60,7 +60,10 @@ pub fn specify_item(s: Span) -> IResult<Span, SpecifyItem> {
#[parser]
pub fn pulsestyle_declaration(s: Span) -> IResult<Span, PulsestyleDeclaration> {
let (s, a) = alt((symbol("pulsestyle_onevent"), symbol("pulsestyle_ondetect")))(s)?;
let (s, a) = alt((
keyword("pulsestyle_onevent"),
keyword("pulsestyle_ondetect"),
))(s)?;
let (s, b) = list_of_path_outputs(s)?;
let (s, c) = symbol(";")(s)?;
Ok((s, PulsestyleDeclaration { nodes: (a, b, c) }))
@ -68,7 +71,7 @@ pub fn pulsestyle_declaration(s: Span) -> IResult<Span, PulsestyleDeclaration> {
#[parser]
pub fn showcancelled_declaration(s: Span) -> IResult<Span, ShowcancelledDeclaration> {
let (s, a) = alt((symbol("showcalcelled"), symbol("noshowcancelled")))(s)?;
let (s, a) = alt((keyword("showcalcelled"), keyword("noshowcancelled")))(s)?;
let (s, b) = list_of_path_outputs(s)?;
let (s, c) = symbol(";")(s)?;
Ok((s, ShowcancelledDeclaration { nodes: (a, b, c) }))

View File

@ -273,9 +273,9 @@ pub fn data_source_expression(s: Span) -> IResult<Span, DataSourceExpression> {
#[parser]
pub fn edge_identifier(s: Span) -> IResult<Span, EdgeIdentifier> {
alt((
map(symbol("posedge"), |x| EdgeIdentifier::Posedge(x)),
map(symbol("negedge"), |x| EdgeIdentifier::Negedge(x)),
map(symbol("edge"), |x| EdgeIdentifier::Edge(x)),
map(keyword("posedge"), |x| EdgeIdentifier::Posedge(x)),
map(keyword("negedge"), |x| EdgeIdentifier::Negedge(x)),
map(keyword("edge"), |x| EdgeIdentifier::Edge(x)),
))(s)
}
@ -292,7 +292,7 @@ pub fn state_dependent_path_declaration(s: Span) -> IResult<Span, StateDependent
pub fn state_dependent_path_declaration_if_simple(
s: Span,
) -> IResult<Span, StateDependentPathDeclaration> {
let (s, a) = symbol("if")(s)?;
let (s, a) = keyword("if")(s)?;
let (s, b) = paren(module_path_expression)(s)?;
let (s, c) = simple_path_declaration(s)?;
Ok((
@ -307,7 +307,7 @@ pub fn state_dependent_path_declaration_if_simple(
pub fn state_dependent_path_declaration_if_edge_sensitive(
s: Span,
) -> IResult<Span, StateDependentPathDeclaration> {
let (s, a) = symbol("if")(s)?;
let (s, a) = keyword("if")(s)?;
let (s, b) = paren(module_path_expression)(s)?;
let (s, c) = edge_sensitive_path_declaration(s)?;
Ok((
@ -322,7 +322,7 @@ pub fn state_dependent_path_declaration_if_edge_sensitive(
pub fn state_dependent_path_declaration_if_none(
s: Span,
) -> IResult<Span, StateDependentPathDeclaration> {
let (s, a) = symbol("ifnone")(s)?;
let (s, a) = keyword("ifnone")(s)?;
let (s, b) = simple_path_declaration(s)?;
Ok((
s,

View File

@ -347,7 +347,7 @@ pub fn system_timing_check(s: Span) -> IResult<Span, SystemTimingCheck> {
#[parser]
pub fn setup_timing_check(s: Span) -> IResult<Span, SetupTimingCheck> {
let (s, a) = symbol("$setup")(s)?;
let (s, a) = keyword("$setup")(s)?;
let (s, b) = paren(tuple((
data_event,
symbol(","),
@ -362,7 +362,7 @@ pub fn setup_timing_check(s: Span) -> IResult<Span, SetupTimingCheck> {
#[parser]
pub fn hold_timing_check(s: Span) -> IResult<Span, HoldTimingCheck> {
let (s, a) = symbol("$setup")(s)?;
let (s, a) = keyword("$setup")(s)?;
let (s, b) = paren(tuple((
referecne_event,
symbol(","),
@ -377,7 +377,7 @@ pub fn hold_timing_check(s: Span) -> IResult<Span, HoldTimingCheck> {
#[parser]
pub fn setuphold_timing_check(s: Span) -> IResult<Span, SetupholdTimingCheck> {
let (s, a) = symbol("$setuphold")(s)?;
let (s, a) = keyword("$setuphold")(s)?;
let (s, b) = paren(tuple((
referecne_event,
symbol(","),
@ -410,7 +410,7 @@ pub fn setuphold_timing_check(s: Span) -> IResult<Span, SetupholdTimingCheck> {
#[parser]
pub fn recovery_timing_check(s: Span) -> IResult<Span, RecoveryTimingCheck> {
let (s, a) = symbol("$recovery")(s)?;
let (s, a) = keyword("$recovery")(s)?;
let (s, b) = paren(tuple((
referecne_event,
symbol(","),
@ -425,7 +425,7 @@ pub fn recovery_timing_check(s: Span) -> IResult<Span, RecoveryTimingCheck> {
#[parser]
pub fn removal_timing_check(s: Span) -> IResult<Span, RemovalTimingCheck> {
let (s, a) = symbol("$removal")(s)?;
let (s, a) = keyword("$removal")(s)?;
let (s, b) = paren(tuple((
referecne_event,
symbol(","),
@ -440,7 +440,7 @@ pub fn removal_timing_check(s: Span) -> IResult<Span, RemovalTimingCheck> {
#[parser]
pub fn recrem_timing_check(s: Span) -> IResult<Span, RecremTimingCheck> {
let (s, a) = symbol("$recrem")(s)?;
let (s, a) = keyword("$recrem")(s)?;
let (s, b) = paren(tuple((
referecne_event,
symbol(","),
@ -473,7 +473,7 @@ pub fn recrem_timing_check(s: Span) -> IResult<Span, RecremTimingCheck> {
#[parser]
pub fn skew_timing_check(s: Span) -> IResult<Span, SkewTimingCheck> {
let (s, a) = symbol("$skew")(s)?;
let (s, a) = keyword("$skew")(s)?;
let (s, b) = paren(tuple((
referecne_event,
symbol(","),
@ -488,7 +488,7 @@ pub fn skew_timing_check(s: Span) -> IResult<Span, SkewTimingCheck> {
#[parser]
pub fn timeskew_timing_check(s: Span) -> IResult<Span, TimeskewTimingCheck> {
let (s, a) = symbol("$timeskew")(s)?;
let (s, a) = keyword("$timeskew")(s)?;
let (s, b) = paren(tuple((
referecne_event,
symbol(","),
@ -511,7 +511,7 @@ pub fn timeskew_timing_check(s: Span) -> IResult<Span, TimeskewTimingCheck> {
#[parser]
pub fn fullskew_timing_check(s: Span) -> IResult<Span, FullskewTimingCheck> {
let (s, a) = symbol("$fullskew")(s)?;
let (s, a) = keyword("$fullskew")(s)?;
let (s, b) = paren(tuple((
referecne_event,
symbol(","),
@ -536,7 +536,7 @@ pub fn fullskew_timing_check(s: Span) -> IResult<Span, FullskewTimingCheck> {
#[parser]
pub fn period_timing_check(s: Span) -> IResult<Span, PeriodTimingCheck> {
let (s, a) = symbol("$period")(s)?;
let (s, a) = keyword("$period")(s)?;
let (s, b) = paren(tuple((
controlled_referecne_event,
symbol(","),
@ -549,7 +549,7 @@ pub fn period_timing_check(s: Span) -> IResult<Span, PeriodTimingCheck> {
#[parser]
pub fn width_timing_check(s: Span) -> IResult<Span, WidthTimingCheck> {
let (s, a) = symbol("$width")(s)?;
let (s, a) = keyword("$width")(s)?;
let (s, b) = paren(tuple((
controlled_referecne_event,
symbol(","),
@ -564,7 +564,7 @@ pub fn width_timing_check(s: Span) -> IResult<Span, WidthTimingCheck> {
#[parser]
pub fn nocharge_timing_check(s: Span) -> IResult<Span, NochargeTimingCheck> {
let (s, a) = symbol("$nocharge")(s)?;
let (s, a) = keyword("$nocharge")(s)?;
let (s, b) = paren(tuple((
referecne_event,
symbol(","),

View File

@ -106,9 +106,9 @@ pub fn controlled_timing_check_event(s: Span) -> IResult<Span, ControlledTimingC
#[parser]
pub fn timing_check_event_control(s: Span) -> IResult<Span, TimingCheckEventControl> {
alt((
map(symbol("posedge"), |x| TimingCheckEventControl::Posedge(x)),
map(symbol("negedge"), |x| TimingCheckEventControl::Negedge(x)),
map(symbol("edge"), |x| TimingCheckEventControl::Edge(x)),
map(keyword("posedge"), |x| TimingCheckEventControl::Posedge(x)),
map(keyword("negedge"), |x| TimingCheckEventControl::Negedge(x)),
map(keyword("edge"), |x| TimingCheckEventControl::Edge(x)),
map(edge_control_specifier, |x| {
TimingCheckEventControl::EdgeControlSpecifier(x)
}),
@ -129,7 +129,7 @@ pub fn specify_terminal_descriptor(s: Span) -> IResult<Span, SpecifyTerminalDesc
#[parser]
pub fn edge_control_specifier(s: Span) -> IResult<Span, EdgeControlSpecifier> {
let (s, a) = symbol("edge")(s)?;
let (s, a) = keyword("edge")(s)?;
let (s, b) = bracket(list(symbol(","), edge_descriptor))(s)?;
Ok((s, EdgeControlSpecifier { nodes: (a, b) }))
}
@ -137,24 +137,24 @@ pub fn edge_control_specifier(s: Span) -> IResult<Span, EdgeControlSpecifier> {
#[parser]
pub fn edge_descriptor(s: Span) -> IResult<Span, EdgeDescriptor> {
alt((
map(symbol("01"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("10"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("x0"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("x1"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("X0"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("X1"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("z0"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("z1"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("Z0"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("Z1"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("0x"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("1x"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("0X"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("1X"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("0z"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("1z"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("0Z"), |x| EdgeDescriptor { nodes: (x,) }),
map(symbol("1Z"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("01"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("10"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("x0"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("x1"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("X0"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("X1"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("z0"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("z1"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("Z0"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("Z1"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("0x"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("1x"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("0X"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("1X"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("0z"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("1z"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("0Z"), |x| EdgeDescriptor { nodes: (x,) }),
map(keyword("1Z"), |x| EdgeDescriptor { nodes: (x,) }),
))(s)
}
@ -210,15 +210,15 @@ pub fn scalar_timing_check_condition_binary(s: Span) -> IResult<Span, ScalarTimi
#[parser]
pub fn scalar_constant(s: Span) -> IResult<Span, ScalarConstant> {
alt((
map(symbol("1'b0"), |x| ScalarConstant { nodes: (x,) }),
map(symbol("1'b1"), |x| ScalarConstant { nodes: (x,) }),
map(symbol("1'B0"), |x| ScalarConstant { nodes: (x,) }),
map(symbol("1'B1"), |x| ScalarConstant { nodes: (x,) }),
map(symbol("'b0"), |x| ScalarConstant { nodes: (x,) }),
map(symbol("'b1"), |x| ScalarConstant { nodes: (x,) }),
map(symbol("'B0"), |x| ScalarConstant { nodes: (x,) }),
map(symbol("'B1"), |x| ScalarConstant { nodes: (x,) }),
map(symbol("1"), |x| ScalarConstant { nodes: (x,) }),
map(symbol("0"), |x| ScalarConstant { nodes: (x,) }),
map(keyword("1'b0"), |x| ScalarConstant { nodes: (x,) }),
map(keyword("1'b1"), |x| ScalarConstant { nodes: (x,) }),
map(keyword("1'B0"), |x| ScalarConstant { nodes: (x,) }),
map(keyword("1'B1"), |x| ScalarConstant { nodes: (x,) }),
map(keyword("'b0"), |x| ScalarConstant { nodes: (x,) }),
map(keyword("'b1"), |x| ScalarConstant { nodes: (x,) }),
map(keyword("'B0"), |x| ScalarConstant { nodes: (x,) }),
map(keyword("'B1"), |x| ScalarConstant { nodes: (x,) }),
map(keyword("1"), |x| ScalarConstant { nodes: (x,) }),
map(keyword("0"), |x| ScalarConstant { nodes: (x,) }),
))(s)
}

View File

@ -137,10 +137,10 @@ pub fn udp_body(s: Span) -> IResult<Span, UdpBody> {
#[parser]
pub fn combinational_body(s: Span) -> IResult<Span, CombinationalBody> {
let (s, a) = symbol("table")(s)?;
let (s, a) = keyword("table")(s)?;
let (s, b) = combinational_entry(s)?;
let (s, c) = many0(combinational_entry)(s)?;
let (s, d) = symbol("endtable")(s)?;
let (s, d) = keyword("endtable")(s)?;
Ok((
s,
CombinationalBody {
@ -166,10 +166,10 @@ pub fn combinational_entry(s: Span) -> IResult<Span, CombinationalEntry> {
#[parser]
pub fn sequential_body(s: Span) -> IResult<Span, SequentialBody> {
let (s, a) = opt(udp_initial_statement)(s)?;
let (s, b) = symbol("table")(s)?;
let (s, b) = keyword("table")(s)?;
let (s, c) = sequential_entry(s)?;
let (s, d) = many0(sequential_entry)(s)?;
let (s, e) = symbol("endtable")(s)?;
let (s, e) = keyword("endtable")(s)?;
Ok((
s,
SequentialBody {
@ -180,7 +180,7 @@ pub fn sequential_body(s: Span) -> IResult<Span, SequentialBody> {
#[parser]
pub fn udp_initial_statement(s: Span) -> IResult<Span, UdpInitialStatement> {
let (s, a) = symbol("initial")(s)?;
let (s, a) = keyword("initial")(s)?;
let (s, b) = output_port_identifier(s)?;
let (s, c) = symbol("=")(s)?;
let (s, d) = init_val(s)?;
@ -196,16 +196,16 @@ pub fn udp_initial_statement(s: Span) -> IResult<Span, UdpInitialStatement> {
#[parser]
pub fn init_val(s: Span) -> IResult<Span, InitVal> {
alt((
map(symbol("1'b0"), |x| InitVal { nodes: (x,) }),
map(symbol("1'b1"), |x| InitVal { nodes: (x,) }),
map(symbol("1'bx"), |x| InitVal { nodes: (x,) }),
map(symbol("1'bX"), |x| InitVal { nodes: (x,) }),
map(symbol("1'B0"), |x| InitVal { nodes: (x,) }),
map(symbol("1'B1"), |x| InitVal { nodes: (x,) }),
map(symbol("1'Bx"), |x| InitVal { nodes: (x,) }),
map(symbol("1'BX"), |x| InitVal { nodes: (x,) }),
map(symbol("1"), |x| InitVal { nodes: (x,) }),
map(symbol("0"), |x| InitVal { nodes: (x,) }),
map(keyword("1'b0"), |x| InitVal { nodes: (x,) }),
map(keyword("1'b1"), |x| InitVal { nodes: (x,) }),
map(keyword("1'bx"), |x| InitVal { nodes: (x,) }),
map(keyword("1'bX"), |x| InitVal { nodes: (x,) }),
map(keyword("1'B0"), |x| InitVal { nodes: (x,) }),
map(keyword("1'B1"), |x| InitVal { nodes: (x,) }),
map(keyword("1'Bx"), |x| InitVal { nodes: (x,) }),
map(keyword("1'BX"), |x| InitVal { nodes: (x,) }),
map(keyword("1"), |x| InitVal { nodes: (x,) }),
map(keyword("0"), |x| InitVal { nodes: (x,) }),
))(s)
}
@ -279,37 +279,37 @@ pub fn next_state(s: Span) -> IResult<Span, NextState> {
#[parser]
pub fn output_symbol(s: Span) -> IResult<Span, OutputSymbol> {
alt((
map(symbol("0"), |x| OutputSymbol { nodes: (x,) }),
map(symbol("1"), |x| OutputSymbol { nodes: (x,) }),
map(symbol("x"), |x| OutputSymbol { nodes: (x,) }),
map(symbol("X"), |x| OutputSymbol { nodes: (x,) }),
map(keyword("0"), |x| OutputSymbol { nodes: (x,) }),
map(keyword("1"), |x| OutputSymbol { nodes: (x,) }),
map(keyword("x"), |x| OutputSymbol { nodes: (x,) }),
map(keyword("X"), |x| OutputSymbol { nodes: (x,) }),
))(s)
}
#[parser]
pub fn level_symbol(s: Span) -> IResult<Span, LevelSymbol> {
alt((
map(symbol("0"), |x| LevelSymbol { nodes: (x,) }),
map(symbol("1"), |x| LevelSymbol { nodes: (x,) }),
map(symbol("x"), |x| LevelSymbol { nodes: (x,) }),
map(symbol("X"), |x| LevelSymbol { nodes: (x,) }),
map(symbol("?"), |x| LevelSymbol { nodes: (x,) }),
map(symbol("b"), |x| LevelSymbol { nodes: (x,) }),
map(symbol("B"), |x| LevelSymbol { nodes: (x,) }),
map(keyword("0"), |x| LevelSymbol { nodes: (x,) }),
map(keyword("1"), |x| LevelSymbol { nodes: (x,) }),
map(keyword("x"), |x| LevelSymbol { nodes: (x,) }),
map(keyword("X"), |x| LevelSymbol { nodes: (x,) }),
map(keyword("?"), |x| LevelSymbol { nodes: (x,) }),
map(keyword("b"), |x| LevelSymbol { nodes: (x,) }),
map(keyword("B"), |x| LevelSymbol { nodes: (x,) }),
))(s)
}
#[parser]
pub fn edge_symbol(s: Span) -> IResult<Span, EdgeSymbol> {
alt((
map(symbol("r"), |x| EdgeSymbol { nodes: (x,) }),
map(symbol("R"), |x| EdgeSymbol { nodes: (x,) }),
map(symbol("f"), |x| EdgeSymbol { nodes: (x,) }),
map(symbol("F"), |x| EdgeSymbol { nodes: (x,) }),
map(symbol("p"), |x| EdgeSymbol { nodes: (x,) }),
map(symbol("P"), |x| EdgeSymbol { nodes: (x,) }),
map(symbol("n"), |x| EdgeSymbol { nodes: (x,) }),
map(symbol("N"), |x| EdgeSymbol { nodes: (x,) }),
map(symbol("*"), |x| EdgeSymbol { nodes: (x,) }),
map(keyword("r"), |x| EdgeSymbol { nodes: (x,) }),
map(keyword("R"), |x| EdgeSymbol { nodes: (x,) }),
map(keyword("f"), |x| EdgeSymbol { nodes: (x,) }),
map(keyword("F"), |x| EdgeSymbol { nodes: (x,) }),
map(keyword("p"), |x| EdgeSymbol { nodes: (x,) }),
map(keyword("P"), |x| EdgeSymbol { nodes: (x,) }),
map(keyword("n"), |x| EdgeSymbol { nodes: (x,) }),
map(keyword("N"), |x| EdgeSymbol { nodes: (x,) }),
map(keyword("*"), |x| EdgeSymbol { nodes: (x,) }),
))(s)
}

View File

@ -91,7 +91,7 @@ pub struct UdpDeclarationWildcard<'a> {
#[parser]
pub fn udp_nonansi_declaration(s: Span) -> IResult<Span, UdpNonansiDeclaration> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("primitive")(s)?;
let (s, b) = keyword("primitive")(s)?;
let (s, c) = udp_identifier(s)?;
let (s, d) = paren(udp_port_list)(s)?;
let (s, e) = symbol(";")(s)?;
@ -106,7 +106,7 @@ pub fn udp_nonansi_declaration(s: Span) -> IResult<Span, UdpNonansiDeclaration>
#[parser]
pub fn udp_ansi_declaration(s: Span) -> IResult<Span, UdpAnsiDeclaration> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("primitive")(s)?;
let (s, b) = keyword("primitive")(s)?;
let (s, c) = udp_identifier(s)?;
let (s, d) = paren(udp_declaration_port_list)(s)?;
let (s, e) = symbol(";")(s)?;
@ -135,7 +135,7 @@ pub fn udp_declaration_nonansi(s: Span) -> IResult<Span, UdpDeclaration> {
let (s, b) = udp_port_declaration(s)?;
let (s, c) = many0(udp_port_declaration)(s)?;
let (s, d) = udp_body(s)?;
let (s, e) = symbol("endprimitive")(s)?;
let (s, e) = keyword("endprimitive")(s)?;
let (s, f) = opt(pair(symbol(":"), udp_identifier))(s)?;
Ok((
s,
@ -149,7 +149,7 @@ pub fn udp_declaration_nonansi(s: Span) -> IResult<Span, UdpDeclaration> {
pub fn udp_declaration_ansi(s: Span) -> IResult<Span, UdpDeclaration> {
let (s, a) = udp_ansi_declaration(s)?;
let (s, b) = udp_body(s)?;
let (s, c) = symbol("endprimitive")(s)?;
let (s, c) = keyword("endprimitive")(s)?;
let (s, d) = opt(pair(symbol(":"), udp_identifier))(s)?;
Ok((
s,
@ -161,7 +161,7 @@ pub fn udp_declaration_ansi(s: Span) -> IResult<Span, UdpDeclaration> {
#[parser]
pub fn udp_declaration_extern_nonansi(s: Span) -> IResult<Span, UdpDeclaration> {
let (s, a) = symbol("extern")(s)?;
let (s, a) = keyword("extern")(s)?;
let (s, b) = udp_nonansi_declaration(s)?;
Ok((
s,
@ -171,7 +171,7 @@ pub fn udp_declaration_extern_nonansi(s: Span) -> IResult<Span, UdpDeclaration>
#[parser]
pub fn udp_declaration_extern_ansi(s: Span) -> IResult<Span, UdpDeclaration> {
let (s, a) = symbol("extern")(s)?;
let (s, a) = keyword("extern")(s)?;
let (s, b) = udp_ansi_declaration(s)?;
Ok((
s,
@ -182,13 +182,13 @@ pub fn udp_declaration_extern_ansi(s: Span) -> IResult<Span, UdpDeclaration> {
#[parser]
pub fn udp_declaration_wildcard(s: Span) -> IResult<Span, UdpDeclaration> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("primitive")(s)?;
let (s, b) = keyword("primitive")(s)?;
let (s, c) = udp_identifier(s)?;
let (s, d) = paren(symbol(".*"))(s)?;
let (s, e) = symbol(";")(s)?;
let (s, f) = many0(udp_port_declaration)(s)?;
let (s, g) = udp_body(s)?;
let (s, h) = symbol("endprimitive")(s)?;
let (s, h) = keyword("endprimitive")(s)?;
let (s, i) = opt(pair(symbol(":"), udp_identifier))(s)?;
Ok((
s,

View File

@ -114,7 +114,7 @@ pub fn udp_output_declaration(s: Span) -> IResult<Span, UdpOutputDeclaration> {
#[parser]
pub fn udp_output_declaration_nonreg(s: Span) -> IResult<Span, UdpOutputDeclaration> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("output")(s)?;
let (s, b) = keyword("output")(s)?;
let (s, c) = port_identifier(s)?;
Ok((
s,
@ -125,8 +125,8 @@ pub fn udp_output_declaration_nonreg(s: Span) -> IResult<Span, UdpOutputDeclarat
#[parser]
pub fn udp_output_declaration_reg(s: Span) -> IResult<Span, UdpOutputDeclaration> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("output")(s)?;
let (s, c) = symbol("reg")(s)?;
let (s, b) = keyword("output")(s)?;
let (s, c) = keyword("reg")(s)?;
let (s, d) = port_identifier(s)?;
let (s, e) = opt(pair(symbol("="), constant_expression))(s)?;
Ok((
@ -140,7 +140,7 @@ pub fn udp_output_declaration_reg(s: Span) -> IResult<Span, UdpOutputDeclaration
#[parser]
pub fn udp_input_declaration(s: Span) -> IResult<Span, UdpInputDeclaration> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("input")(s)?;
let (s, b) = keyword("input")(s)?;
let (s, c) = list_of_udp_port_identifiers(s)?;
Ok((s, UdpInputDeclaration { nodes: (a, b, c) }))
}
@ -148,7 +148,7 @@ pub fn udp_input_declaration(s: Span) -> IResult<Span, UdpInputDeclaration> {
#[parser]
pub fn udp_reg_declaration(s: Span) -> IResult<Span, UdpRegDeclaration> {
let (s, a) = many0(attribute_instance)(s)?;
let (s, b) = symbol("reg")(s)?;
let (s, b) = keyword("reg")(s)?;
let (s, c) = variable_identifier(s)?;
Ok((s, UdpRegDeclaration { nodes: (a, b, c) }))
}

View File

@ -5,10 +5,262 @@ use nom::bytes::complete::*;
use nom::character::complete::*;
use nom::combinator::*;
use nom::multi::*;
use nom::sequence::*;
use nom::IResult;
// -----------------------------------------------------------------------------
const KEYWORDS: &[&str] = &[
"accept_on",
"alias",
"always",
"always_comb",
"always_ff",
"always_latch",
"and",
"assert",
"assign",
"assume",
"automatic",
"before",
"begin",
"bind",
"bins",
"binsof",
"bit",
"break",
"buf",
"bufif0",
"bufif1",
"byte",
"case",
"casex",
"casez",
"cell",
"chandle",
"checker",
"class",
"clocking",
"cmos",
"config",
"const",
"constraint",
"context",
"continue",
"cover",
"covergroup",
"coverpoint",
"cross",
"deassign",
"default",
"defparam",
"design",
"disable",
"dist",
"do",
"edge",
"else",
"end",
"endcase",
"endchecker",
"endclass",
"endclocking",
"endconfig",
"endfunction",
"endgenerate",
"endgroup",
"endinterface",
"endmodule",
"endpackage",
"endprimitive",
"endprogram",
"endproperty",
"endspecify",
"endsequence",
"endtable",
"endtask",
"enum",
"event",
"eventually",
"expect",
"export",
"extends",
"extern",
"final",
"first_match",
"for",
"force",
"foreach",
"forever",
"fork",
"forkjoin",
"function",
"generate",
"genvar",
"global",
"highz0",
"highz1",
"if",
"iff",
"ifnone",
"ignore_bins",
"illegal_bins",
"implements",
"implies",
"import",
"incdir",
"include",
"initial",
"inout",
"input",
"inside",
"instance",
"int",
"integer",
"interconnect",
"interface",
"intersect",
"join",
"join_any",
"join_none",
"large",
"let",
"liblist",
"library",
"local",
"localparam",
"logic",
"longint",
"macromodule",
"matches",
"medium",
"modport",
"module",
"nand",
"negedge",
"nettype",
"new",
"nexttime",
"nmos",
"nor",
"noshowcancelled",
"not",
"notif0",
"notif1",
"null",
"or",
"output",
"package",
"packed",
"parameter",
"pmos",
"posedge",
"primitive",
"priority",
"program",
"property",
"protected",
"pull0",
"pull1",
"pulldown",
"pullup",
"pulsestyle_ondetect",
"pulsestyle_onevent",
"pure",
"rand",
"randc",
"randcase",
"randsequence",
"rcmos",
"real",
"realtime",
"ref",
"reg",
"reject_on",
"release",
"repeat",
"restrict",
"return",
"rnmos",
"rpmos",
"rtran",
"rtranif0",
"rtranif1",
"s_always",
"s_eventually",
"s_nexttime",
"s_until",
"s_until_with",
"scalared",
"sequence",
"shortint",
"shortreal",
"showcancelled",
"signed",
"small",
"soft",
"solve",
"specify",
"specparam",
"static",
"string",
"strong",
"strong0",
"strong1",
"struct",
"super",
"supply0",
"supply1",
"sync_accept_on",
"sync_reject_on",
"table",
"tagged",
"task",
"this",
"throughout",
"time",
"timeprecision",
"timeunit",
"tran",
"tranif0",
"tranif1",
"tri",
"tri0",
"tri1",
"triand",
"trior",
"trireg",
"type",
"typedef",
"union",
"unique",
"unique0",
"unsigned",
"until",
"until_with",
"untyped",
"use",
"uwire",
"var",
"vectored",
"virtual",
"void",
"wait",
"wait_order",
"wand",
"weak",
"weak0",
"weak1",
"while",
"wildcard",
"wire",
"with",
"within",
"wor",
"xnor",
"xor",
];
#[derive(Debug, Node)]
pub struct Symbol<'a> {
pub nodes: (Span<'a>, Vec<WhiteSpace<'a>>),
@ -74,6 +326,24 @@ pub fn symbol<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult<Span<'a>, Symbol<'
}
}
pub fn keyword<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult<Span<'a>, Symbol<'a>> {
move |s: Span<'a>| {
if cfg!(feature = "trace") {
println!(
"{:<64} : {:<4},{:>032x} : {}",
format!("keyword(\"{}\")", t),
s.offset,
s.extra[0],
s.fragment
);
}
let (s, x) = map(ws(terminated(tag(t.clone()), peek(none_of(AZ09_)))), |x| {
Symbol { nodes: x }
})(s)?;
Ok((clear_recursive_flags(s), x))
}
}
pub fn paren<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, Paren<O>>
where
F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
@ -195,6 +465,28 @@ where
move |s: Span<'a>| Ok((s, None))
}
pub fn alt_left<'a, O, F, G>(f: F, _g: G) -> impl Fn(Span<'a>) -> IResult<Span<'a>, O>
where
F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
G: Fn(Span<'a>) -> IResult<Span<'a>, O>,
{
move |s: Span<'a>| {
let (s, x) = f(s)?;
Ok((s, x))
}
}
pub fn alt_right<'a, O, F, G>(_f: F, g: G) -> impl Fn(Span<'a>) -> IResult<Span<'a>, O>
where
F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
G: Fn(Span<'a>) -> IResult<Span<'a>, O>,
{
move |s: Span<'a>| {
let (s, x) = g(s)?;
Ok((s, x))
}
}
// -----------------------------------------------------------------------------
#[parser]
@ -254,6 +546,15 @@ pub fn clear_recursive_flags(s: Span) -> Span {
}
}
pub fn is_keyword(s: &Span) -> bool {
for k in KEYWORDS {
if &s.fragment == k {
return true;
}
}
false
}
// -----------------------------------------------------------------------------
#[cfg(test)]

View File

@ -260,6 +260,10 @@ fn impl_parser_body_ambiguous(item: &ItemFn) -> TokenStream {
let rest = rest.replacen("ambiguous_opt", &format!("amb_temporary{}", i), 1);
token = format!("{}{}", head, rest);
replace_parsers.push(("opt", "none"));
} else if rest.starts_with("ambiguous_alt") {
let rest = rest.replacen("ambiguous_alt", &format!("amb_temporary{}", i), 1);
token = format!("{}{}", head, rest);
replace_parsers.push(("alt_left", "alt_right"));
}
}