Add behavioral_statements

This commit is contained in:
dalance 2019-07-05 17:24:28 +09:00
parent 82372ee859
commit 317f18d845
18 changed files with 1901 additions and 589 deletions

View File

@ -0,0 +1,281 @@
use crate::parser::*;
use nom::branch::*;
use nom::combinator::*;
use nom::multi::*;
use nom::sequence::*;
use nom::IResult;
// -----------------------------------------------------------------------------
#[derive(Debug)]
pub enum CaseStatement<'a> {
Normal(CaseStatementNormal<'a>),
Matches(CaseStatementMatches<'a>),
Inside(CaseStatementInside<'a>),
}
#[derive(Debug)]
pub struct CaseStatementNormal<'a> {
pub unique_priority: Option<UniquePriority>,
pub keyword: CaseKeyword,
pub expression: Expression<'a>,
pub item: Vec<CaseItem<'a>>,
}
#[derive(Debug)]
pub struct CaseStatementMatches<'a> {
pub unique_priority: Option<UniquePriority>,
pub keyword: CaseKeyword,
pub expression: Expression<'a>,
pub item: Vec<CasePatternItem<'a>>,
}
#[derive(Debug)]
pub struct CaseStatementInside<'a> {
pub unique_priority: Option<UniquePriority>,
pub keyword: CaseKeyword,
pub expression: Expression<'a>,
pub item: Vec<CaseInsideItem<'a>>,
}
#[derive(Debug)]
pub enum CaseKeyword {
Case,
Casez,
Casex,
}
#[derive(Debug)]
pub enum CaseItem<'a> {
NonDefault(CaseItemNondefault<'a>),
Default(CaseItemDefault<'a>),
}
#[derive(Debug)]
pub enum CasePatternItem<'a> {
NonDefault(CasePatternItemNondefault<'a>),
Default(CaseItemDefault<'a>),
}
#[derive(Debug)]
pub enum CaseInsideItem<'a> {
NonDefault(CaseInsideItemNondefault<'a>),
Default(CaseItemDefault<'a>),
}
#[derive(Debug)]
pub struct CaseItemDefault<'a> {
pub statement: StatementOrNull<'a>,
}
#[derive(Debug)]
pub struct CaseItemNondefault<'a> {
pub expression: Vec<Expression<'a>>,
pub statement: StatementOrNull<'a>,
}
#[derive(Debug)]
pub struct CasePatternItemNondefault<'a> {
pub pattern: Pattern<'a>,
pub expression: Option<Expression<'a>>,
pub statement: StatementOrNull<'a>,
}
#[derive(Debug)]
pub struct CaseInsideItemNondefault<'a> {
pub open_range_list: Vec<ValueRange<'a>>,
pub statement: StatementOrNull<'a>,
}
#[derive(Debug)]
pub struct RandcaseStatement<'a> {
pub item: Vec<RandcaseItem<'a>>,
}
#[derive(Debug)]
pub struct RandcaseItem<'a> {
pub expression: Expression<'a>,
pub statement: StatementOrNull<'a>,
}
// -----------------------------------------------------------------------------
pub fn case_statement(s: &str) -> IResult<&str, CaseStatement> {
alt((
case_statement_normal,
case_statement_matches,
case_statement_inside,
))(s)
}
pub fn case_statement_normal(s: &str) -> IResult<&str, CaseStatement> {
let (s, x) = opt(unique_priority)(s)?;
let (s, y) = case_keyword(s)?;
let (s, _) = symbol("(")(s)?;
let (s, z) = case_expression(s)?;
let (s, _) = symbol(")")(s)?;
let (s, v) = many1(case_item)(s)?;
let (s, _) = symbol("endcase")(s)?;
Ok((
s,
CaseStatement::Normal(CaseStatementNormal {
unique_priority: x,
keyword: y,
expression: z,
item: v,
}),
))
}
pub fn case_statement_matches(s: &str) -> IResult<&str, CaseStatement> {
let (s, x) = opt(unique_priority)(s)?;
let (s, y) = case_keyword(s)?;
let (s, _) = symbol("(")(s)?;
let (s, z) = case_expression(s)?;
let (s, _) = symbol(")")(s)?;
let (s, _) = symbol("matches")(s)?;
let (s, v) = many1(case_pattern_item)(s)?;
let (s, _) = symbol("endcase")(s)?;
Ok((
s,
CaseStatement::Matches(CaseStatementMatches {
unique_priority: x,
keyword: y,
expression: z,
item: v,
}),
))
}
pub fn case_statement_inside(s: &str) -> IResult<&str, CaseStatement> {
let (s, x) = opt(unique_priority)(s)?;
let (s, y) = case_keyword(s)?;
let (s, _) = symbol("(")(s)?;
let (s, z) = case_expression(s)?;
let (s, _) = symbol(")")(s)?;
let (s, _) = symbol("inside")(s)?;
let (s, v) = many1(case_inside_item)(s)?;
let (s, _) = symbol("endcase")(s)?;
Ok((
s,
CaseStatement::Inside(CaseStatementInside {
unique_priority: x,
keyword: y,
expression: z,
item: v,
}),
))
}
pub fn case_keyword(s: &str) -> IResult<&str, CaseKeyword> {
alt((
map(symbol("casez"), |_| CaseKeyword::Casez),
map(symbol("casex"), |_| CaseKeyword::Casex),
map(symbol("case"), |_| CaseKeyword::Case),
))(s)
}
pub fn case_expression(s: &str) -> IResult<&str, Expression> {
expression(s)
}
pub fn case_item(s: &str) -> IResult<&str, CaseItem> {
alt((
case_item_nondefault,
map(case_item_default, |x| CaseItem::Default(x)),
))(s)
}
pub fn case_item_nondefault(s: &str) -> IResult<&str, CaseItem> {
let (s, x) = separated_nonempty_list(symbol(","), case_item_expression)(s)?;
let (s, _) = symbol(":")(s)?;
let (s, y) = statement_or_null(s)?;
Ok((
s,
CaseItem::NonDefault(CaseItemNondefault {
expression: x,
statement: y,
}),
))
}
pub fn case_item_default(s: &str) -> IResult<&str, CaseItemDefault> {
let (s, _) = symbol("default")(s)?;
let (s, _) = opt(symbol(":"))(s)?;
let (s, x) = statement_or_null(s)?;
Ok((s, CaseItemDefault { statement: x }))
}
pub fn case_pattern_item(s: &str) -> IResult<&str, CasePatternItem> {
alt((
case_pattern_item_nondefault,
map(case_item_default, |x| CasePatternItem::Default(x)),
))(s)
}
pub fn case_pattern_item_nondefault(s: &str) -> IResult<&str, CasePatternItem> {
let (s, x) = pattern(s)?;
let (s, y) = opt(preceded(symbol("&&&"), expression))(s)?;
let (s, _) = symbol(":")(s)?;
let (s, z) = statement_or_null(s)?;
Ok((
s,
CasePatternItem::NonDefault(CasePatternItemNondefault {
pattern: x,
expression: y,
statement: z,
}),
))
}
pub fn case_inside_item(s: &str) -> IResult<&str, CaseInsideItem> {
alt((
case_inside_item_nondefault,
map(case_item_default, |x| CaseInsideItem::Default(x)),
))(s)
}
pub fn case_inside_item_nondefault(s: &str) -> IResult<&str, CaseInsideItem> {
let (s, x) = open_range_list(s)?;
let (s, _) = symbol(":")(s)?;
let (s, y) = statement_or_null(s)?;
Ok((
s,
CaseInsideItem::NonDefault(CaseInsideItemNondefault {
open_range_list: x,
statement: y,
}),
))
}
pub fn case_item_expression(s: &str) -> IResult<&str, Expression> {
expression(s)
}
pub fn randcase_statement(s: &str) -> IResult<&str, RandcaseStatement> {
let (s, _) = symbol("randcase")(s)?;
let (s, x) = many1(randcase_item)(s)?;
let (s, _) = symbol("endcase")(s)?;
Ok((s, RandcaseStatement { item: x }))
}
pub fn randcase_item(s: &str) -> IResult<&str, RandcaseItem> {
let (s, x) = expression(s)?;
let (s, _) = symbol(":")(s)?;
let (s, y) = statement_or_null(s)?;
Ok((
s,
RandcaseItem {
expression: x,
statement: y,
},
))
}
pub fn open_range_list(s: &str) -> IResult<&str, Vec<ValueRange>> {
separated_nonempty_list(symbol(","), open_value_range)(s)
}
pub fn open_value_range(s: &str) -> IResult<&str, ValueRange> {
value_range(s)
}

View File

@ -0,0 +1,117 @@
use crate::parser::*;
use nom::branch::*;
use nom::combinator::*;
use nom::multi::*;
use nom::sequence::*;
use nom::IResult;
// -----------------------------------------------------------------------------
#[derive(Debug)]
pub struct ConditionalStatement<'a> {
pub unique_priority: Option<UniquePriority>,
pub if_statement: ConditionalStatementBody<'a>,
pub else_if_statement: Vec<ConditionalStatementBody<'a>>,
pub else_statement: Option<StatementOrNull<'a>>,
}
#[derive(Debug)]
pub enum UniquePriority {
Unique,
Unique0,
Priority,
}
#[derive(Debug)]
pub struct ConditionalStatementBody<'a> {
pub predicate: CondPredicate<'a>,
pub statement: StatementOrNull<'a>,
}
#[derive(Debug)]
pub struct CondPredicate<'a> {
pub pattern: Vec<ExpressionOrCondPattern<'a>>,
}
#[derive(Debug)]
pub enum ExpressionOrCondPattern<'a> {
Expression(Expression<'a>),
CondPattern(CondPattern<'a>),
}
#[derive(Debug)]
pub struct CondPattern<'a> {
pub expression: Expression<'a>,
pub pattern: Pattern<'a>,
}
// -----------------------------------------------------------------------------
pub fn conditional_statement(s: &str) -> IResult<&str, ConditionalStatement> {
let (s, x) = opt(unique_priority)(s)?;
let (s, _) = symbol("if")(s)?;
let (s, y) = conditional_statement_body(s)?;
let (s, z) = many0(preceded(
pair(symbol("else"), symbol("if")),
conditional_statement_body,
))(s)?;
let (s, v) = opt(preceded(symbol("else"), statement_or_null))(s)?;
Ok((
s,
ConditionalStatement {
unique_priority: x,
if_statement: y,
else_if_statement: z,
else_statement: v,
},
))
}
pub fn conditional_statement_body(s: &str) -> IResult<&str, ConditionalStatementBody> {
let (s, _) = symbol("(")(s)?;
let (s, x) = cond_predicate(s)?;
let (s, _) = symbol(")")(s)?;
let (s, y) = statement_or_null(s)?;
Ok((
s,
ConditionalStatementBody {
predicate: x,
statement: y,
},
))
}
pub fn unique_priority(s: &str) -> IResult<&str, UniquePriority> {
alt((
map(symbol("unique0"), |_| UniquePriority::Unique0),
map(symbol("unique"), |_| UniquePriority::Unique),
map(symbol("priority"), |_| UniquePriority::Priority),
))(s)
}
pub fn cond_predicate(s: &str) -> IResult<&str, CondPredicate> {
let (s, pattern) = separated_nonempty_list(symbol("&&&"), expression_or_cond_pattern)(s)?;
Ok((s, CondPredicate { pattern }))
}
pub fn expression_or_cond_pattern(s: &str) -> IResult<&str, ExpressionOrCondPattern> {
alt((
map(expression, |x| ExpressionOrCondPattern::Expression(x)),
map(cond_pattern, |x| ExpressionOrCondPattern::CondPattern(x)),
))(s)
}
pub fn cond_pattern(s: &str) -> IResult<&str, CondPattern> {
let (s, x) = expression(s)?;
let (s, _) = symbol("matches")(s)?;
let (s, y) = pattern(s)?;
Ok((
s,
CondPattern {
expression: x,
pattern: y,
},
))
}

View File

@ -45,45 +45,57 @@ pub fn continuous_assign(s: &str) -> IResult<&str, ContinuousAssign> {
} }
pub fn continuous_assign_net(s: &str) -> IResult<&str, ContinuousAssign> { pub fn continuous_assign_net(s: &str) -> IResult<&str, ContinuousAssign> {
let (s, drive_strength) = opt(drive_strength)(s)?; let (s, x) = opt(drive_strength)(s)?;
let (s, delay3) = opt(delay3)(s)?; let (s, y) = opt(delay3)(s)?;
let (s, list) = many1(net_assignment)(s)?; let (s, z) = many1(net_assignment)(s)?;
Ok(( Ok((
s, s,
ContinuousAssign::Net(ContinuousAssignNet { ContinuousAssign::Net(ContinuousAssignNet {
drive_strength, drive_strength: x,
delay3, delay3: y,
list, list: z,
}), }),
)) ))
} }
pub fn continuous_assign_variable(s: &str) -> IResult<&str, ContinuousAssign> { pub fn continuous_assign_variable(s: &str) -> IResult<&str, ContinuousAssign> {
let (s, delay_control) = opt(delay_control)(s)?; let (s, x) = opt(delay_control)(s)?;
let (s, list) = many1(variable_assignment)(s)?; let (s, y) = many1(variable_assignment)(s)?;
Ok(( Ok((
s, s,
ContinuousAssign::Variable(ContinuousAssignVariable { ContinuousAssign::Variable(ContinuousAssignVariable {
delay_control, delay_control: x,
list, list: y,
}), }),
)) ))
} }
pub fn net_alias(s: &str) -> IResult<&str, NetAlias> { pub fn net_alias(s: &str) -> IResult<&str, NetAlias> {
let (s, _) = symbol("alias")(s)?; let (s, _) = symbol("alias")(s)?;
let (s, lvalue) = net_lvalue(s)?; let (s, x) = net_lvalue(s)?;
let (s, rvalue) = many1(preceded(symbol("="), net_lvalue))(s)?; let (s, y) = many1(preceded(symbol("="), net_lvalue))(s)?;
Ok((s, NetAlias { lvalue, rvalue })) Ok((
s,
NetAlias {
lvalue: x,
rvalue: y,
},
))
} }
pub fn net_assignment(s: &str) -> IResult<&str, NetAssignment> { pub fn net_assignment(s: &str) -> IResult<&str, NetAssignment> {
let (s, lvalue) = net_lvalue(s)?; let (s, x) = net_lvalue(s)?;
let (s, _) = symbol("=")(s)?; let (s, _) = symbol("=")(s)?;
let (s, rvalue) = expression(s)?; let (s, y) = expression(s)?;
Ok((s, NetAssignment { lvalue, rvalue })) Ok((
s,
NetAssignment {
lvalue: x,
rvalue: y,
},
))
} }

View File

@ -1,6 +1,16 @@
pub mod case_statements;
pub mod conditional_statements;
pub mod continuous_assignment_and_net_alias_statements; pub mod continuous_assignment_and_net_alias_statements;
pub mod parallel_and_sequential_blocks; pub mod parallel_and_sequential_blocks;
pub mod procedual_blocks_and_assignments; pub mod patterns;
pub mod procedural_blocks_and_assignments;
pub mod statements;
pub mod timing_control_statements;
pub use case_statements::*;
pub use conditional_statements::*;
pub use continuous_assignment_and_net_alias_statements::*; pub use continuous_assignment_and_net_alias_statements::*;
pub use parallel_and_sequential_blocks::*; pub use parallel_and_sequential_blocks::*;
pub use procedual_blocks_and_assignments::*; pub use patterns::*;
pub use procedural_blocks_and_assignments::*;
pub use statements::*;
pub use timing_control_statements::*;

View File

@ -53,51 +53,51 @@ pub fn action_block(s: &str) -> IResult<&str, ActionBlock> {
} }
pub fn action_block_else(s: &str) -> IResult<&str, ActionBlock> { pub fn action_block_else(s: &str) -> IResult<&str, ActionBlock> {
let (s, statement) = opt(statement)(s)?; let (s, x) = opt(statement)(s)?;
let (s, _) = symbol("else")(s)?; let (s, _) = symbol("else")(s)?;
let (s, else_statement) = statement_or_null(s)?; let (s, y) = statement_or_null(s)?;
Ok(( Ok((
s, s,
ActionBlock::Else(ActionBlockElse { ActionBlock::Else(ActionBlockElse {
statement, statement: x,
else_statement, else_statement: y,
}), }),
)) ))
} }
pub fn seq_block(s: &str) -> IResult<&str, SeqBlock> { pub fn seq_block(s: &str) -> IResult<&str, SeqBlock> {
let (s, _) = symbol("begin")(s)?; let (s, _) = symbol("begin")(s)?;
let (s, beg_identifier) = opt(preceded(symbol(":"), block_identifier))(s)?; let (s, x) = opt(preceded(symbol(":"), block_identifier))(s)?;
let (s, declaration) = many0(block_item_declaration)(s)?; let (s, y) = many0(block_item_declaration)(s)?;
let (s, statement) = many0(statement_or_null)(s)?; let (s, z) = many0(statement_or_null)(s)?;
let (s, _) = symbol("end")(s)?; let (s, _) = symbol("end")(s)?;
let (s, end_identifier) = opt(preceded(symbol(":"), block_identifier))(s)?; let (s, v) = opt(preceded(symbol(":"), block_identifier))(s)?;
Ok(( Ok((
s, s,
SeqBlock { SeqBlock {
beg_identifier, beg_identifier: x,
declaration, declaration: y,
statement, statement: z,
end_identifier, end_identifier: v,
}, },
)) ))
} }
pub fn par_block(s: &str) -> IResult<&str, ParBlock> { pub fn par_block(s: &str) -> IResult<&str, ParBlock> {
let (s, _) = symbol("fork")(s)?; let (s, _) = symbol("fork")(s)?;
let (s, beg_identifier) = opt(preceded(symbol(":"), block_identifier))(s)?; let (s, x) = opt(preceded(symbol(":"), block_identifier))(s)?;
let (s, declaration) = many0(block_item_declaration)(s)?; let (s, y) = many0(block_item_declaration)(s)?;
let (s, statement) = many0(statement_or_null)(s)?; let (s, z) = many0(statement_or_null)(s)?;
let (s, keyword) = join_keyword(s)?; let (s, v) = join_keyword(s)?;
let (s, end_identifier) = opt(preceded(symbol(":"), block_identifier))(s)?; let (s, w) = opt(preceded(symbol(":"), block_identifier))(s)?;
Ok(( Ok((
s, s,
ParBlock { ParBlock {
beg_identifier, beg_identifier: x,
declaration, declaration: y,
statement, statement: z,
keyword, keyword: v,
end_identifier, end_identifier: w,
}, },
)) ))
} }

View File

@ -0,0 +1,237 @@
use crate::parser::*;
use nom::branch::*;
use nom::combinator::*;
use nom::multi::*;
use nom::sequence::*;
use nom::IResult;
// -----------------------------------------------------------------------------
#[derive(Debug)]
pub enum Pattern<'a> {
VariableIdentifier(Box<Identifier<'a>>),
Asterisk,
ConstantExpression(Box<ConstantExpression<'a>>),
Tagged(Box<(Identifier<'a>, Option<Pattern<'a>>)>),
Pattern(Box<Vec<Pattern<'a>>>),
MemberPattern(Box<Vec<(Identifier<'a>, Pattern<'a>)>>),
}
#[derive(Debug)]
pub enum AssignmentPattern<'a> {
Expression(Vec<Expression<'a>>),
StructurePatternKey(Vec<(StructurePatternKey<'a>, Expression<'a>)>),
ArrayPatternKey(Vec<(ArrayPatternKey<'a>, Expression<'a>)>),
ConstantExpression((ConstantExpression<'a>, Vec<Expression<'a>>)),
}
#[derive(Debug)]
pub enum StructurePatternKey<'a> {
Identifier(Identifier<'a>),
PatternKey(AssignmentPatternKey<'a>),
}
#[derive(Debug)]
pub enum ArrayPatternKey<'a> {
Expression(ConstantExpression<'a>),
PatternKey(AssignmentPatternKey<'a>),
}
#[derive(Debug)]
pub enum AssignmentPatternKey<'a> {
SimpleType(SimpleType<'a>),
Default,
}
#[derive(Debug)]
pub struct AssignmentPatternExpression<'a> {
pub r#type: Option<AssignmentPatternExpressionType<'a>>,
pub pattern: AssignmentPattern<'a>,
}
#[derive(Debug)]
pub enum AssignmentPatternExpressionType<'a> {
Type(ScopedIdentifier<'a>),
Parameter(ScopedIdentifier<'a>),
IntegerAtom(IntegerAtomType<'a>),
TypeReference(TypeReference<'a>),
}
#[derive(Debug)]
pub struct AssignmentPatternNetLvalue<'a> {
pub lvalue: Vec<NetLvalue<'a>>,
}
#[derive(Debug)]
pub struct AssignmentPatternVariableLvalue<'a> {
pub lvalue: Vec<VariableLvalue<'a>>,
}
// -----------------------------------------------------------------------------
pub fn pattern(s: &str) -> IResult<&str, Pattern> {
alt((
map(preceded(symbol("."), variable_identifier), |x| {
Pattern::VariableIdentifier(Box::new(x))
}),
map(symbol(".*"), |_| Pattern::Asterisk),
map(constant_expression, |x| {
Pattern::ConstantExpression(Box::new(x))
}),
map(
preceded(symbol("tagged"), pair(member_identifier, opt(pattern))),
|x| Pattern::Tagged(Box::new(x)),
),
map(
delimited(
symbol("'{"),
separated_nonempty_list(symbol(","), pattern),
symbol("}"),
),
|x| Pattern::Pattern(Box::new(x)),
),
map(
delimited(
symbol("'{"),
separated_nonempty_list(
symbol(","),
pair(member_identifier, preceded(symbol(":"), pattern)),
),
symbol("}"),
),
|x| Pattern::MemberPattern(Box::new(x)),
),
))(s)
}
pub fn assignment_pattern(s: &str) -> IResult<&str, AssignmentPattern> {
alt((
map(
delimited(
symbol("'{"),
separated_nonempty_list(symbol(","), expression),
symbol("}"),
),
|x| AssignmentPattern::Expression(x),
),
map(
delimited(
symbol("'{"),
separated_nonempty_list(
symbol(","),
pair(structure_pattern_key, preceded(symbol(":"), expression)),
),
symbol("}"),
),
|x| AssignmentPattern::StructurePatternKey(x),
),
map(
delimited(
symbol("'{"),
separated_nonempty_list(
symbol(","),
pair(array_pattern_key, preceded(symbol(":"), expression)),
),
symbol("}"),
),
|x| AssignmentPattern::ArrayPatternKey(x),
),
map(
delimited(
symbol("'{"),
pair(
constant_expression,
delimited(
symbol("{"),
separated_nonempty_list(symbol(","), expression),
symbol("}"),
),
),
symbol("}"),
),
|x| AssignmentPattern::ConstantExpression(x),
),
))(s)
}
pub fn structure_pattern_key(s: &str) -> IResult<&str, StructurePatternKey> {
alt((
map(member_identifier, |x| StructurePatternKey::Identifier(x)),
map(assignment_pattern_key, |x| {
StructurePatternKey::PatternKey(x)
}),
))(s)
}
pub fn array_pattern_key(s: &str) -> IResult<&str, ArrayPatternKey> {
alt((
map(constant_expression, |x| ArrayPatternKey::Expression(x)),
map(assignment_pattern_key, |x| ArrayPatternKey::PatternKey(x)),
))(s)
}
pub fn assignment_pattern_key(s: &str) -> IResult<&str, AssignmentPatternKey> {
alt((
map(simple_type, |x| AssignmentPatternKey::SimpleType(x)),
map(symbol("default"), |_| AssignmentPatternKey::Default),
))(s)
}
pub fn assignment_pattern_expression(s: &str) -> IResult<&str, AssignmentPatternExpression> {
let (s, x) = opt(assignment_pattern_expression_type)(s)?;
let (s, y) = assignment_pattern(s)?;
Ok((
s,
AssignmentPatternExpression {
r#type: x,
pattern: y,
},
))
}
pub fn assignment_pattern_expression_type(
s: &str,
) -> IResult<&str, AssignmentPatternExpressionType> {
alt((
map(ps_type_identifier, |x| {
AssignmentPatternExpressionType::Type(x)
}),
map(ps_parameter_identifier, |x| {
AssignmentPatternExpressionType::Parameter(x)
}),
map(integer_atom_type, |x| {
AssignmentPatternExpressionType::IntegerAtom(x)
}),
map(type_reference, |x| {
AssignmentPatternExpressionType::TypeReference(x)
}),
))(s)
}
pub fn constant_assignment_pattern_expression(
s: &str,
) -> IResult<&str, AssignmentPatternExpression> {
assignment_pattern_expression(s)
}
pub fn assignment_pattern_net_lvalue(s: &str) -> IResult<&str, AssignmentPatternNetLvalue> {
let (s, x) = delimited(
symbol("'{"),
separated_nonempty_list(symbol(","), net_lvalue),
symbol("}"),
)(s)?;
Ok((s, AssignmentPatternNetLvalue { lvalue: x }))
}
pub fn assignment_pattern_variable_lvalue(
s: &str,
) -> IResult<&str, AssignmentPatternVariableLvalue> {
let (s, x) = delimited(
symbol("'{"),
separated_nonempty_list(symbol(","), variable_lvalue),
symbol("}"),
)(s)?;
Ok((s, AssignmentPatternVariableLvalue { lvalue: x }))
}
// -----------------------------------------------------------------------------

View File

@ -27,7 +27,7 @@ pub enum AlwaysKeyword {
#[derive(Debug)] #[derive(Debug)]
pub struct FinalConstruct<'a> { pub struct FinalConstruct<'a> {
pub statement: FunctionStatement<'a>, pub statement: Statement<'a>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -74,7 +74,7 @@ pub struct NonblockingAssignment<'a> {
} }
#[derive(Debug)] #[derive(Debug)]
pub enum ProcedualContinuousAssignment<'a> { pub enum ProceduralContinuousAssignment<'a> {
Assign(VariableAssignment<'a>), Assign(VariableAssignment<'a>),
Deassign(VariableLvalue<'a>), Deassign(VariableLvalue<'a>),
ForceVariable(VariableAssignment<'a>), ForceVariable(VariableAssignment<'a>),
@ -93,14 +93,20 @@ pub struct VariableAssignment<'a> {
pub fn initial_construct(s: &str) -> IResult<&str, InitialConstruct> { pub fn initial_construct(s: &str) -> IResult<&str, InitialConstruct> {
let (s, _) = symbol("initial")(s)?; let (s, _) = symbol("initial")(s)?;
let (s, statement) = statement_or_null(s)?; let (s, x) = statement_or_null(s)?;
Ok((s, InitialConstruct { statement })) Ok((s, InitialConstruct { statement: x }))
} }
pub fn always_construct(s: &str) -> IResult<&str, AlwaysConstruct> { pub fn always_construct(s: &str) -> IResult<&str, AlwaysConstruct> {
let (s, keyword) = always_keyword(s)?; let (s, x) = always_keyword(s)?;
let (s, statement) = statement(s)?; let (s, y) = statement(s)?;
Ok((s, AlwaysConstruct { keyword, statement })) Ok((
s,
AlwaysConstruct {
keyword: x,
statement: y,
},
))
} }
pub fn always_keyword(s: &str) -> IResult<&str, AlwaysKeyword> { pub fn always_keyword(s: &str) -> IResult<&str, AlwaysKeyword> {
@ -114,8 +120,8 @@ pub fn always_keyword(s: &str) -> IResult<&str, AlwaysKeyword> {
pub fn final_construct(s: &str) -> IResult<&str, FinalConstruct> { pub fn final_construct(s: &str) -> IResult<&str, FinalConstruct> {
let (s, _) = symbol("final")(s)?; let (s, _) = symbol("final")(s)?;
let (s, statement) = function_statement(s)?; let (s, x) = function_statement(s)?;
Ok((s, FinalConstruct { statement })) Ok((s, FinalConstruct { statement: x }))
} }
pub fn blocking_assignment(s: &str) -> IResult<&str, BlockingAssignment> { pub fn blocking_assignment(s: &str) -> IResult<&str, BlockingAssignment> {
@ -128,61 +134,64 @@ pub fn blocking_assignment(s: &str) -> IResult<&str, BlockingAssignment> {
} }
pub fn blocking_assignment_variable(s: &str) -> IResult<&str, BlockingAssignment> { pub fn blocking_assignment_variable(s: &str) -> IResult<&str, BlockingAssignment> {
let (s, lvalue) = variable_lvalue(s)?; let (s, x) = variable_lvalue(s)?;
let (s, _) = symbol("=")(s)?; let (s, _) = symbol("=")(s)?;
let (s, control) = delay_or_event_control(s)?; let (s, y) = delay_or_event_control(s)?;
let (s, rvalue) = expression(s)?; let (s, z) = expression(s)?;
Ok(( Ok((
s, s,
BlockingAssignment::Variable(BlockingAssignmentVariable { BlockingAssignment::Variable(BlockingAssignmentVariable {
lvalue, lvalue: x,
control, control: y,
rvalue, rvalue: z,
}), }),
)) ))
} }
pub fn blocking_assignment_nonrange_variable(s: &str) -> IResult<&str, BlockingAssignment> { pub fn blocking_assignment_nonrange_variable(s: &str) -> IResult<&str, BlockingAssignment> {
let (s, lvalue) = nonrange_variable_lvalue(s)?; let (s, x) = nonrange_variable_lvalue(s)?;
let (s, _) = symbol("=")(s)?; let (s, _) = symbol("=")(s)?;
let (s, rvalue) = dynamic_array_new(s)?; let (s, y) = dynamic_array_new(s)?;
Ok(( Ok((
s, s,
BlockingAssignment::NonrangeVariable(BlockingAssignmentNonrangeVariable { lvalue, rvalue }), BlockingAssignment::NonrangeVariable(BlockingAssignmentNonrangeVariable {
lvalue: x,
rvalue: y,
}),
)) ))
} }
pub fn blocking_assignment_hierarchical_variable(s: &str) -> IResult<&str, BlockingAssignment> { pub fn blocking_assignment_hierarchical_variable(s: &str) -> IResult<&str, BlockingAssignment> {
let (s, scope) = opt(alt(( let (s, x) = opt(alt((
terminated(implicit_class_handle, symbol(".")), terminated(implicit_class_handle, symbol(".")),
class_scope, class_scope,
package_scope, package_scope,
)))(s)?; )))(s)?;
let (s, lvalue) = hierarchical_variable_identifier(s)?; let (s, y) = hierarchical_variable_identifier(s)?;
let (s, select) = select(s)?; let (s, z) = select(s)?;
let (s, _) = symbol("=")(s)?; let (s, _) = symbol("=")(s)?;
let (s, rvalue) = class_new(s)?; let (s, v) = class_new(s)?;
Ok(( Ok((
s, s,
BlockingAssignment::HierarchicalVariable(BlockingAssignmentHierarchicalVariable { BlockingAssignment::HierarchicalVariable(BlockingAssignmentHierarchicalVariable {
scope, scope: x,
lvalue, lvalue: y,
select, select: z,
rvalue, rvalue: v,
}), }),
)) ))
} }
pub fn operator_assignment(s: &str) -> IResult<&str, OperatorAssignment> { pub fn operator_assignment(s: &str) -> IResult<&str, OperatorAssignment> {
let (s, lvalue) = variable_lvalue(s)?; let (s, x) = variable_lvalue(s)?;
let (s, operator) = assignment_operator(s)?; let (s, y) = assignment_operator(s)?;
let (s, rvalue) = expression(s)?; let (s, z) = expression(s)?;
Ok(( Ok((
s, s,
OperatorAssignment { OperatorAssignment {
lvalue, lvalue: x,
operator, operator: y,
rvalue, rvalue: z,
}, },
)) ))
} }
@ -206,46 +215,52 @@ pub fn assignment_operator(s: &str) -> IResult<&str, Operator> {
} }
pub fn nonblocking_assignment(s: &str) -> IResult<&str, NonblockingAssignment> { pub fn nonblocking_assignment(s: &str) -> IResult<&str, NonblockingAssignment> {
let (s, lvalue) = variable_lvalue(s)?; let (s, x) = variable_lvalue(s)?;
let (s, _) = symbol("<=")(s)?; let (s, _) = symbol("<=")(s)?;
let (s, control) = opt(delay_or_event_control)(s)?; let (s, y) = opt(delay_or_event_control)(s)?;
let (s, rvalue) = expression(s)?; let (s, z) = expression(s)?;
Ok(( Ok((
s, s,
NonblockingAssignment { NonblockingAssignment {
lvalue, lvalue: x,
control, control: y,
rvalue, rvalue: z,
}, },
)) ))
} }
pub fn procedual_continuous_assignment(s: &str) -> IResult<&str, ProcedualContinuousAssignment> { pub fn procedural_continuous_assignment(s: &str) -> IResult<&str, ProceduralContinuousAssignment> {
alt(( alt((
map(preceded(symbol("assign"), variable_assignment), |x| { map(preceded(symbol("assign"), variable_assignment), |x| {
ProcedualContinuousAssignment::Assign(x) ProceduralContinuousAssignment::Assign(x)
}), }),
map(preceded(symbol("deassign"), variable_lvalue), |x| { map(preceded(symbol("deassign"), variable_lvalue), |x| {
ProcedualContinuousAssignment::Deassign(x) ProceduralContinuousAssignment::Deassign(x)
}), }),
map(preceded(symbol("force"), variable_assignment), |x| { map(preceded(symbol("force"), variable_assignment), |x| {
ProcedualContinuousAssignment::ForceVariable(x) ProceduralContinuousAssignment::ForceVariable(x)
}), }),
map(preceded(symbol("force"), net_assignment), |x| { map(preceded(symbol("force"), net_assignment), |x| {
ProcedualContinuousAssignment::ForceNet(x) ProceduralContinuousAssignment::ForceNet(x)
}), }),
map(preceded(symbol("release"), variable_lvalue), |x| { map(preceded(symbol("release"), variable_lvalue), |x| {
ProcedualContinuousAssignment::ReleaseVariable(x) ProceduralContinuousAssignment::ReleaseVariable(x)
}), }),
map(preceded(symbol("release"), net_lvalue), |x| { map(preceded(symbol("release"), net_lvalue), |x| {
ProcedualContinuousAssignment::ReleaseNet(x) ProceduralContinuousAssignment::ReleaseNet(x)
}), }),
))(s) ))(s)
} }
pub fn variable_assignment(s: &str) -> IResult<&str, VariableAssignment> { pub fn variable_assignment(s: &str) -> IResult<&str, VariableAssignment> {
let (s, lvalue) = variable_lvalue(s)?; let (s, x) = variable_lvalue(s)?;
let (s, _) = symbol("=")(s)?; let (s, _) = symbol("=")(s)?;
let (s, rvalue) = expression(s)?; let (s, y) = expression(s)?;
Ok((s, VariableAssignment { lvalue, rvalue })) Ok((
s,
VariableAssignment {
lvalue: x,
rvalue: y,
},
))
} }

View File

@ -0,0 +1,142 @@
use crate::parser::*;
use nom::branch::*;
use nom::combinator::*;
use nom::multi::*;
use nom::sequence::*;
use nom::IResult;
// -----------------------------------------------------------------------------
#[derive(Debug)]
pub enum StatementOrNull<'a> {
Statement(Statement<'a>),
Attribute(Vec<AttributeInstance<'a>>),
}
#[derive(Debug)]
pub struct Statement<'a> {
pub identifier: Option<Identifier<'a>>,
pub attribute: Vec<AttributeInstance<'a>>,
pub item: StatementItem<'a>,
}
#[derive(Debug)]
pub enum StatementItem<'a> {
BlockingAssignment(Box<BlockingAssignment<'a>>),
NonblockingAssignment(Box<NonblockingAssignment<'a>>),
ProceduralContinuousAssignment(Box<ProceduralContinuousAssignment<'a>>),
CaseStatement(Box<CaseStatement<'a>>),
ConditionalStatement(Box<ConditionalStatement<'a>>),
IncOrDecExpression(Box<IncOrDecExpression<'a>>),
SubroutineCallStatement(Box<SubroutineCallStatement<'a>>),
DisableStatement(Box<DisableStatement<'a>>),
EventTrigger(Box<EventTrigger<'a>>),
LoopStatement(Box<LoopStatement<'a>>),
JumpStatement(Box<JumpStatement<'a>>),
ParBlock(Box<ParBlock<'a>>),
ProceduralTimingControlStatement(Box<ProceduralTimingControlStatement<'a>>),
SeqBlock(Box<SeqBlock<'a>>),
WaitStatement(Box<WaitStatement<'a>>),
ProceduralAssertionStatement(Box<ProceduralAssertionStatement<'a>>),
ClockingDrive(Box<ClockingDrive<'a>>),
RandsequenceStatement(Box<RandsequenceStatement<'a>>),
RandcaseStatement(Box<RandcaseStatement<'a>>),
ExpectPropertyStatement(Box<ExpectPropertyStatement<'a>>),
}
// -----------------------------------------------------------------------------
pub fn statement_or_null(s: &str) -> IResult<&str, StatementOrNull> {
alt((
map(statement, |x| StatementOrNull::Statement(x)),
map(terminated(many0(attribute_instance), symbol(";")), |x| {
StatementOrNull::Attribute(x)
}),
))(s)
}
pub fn statement(s: &str) -> IResult<&str, Statement> {
let (s, x) = opt(terminated(block_identifier, symbol(":")))(s)?;
let (s, y) = many0(attribute_instance)(s)?;
let (s, z) = statement_item(s)?;
Ok((
s,
Statement {
identifier: x,
attribute: y,
item: z,
},
))
}
pub fn statement_item(s: &str) -> IResult<&str, StatementItem> {
alt((
map(terminated(blocking_assignment, symbol(";")), |x| {
StatementItem::BlockingAssignment(Box::new(x))
}),
map(terminated(nonblocking_assignment, symbol(";")), |x| {
StatementItem::NonblockingAssignment(Box::new(x))
}),
map(
terminated(procedural_continuous_assignment, symbol(";")),
|x| StatementItem::ProceduralContinuousAssignment(Box::new(x)),
),
map(case_statement, |x| {
StatementItem::CaseStatement(Box::new(x))
}),
map(conditional_statement, |x| {
StatementItem::ConditionalStatement(Box::new(x))
}),
map(terminated(inc_or_dec_expression, symbol(";")), |x| {
StatementItem::IncOrDecExpression(Box::new(x))
}),
map(subroutine_call_statement, |x| {
StatementItem::SubroutineCallStatement(Box::new(x))
}),
map(disable_statement, |x| {
StatementItem::DisableStatement(Box::new(x))
}),
map(event_trigger, |x| StatementItem::EventTrigger(Box::new(x))),
map(loop_statement, |x| {
StatementItem::LoopStatement(Box::new(x))
}),
map(jump_statement, |x| {
StatementItem::JumpStatement(Box::new(x))
}),
map(par_block, |x| StatementItem::ParBlock(Box::new(x))),
map(procedural_timing_control_statement, |x| {
StatementItem::ProceduralTimingControlStatement(Box::new(x))
}),
map(seq_block, |x| StatementItem::SeqBlock(Box::new(x))),
map(wait_statement, |x| {
StatementItem::WaitStatement(Box::new(x))
}),
map(procedural_assertion_statement, |x| {
StatementItem::ProceduralAssertionStatement(Box::new(x))
}),
map(terminated(clocking_drive, symbol(";")), |x| {
StatementItem::ClockingDrive(Box::new(x))
}),
map(randsequence_statement, |x| {
StatementItem::RandsequenceStatement(Box::new(x))
}),
map(randcase_statement, |x| {
StatementItem::RandcaseStatement(Box::new(x))
}),
map(expect_property_statement, |x| {
StatementItem::ExpectPropertyStatement(Box::new(x))
}),
))(s)
}
pub fn function_statement(s: &str) -> IResult<&str, Statement> {
statement(s)
}
pub fn function_statement_or_null(s: &str) -> IResult<&str, StatementOrNull> {
statement_or_null(s)
}
pub fn variable_identifier_list(s: &str) -> IResult<&str, Vec<Identifier>> {
separated_nonempty_list(symbol(","), variable_identifier)(s)
}

View File

@ -0,0 +1,410 @@
use crate::parser::*;
use nom::branch::*;
use nom::combinator::*;
use nom::multi::*;
use nom::sequence::*;
use nom::IResult;
// -----------------------------------------------------------------------------
#[derive(Debug)]
pub struct ProceduralTimingControlStatement<'a> {
pub control: ProceduralTimingControl<'a>,
pub statement: StatementOrNull<'a>,
}
#[derive(Debug)]
pub enum DelayOrEventControl<'a> {
Delay(DelayControl<'a>),
Event(EventControl<'a>),
Repeat(DelayOrEventControlRepeat<'a>),
}
#[derive(Debug)]
pub struct DelayOrEventControlRepeat<'a> {
pub expression: Expression<'a>,
pub control: EventControl<'a>,
}
#[derive(Debug)]
pub enum DelayControl<'a> {
Delay(DelayValue<'a>),
Mintypmax(MintypmaxExpression<'a>),
}
#[derive(Debug)]
pub enum EventControl<'a> {
EventIdentifier(HierarchicalIdentifier<'a>),
EventExpression(EventExpression<'a>),
Asterisk,
SequenceIdentifier(ScopedIdentifier<'a>),
}
#[derive(Debug)]
pub enum EventExpression<'a> {
Expression(Box<EventExpressionExpression<'a>>),
Sequence(Box<EventExpressionSequence<'a>>),
Or(Box<(EventExpression<'a>, EventExpression<'a>)>),
Comma(Box<(EventExpression<'a>, EventExpression<'a>)>),
Paren(Box<EventExpression<'a>>),
}
#[derive(Debug)]
pub struct EventExpressionExpression<'a> {
pub edge: Option<EdgeIdentifier<'a>>,
pub expression: Expression<'a>,
pub iff: Option<Expression<'a>>,
}
#[derive(Debug)]
pub struct EventExpressionSequence<'a> {
pub instance: SequenceInstance<'a>,
pub iff: Option<Expression<'a>>,
}
#[derive(Debug)]
pub enum ProceduralTimingControl<'a> {
DelayControl(DelayControl<'a>),
EventControl(EventControl<'a>),
CycleDelay(CycleDelay<'a>),
}
#[derive(Debug)]
pub enum JumpStatement<'a> {
Return(JumpStatementReturn<'a>),
Break,
Continue,
}
#[derive(Debug)]
pub struct JumpStatementReturn<'a> {
pub expression: Option<Expression<'a>>,
}
#[derive(Debug)]
pub enum WaitStatement<'a> {
Wait(WaitStatementWait<'a>),
Fork,
Order(WaitStatementOrder<'a>),
}
#[derive(Debug)]
pub struct WaitStatementWait<'a> {
pub expression: Expression<'a>,
pub statement: StatementOrNull<'a>,
}
#[derive(Debug)]
pub struct WaitStatementOrder<'a> {
pub identifier: Vec<HierarchicalIdentifier<'a>>,
pub block: ActionBlock<'a>,
}
#[derive(Debug)]
pub enum EventTrigger<'a> {
Named(EventTriggerNamed<'a>),
Nonblocking(EventTriggerNonblocking<'a>),
}
#[derive(Debug)]
pub struct EventTriggerNamed<'a> {
pub identifier: HierarchicalIdentifier<'a>,
}
#[derive(Debug)]
pub struct EventTriggerNonblocking<'a> {
pub control: Option<DelayOrEventControl<'a>>,
pub identifier: HierarchicalIdentifier<'a>,
}
#[derive(Debug)]
pub enum DisableStatement<'a> {
Task(HierarchicalIdentifier<'a>),
Block(HierarchicalIdentifier<'a>),
Fork,
}
// -----------------------------------------------------------------------------
pub fn procedural_timing_control_statement(
s: &str,
) -> IResult<&str, ProceduralTimingControlStatement> {
let (s, x) = procedural_timing_control(s)?;
let (s, y) = statement_or_null(s)?;
Ok((
s,
ProceduralTimingControlStatement {
control: x,
statement: y,
},
))
}
pub fn delay_or_event_control(s: &str) -> IResult<&str, DelayOrEventControl> {
alt((
map(delay_control, |x| DelayOrEventControl::Delay(x)),
map(event_control, |x| DelayOrEventControl::Event(x)),
delay_or_event_control_repeat,
))(s)
}
pub fn delay_or_event_control_repeat(s: &str) -> IResult<&str, DelayOrEventControl> {
let (s, _) = symbol("repeat")(s)?;
let (s, _) = symbol("(")(s)?;
let (s, x) = expression(s)?;
let (s, _) = symbol(")")(s)?;
let (s, y) = event_control(s)?;
Ok((
s,
DelayOrEventControl::Repeat(DelayOrEventControlRepeat {
expression: x,
control: y,
}),
))
}
pub fn delay_control(s: &str) -> IResult<&str, DelayControl> {
alt((delay_control_delay, delay_control_mintypmax))(s)
}
pub fn delay_control_delay(s: &str) -> IResult<&str, DelayControl> {
let (s, _) = symbol("#")(s)?;
let (s, x) = delay_value(s)?;
Ok((s, DelayControl::Delay(x)))
}
pub fn delay_control_mintypmax(s: &str) -> IResult<&str, DelayControl> {
let (s, _) = symbol("#")(s)?;
let (s, _) = symbol("(")(s)?;
let (s, x) = mintypmax_expression(s)?;
let (s, _) = symbol(")")(s)?;
Ok((s, DelayControl::Mintypmax(x)))
}
pub fn event_control(s: &str) -> IResult<&str, EventControl> {
alt((
event_control_event_identifier,
event_control_event_expression,
event_control_asterisk,
event_control_sequence_identifier,
))(s)
}
pub fn event_control_event_identifier(s: &str) -> IResult<&str, EventControl> {
let (s, _) = symbol("@")(s)?;
let (s, x) = hierarchical_event_identifier(s)?;
Ok((s, EventControl::EventIdentifier(x)))
}
pub fn event_control_event_expression(s: &str) -> IResult<&str, EventControl> {
let (s, _) = symbol("@")(s)?;
let (s, _) = symbol("(")(s)?;
let (s, x) = event_expression(s)?;
let (s, _) = symbol(")")(s)?;
Ok((s, EventControl::EventExpression(x)))
}
pub fn event_control_asterisk(s: &str) -> IResult<&str, EventControl> {
let (s, _) = alt((symbol("@*"), preceded(symbol("@"), symbol("(*)"))))(s)?;
Ok((s, EventControl::Asterisk))
}
pub fn event_control_sequence_identifier(s: &str) -> IResult<&str, EventControl> {
let (s, _) = symbol("@")(s)?;
let (s, x) = ps_or_hierarchical_sequence_identifier(s)?;
Ok((s, EventControl::SequenceIdentifier(x)))
}
pub fn event_expression(s: &str) -> IResult<&str, EventExpression> {
alt((
event_expression_expression,
event_expression_sequence,
event_expression_or,
event_expression_comma,
event_expression_paren,
))(s)
}
pub fn event_expression_expression(s: &str) -> IResult<&str, EventExpression> {
let (s, x) = opt(edge_identifier)(s)?;
let (s, y) = expression(s)?;
let (s, z) = opt(preceded(symbol("iff"), expression))(s)?;
Ok((
s,
EventExpression::Expression(Box::new(EventExpressionExpression {
edge: x,
expression: y,
iff: z,
})),
))
}
pub fn event_expression_sequence(s: &str) -> IResult<&str, EventExpression> {
let (s, x) = sequence_instance(s)?;
let (s, y) = opt(preceded(symbol("iff"), expression))(s)?;
Ok((
s,
EventExpression::Sequence(Box::new(EventExpressionSequence {
instance: x,
iff: y,
})),
))
}
pub fn event_expression_or(s: &str) -> IResult<&str, EventExpression> {
let (s, x) = event_expression(s)?;
let (s, _) = symbol("or")(s)?;
let (s, y) = event_expression(s)?;
Ok((s, EventExpression::Or(Box::new((x, y)))))
}
pub fn event_expression_comma(s: &str) -> IResult<&str, EventExpression> {
let (s, x) = event_expression(s)?;
let (s, _) = symbol(",")(s)?;
let (s, y) = event_expression(s)?;
Ok((s, EventExpression::Comma(Box::new((x, y)))))
}
pub fn event_expression_paren(s: &str) -> IResult<&str, EventExpression> {
let (s, _) = symbol("(")(s)?;
let (s, x) = event_expression(s)?;
let (s, _) = symbol(")")(s)?;
Ok((s, EventExpression::Paren(Box::new(x))))
}
pub fn procedural_timing_control(s: &str) -> IResult<&str, ProceduralTimingControl> {
alt((
map(delay_control, |x| ProceduralTimingControl::DelayControl(x)),
map(event_control, |x| ProceduralTimingControl::EventControl(x)),
map(cycle_delay, |x| ProceduralTimingControl::CycleDelay(x)),
))(s)
}
pub fn jump_statement(s: &str) -> IResult<&str, JumpStatement> {
alt((
jump_statement_return,
jump_statement_break,
jump_statement_continue,
))(s)
}
pub fn jump_statement_return(s: &str) -> IResult<&str, JumpStatement> {
let (s, _) = symbol("return")(s)?;
let (s, x) = opt(expression)(s)?;
let (s, _) = symbol(";")(s)?;
Ok((
s,
JumpStatement::Return(JumpStatementReturn { expression: x }),
))
}
pub fn jump_statement_break(s: &str) -> IResult<&str, JumpStatement> {
let (s, _) = symbol("break")(s)?;
let (s, _) = symbol(";")(s)?;
Ok((s, JumpStatement::Break))
}
pub fn jump_statement_continue(s: &str) -> IResult<&str, JumpStatement> {
let (s, _) = symbol("continue")(s)?;
let (s, _) = symbol(";")(s)?;
Ok((s, JumpStatement::Continue))
}
pub fn wait_statement(s: &str) -> IResult<&str, WaitStatement> {
alt((
wait_statement_wait,
wait_statement_fork,
wait_statement_order,
))(s)
}
pub fn wait_statement_wait(s: &str) -> IResult<&str, WaitStatement> {
let (s, _) = symbol("wait")(s)?;
let (s, x) = delimited(symbol("("), expression, symbol(")"))(s)?;
let (s, y) = statement_or_null(s)?;
Ok((
s,
WaitStatement::Wait(WaitStatementWait {
expression: x,
statement: y,
}),
))
}
pub fn wait_statement_fork(s: &str) -> IResult<&str, WaitStatement> {
let (s, _) = symbol("wait")(s)?;
let (s, _) = symbol("fork")(s)?;
let (s, _) = symbol(";")(s)?;
Ok((s, WaitStatement::Fork))
}
pub fn wait_statement_order(s: &str) -> IResult<&str, WaitStatement> {
let (s, _) = symbol("wait_order")(s)?;
let (s, x) = delimited(
symbol("("),
separated_nonempty_list(symbol(","), hierarchical_identifier),
symbol(")"),
)(s)?;
let (s, y) = action_block(s)?;
Ok((
s,
WaitStatement::Order(WaitStatementOrder {
identifier: x,
block: y,
}),
))
}
pub fn event_trigger(s: &str) -> IResult<&str, EventTrigger> {
alt((event_trigger_named, event_trigger_nonblocking))(s)
}
pub fn event_trigger_named(s: &str) -> IResult<&str, EventTrigger> {
let (s, _) = symbol("->")(s)?;
let (s, x) = hierarchical_event_identifier(s)?;
let (s, _) = symbol(";")(s)?;
Ok((s, EventTrigger::Named(EventTriggerNamed { identifier: x })))
}
pub fn event_trigger_nonblocking(s: &str) -> IResult<&str, EventTrigger> {
let (s, _) = symbol("->>")(s)?;
let (s, x) = opt(delay_or_event_control)(s)?;
let (s, y) = hierarchical_event_identifier(s)?;
let (s, _) = symbol(";")(s)?;
Ok((
s,
EventTrigger::Nonblocking(EventTriggerNonblocking {
control: x,
identifier: y,
}),
))
}
pub fn disable_statement(s: &str) -> IResult<&str, DisableStatement> {
alt((
disable_statement_task,
disable_statement_block,
disable_statement_fork,
))(s)
}
pub fn disable_statement_task(s: &str) -> IResult<&str, DisableStatement> {
let (s, _) = symbol("disable")(s)?;
let (s, x) = hierarchical_task_identifier(s)?;
let (s, _) = symbol(";")(s)?;
Ok((s, DisableStatement::Task(x)))
}
pub fn disable_statement_block(s: &str) -> IResult<&str, DisableStatement> {
let (s, _) = symbol("disable")(s)?;
let (s, x) = hierarchical_block_identifier(s)?;
let (s, _) = symbol(";")(s)?;
Ok((s, DisableStatement::Block(x)))
}
pub fn disable_statement_fork(s: &str) -> IResult<&str, DisableStatement> {
let (s, _) = symbol("disable")(s)?;
let (s, _) = symbol("fork")(s)?;
let (s, _) = symbol(";")(s)?;
Ok((s, DisableStatement::Fork))
}

View File

@ -75,81 +75,81 @@ pub struct ArrayRangeExpression<'a> {
pub fn concatenation(s: &str) -> IResult<&str, Concatenation> { pub fn concatenation(s: &str) -> IResult<&str, Concatenation> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, expression) = separated_nonempty_list(symbol(","), expression)(s)?; let (s, x) = separated_nonempty_list(symbol(","), expression)(s)?;
let (s, _) = symbol("}")(s)?; let (s, _) = symbol("}")(s)?;
Ok((s, Concatenation { expression })) Ok((s, Concatenation { expression: x }))
} }
pub fn constant_concatenation(s: &str) -> IResult<&str, ConstantConcatenation> { pub fn constant_concatenation(s: &str) -> IResult<&str, ConstantConcatenation> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, expression) = separated_nonempty_list(symbol(","), constant_expression)(s)?; let (s, x) = separated_nonempty_list(symbol(","), constant_expression)(s)?;
let (s, _) = symbol("}")(s)?; let (s, _) = symbol("}")(s)?;
Ok((s, ConstantConcatenation { expression })) Ok((s, ConstantConcatenation { expression: x }))
} }
pub fn constant_multiple_concatenation(s: &str) -> IResult<&str, ConstantMultipleConcatenation> { pub fn constant_multiple_concatenation(s: &str) -> IResult<&str, ConstantMultipleConcatenation> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, expression) = constant_expression(s)?; let (s, x) = constant_expression(s)?;
let (s, concatenation) = constant_concatenation(s)?; let (s, y) = constant_concatenation(s)?;
let (s, _) = symbol("}")(s)?; let (s, _) = symbol("}")(s)?;
Ok(( Ok((
s, s,
ConstantMultipleConcatenation { ConstantMultipleConcatenation {
expression, expression: x,
concatenation, concatenation: y,
}, },
)) ))
} }
pub fn module_path_concatenation(s: &str) -> IResult<&str, ModulePathConcatenation> { pub fn module_path_concatenation(s: &str) -> IResult<&str, ModulePathConcatenation> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, expression) = separated_nonempty_list(symbol(","), module_path_expression)(s)?; let (s, x) = separated_nonempty_list(symbol(","), module_path_expression)(s)?;
let (s, _) = symbol("}")(s)?; let (s, _) = symbol("}")(s)?;
Ok((s, ModulePathConcatenation { expression })) Ok((s, ModulePathConcatenation { expression: x }))
} }
pub fn module_path_multiple_concatenation( pub fn module_path_multiple_concatenation(
s: &str, s: &str,
) -> IResult<&str, ModulePathMultipleConcatenation> { ) -> IResult<&str, ModulePathMultipleConcatenation> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, expression) = constant_expression(s)?; let (s, x) = constant_expression(s)?;
let (s, concatenation) = module_path_concatenation(s)?; let (s, y) = module_path_concatenation(s)?;
let (s, _) = symbol("}")(s)?; let (s, _) = symbol("}")(s)?;
Ok(( Ok((
s, s,
ModulePathMultipleConcatenation { ModulePathMultipleConcatenation {
expression, expression: x,
concatenation, concatenation: y,
}, },
)) ))
} }
pub fn multiple_concatenation(s: &str) -> IResult<&str, MultipleConcatenation> { pub fn multiple_concatenation(s: &str) -> IResult<&str, MultipleConcatenation> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, expression) = expression(s)?; let (s, x) = expression(s)?;
let (s, concatenation) = concatenation(s)?; let (s, y) = concatenation(s)?;
let (s, _) = symbol("}")(s)?; let (s, _) = symbol("}")(s)?;
Ok(( Ok((
s, s,
MultipleConcatenation { MultipleConcatenation {
expression, expression: x,
concatenation, concatenation: y,
}, },
)) ))
} }
pub fn streaming_concatenation(s: &str) -> IResult<&str, StreamingConcatenation> { pub fn streaming_concatenation(s: &str) -> IResult<&str, StreamingConcatenation> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, operator) = stream_operator(s)?; let (s, x) = stream_operator(s)?;
let (s, size) = opt(slice_size)(s)?; let (s, y) = opt(slice_size)(s)?;
let (s, concatenation) = stream_concatenation(s)?; let (s, z) = stream_concatenation(s)?;
let (s, _) = symbol("}")(s)?; let (s, _) = symbol("}")(s)?;
Ok(( Ok((
s, s,
StreamingConcatenation { StreamingConcatenation {
operator, operator: x,
size, size: y,
concatenation, concatenation: z,
}, },
)) ))
} }
@ -167,37 +167,43 @@ pub fn slice_size(s: &str) -> IResult<&str, SliceSize> {
pub fn stream_concatenation(s: &str) -> IResult<&str, StreamConcatenation> { pub fn stream_concatenation(s: &str) -> IResult<&str, StreamConcatenation> {
let (s, _) = symbol("{")(s)?; let (s, _) = symbol("{")(s)?;
let (s, expression) = separated_nonempty_list(symbol(","), stream_expression)(s)?; let (s, x) = separated_nonempty_list(symbol(","), stream_expression)(s)?;
let (s, _) = symbol("}")(s)?; let (s, _) = symbol("}")(s)?;
Ok((s, StreamConcatenation { expression })) Ok((s, StreamConcatenation { expression: x }))
} }
pub fn stream_expression(s: &str) -> IResult<&str, StreamExpression> { pub fn stream_expression(s: &str) -> IResult<&str, StreamExpression> {
let (s, expression) = expression(s)?; let (s, x) = expression(s)?;
let (s, with) = opt(preceded( let (s, y) = opt(preceded(
symbol("with"), symbol("with"),
delimited(symbol("["), array_range_expression, symbol("]")), delimited(symbol("["), array_range_expression, symbol("]")),
))(s)?; ))(s)?;
Ok((s, StreamExpression { expression, with })) Ok((
s,
StreamExpression {
expression: x,
with: y,
},
))
} }
pub fn array_range_expression(s: &str) -> IResult<&str, ArrayRangeExpression> { pub fn array_range_expression(s: &str) -> IResult<&str, ArrayRangeExpression> {
let (s, arg0) = expression(s)?; let (s, x) = expression(s)?;
let (s, x) = opt(pair( let (s, y) = opt(pair(
alt((symbol(":"), symbol("+:"), symbol("-:"))), alt((symbol(":"), symbol("+:"), symbol("-:"))),
expression, expression,
))(s)?; ))(s)?;
let (operator, arg1) = if let Some((x, y)) = x { let (y, z) = if let Some((y, z)) = y {
(Some(x), Some(y)) (Some(y), Some(z))
} else { } else {
(None, None) (None, None)
}; };
Ok(( Ok((
s, s,
ArrayRangeExpression { ArrayRangeExpression {
arg0, arg0: x,
operator, operator: y,
arg1, arg1: z,
}, },
)) ))
} }

View File

@ -9,9 +9,9 @@ use nom::IResult;
#[derive(Debug)] #[derive(Debug)]
pub enum NetLvalue<'a> { pub enum NetLvalue<'a> {
Identifier(NetLvalueIdentifier<'a>), Identifier(Box<NetLvalueIdentifier<'a>>),
Lvalue(Vec<NetLvalue<'a>>), Lvalue(Box<Vec<NetLvalue<'a>>>),
Pattern(NetLvaluePattern<'a>), Pattern(Box<NetLvaluePattern<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
@ -28,10 +28,10 @@ pub struct NetLvaluePattern<'a> {
#[derive(Debug)] #[derive(Debug)]
pub enum VariableLvalue<'a> { pub enum VariableLvalue<'a> {
Identifier(VariableLvalueIdentifier<'a>), Identifier(Box<VariableLvalueIdentifier<'a>>),
Lvalue(Vec<VariableLvalue<'a>>), Lvalue(Box<Vec<VariableLvalue<'a>>>),
Pattern(VariableLvaluePattern<'a>), Pattern(Box<VariableLvaluePattern<'a>>),
Concatenation(StreamingConcatenation<'a>), Concatenation(Box<StreamingConcatenation<'a>>),
} }
#[derive(Debug)] #[derive(Debug)]
@ -61,18 +61,27 @@ pub fn net_lvalue(s: &str) -> IResult<&str, NetLvalue> {
} }
pub fn net_lvalue_identifier(s: &str) -> IResult<&str, NetLvalue> { pub fn net_lvalue_identifier(s: &str) -> IResult<&str, NetLvalue> {
let (s, identifier) = ps_or_hierarchical_net_identifier(s)?; let (s, x) = ps_or_hierarchical_net_identifier(s)?;
let (s, select) = constant_select(s)?; let (s, y) = constant_select(s)?;
Ok(( Ok((
s, s,
NetLvalue::Identifier(NetLvalueIdentifier { identifier, select }), NetLvalue::Identifier(Box::new(NetLvalueIdentifier {
identifier: x,
select: y,
})),
)) ))
} }
pub fn net_lvalue_pattern(s: &str) -> IResult<&str, NetLvalue> { pub fn net_lvalue_pattern(s: &str) -> IResult<&str, NetLvalue> {
let (s, r#type) = opt(assignment_pattern_expression_type)(s)?; let (s, x) = opt(assignment_pattern_expression_type)(s)?;
let (s, lvalue) = assignment_pattern_net_lvalue(s)?; let (s, y) = assignment_pattern_net_lvalue(s)?;
Ok((s, NetLvalue::Pattern(NetLvaluePattern { r#type, lvalue }))) Ok((
s,
NetLvalue::Pattern(Box::new(NetLvaluePattern {
r#type: x,
lvalue: y,
})),
))
} }
pub fn net_lvalue_lvalue(s: &str) -> IResult<&str, NetLvalue> { pub fn net_lvalue_lvalue(s: &str) -> IResult<&str, NetLvalue> {
@ -87,7 +96,7 @@ pub fn net_lvalue_lvalue(s: &str) -> IResult<&str, NetLvalue> {
ret.push(y); ret.push(y);
} }
Ok((s, NetLvalue::Lvalue(ret))) Ok((s, NetLvalue::Lvalue(Box::new(ret))))
} }
pub fn variable_lvalue(s: &str) -> IResult<&str, VariableLvalue> { pub fn variable_lvalue(s: &str) -> IResult<&str, VariableLvalue> {
@ -96,34 +105,37 @@ pub fn variable_lvalue(s: &str) -> IResult<&str, VariableLvalue> {
variable_lvalue_lvalue, variable_lvalue_lvalue,
variable_lvalue_pattern, variable_lvalue_pattern,
map(streaming_concatenation, |x| { map(streaming_concatenation, |x| {
VariableLvalue::Concatenation(x) VariableLvalue::Concatenation(Box::new(x))
}), }),
))(s) ))(s)
} }
pub fn variable_lvalue_identifier(s: &str) -> IResult<&str, VariableLvalue> { pub fn variable_lvalue_identifier(s: &str) -> IResult<&str, VariableLvalue> {
let (s, scope) = opt(alt(( let (s, x) = opt(alt((
terminated(implicit_class_handle, symbol(".")), terminated(implicit_class_handle, symbol(".")),
package_scope, package_scope,
)))(s)?; )))(s)?;
let (s, identifier) = hierarchical_variable_identifier(s)?; let (s, y) = hierarchical_variable_identifier(s)?;
let (s, select) = select(s)?; let (s, z) = select(s)?;
Ok(( Ok((
s, s,
VariableLvalue::Identifier(VariableLvalueIdentifier { VariableLvalue::Identifier(Box::new(VariableLvalueIdentifier {
scope, scope: x,
identifier, identifier: y,
select, select: z,
}), })),
)) ))
} }
pub fn variable_lvalue_pattern(s: &str) -> IResult<&str, VariableLvalue> { pub fn variable_lvalue_pattern(s: &str) -> IResult<&str, VariableLvalue> {
let (s, r#type) = opt(assignment_pattern_expression_type)(s)?; let (s, x) = opt(assignment_pattern_expression_type)(s)?;
let (s, lvalue) = assignment_pattern_variable_lvalue(s)?; let (s, y) = assignment_pattern_variable_lvalue(s)?;
Ok(( Ok((
s, s,
VariableLvalue::Pattern(VariableLvaluePattern { r#type, lvalue }), VariableLvalue::Pattern(Box::new(VariableLvaluePattern {
r#type: x,
lvalue: y,
})),
)) ))
} }
@ -139,22 +151,22 @@ pub fn variable_lvalue_lvalue(s: &str) -> IResult<&str, VariableLvalue> {
ret.push(y); ret.push(y);
} }
Ok((s, VariableLvalue::Lvalue(ret))) Ok((s, VariableLvalue::Lvalue(Box::new(ret))))
} }
pub fn nonrange_variable_lvalue(s: &str) -> IResult<&str, NonrangeVariableLvalue> { pub fn nonrange_variable_lvalue(s: &str) -> IResult<&str, NonrangeVariableLvalue> {
let (s, scope) = opt(alt(( let (s, x) = opt(alt((
terminated(implicit_class_handle, symbol(".")), terminated(implicit_class_handle, symbol(".")),
package_scope, package_scope,
)))(s)?; )))(s)?;
let (s, identifier) = hierarchical_variable_identifier(s)?; let (s, y) = hierarchical_variable_identifier(s)?;
let (s, select) = nonrange_select(s)?; let (s, z) = nonrange_select(s)?;
Ok(( Ok((
s, s,
NonrangeVariableLvalue { NonrangeVariableLvalue {
scope, scope: x,
identifier, identifier: y,
select, select: z,
}, },
)) ))
} }

View File

@ -140,7 +140,7 @@ pub struct TaggedUnionExpression<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct InsideExpression<'a> { pub struct InsideExpression<'a> {
pub expression: Expression<'a>, pub expression: Expression<'a>,
pub open_range_list: OpenRangeList<'a>, pub open_range_list: Vec<ValueRange<'a>>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -211,47 +211,47 @@ pub fn inc_or_dec_expression(s: &str) -> IResult<&str, IncOrDecExpression> {
} }
pub fn inc_or_dec_expression_prefix(s: &str) -> IResult<&str, IncOrDecExpression> { pub fn inc_or_dec_expression_prefix(s: &str) -> IResult<&str, IncOrDecExpression> {
let (s, operator) = inc_or_dec_operator(s)?; let (s, x) = inc_or_dec_operator(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, lvalue) = variable_lvalue(s)?; let (s, z) = variable_lvalue(s)?;
Ok(( Ok((
s, s,
IncOrDecExpression::Prefix(IncOrDecExpressionPrefix { IncOrDecExpression::Prefix(IncOrDecExpressionPrefix {
operator, operator: x,
attribute, attribute: y,
lvalue, lvalue: z,
}), }),
)) ))
} }
pub fn inc_or_dec_expression_suffix(s: &str) -> IResult<&str, IncOrDecExpression> { pub fn inc_or_dec_expression_suffix(s: &str) -> IResult<&str, IncOrDecExpression> {
let (s, lvalue) = variable_lvalue(s)?; let (s, x) = variable_lvalue(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, operator) = inc_or_dec_operator(s)?; let (s, z) = inc_or_dec_operator(s)?;
Ok(( Ok((
s, s,
IncOrDecExpression::Suffix(IncOrDecExpressionSuffix { IncOrDecExpression::Suffix(IncOrDecExpressionSuffix {
lvalue, lvalue: x,
attribute, attribute: y,
operator, operator: z,
}), }),
)) ))
} }
pub fn conditional_expression(s: &str) -> IResult<&str, ConditionalExpression> { pub fn conditional_expression(s: &str) -> IResult<&str, ConditionalExpression> {
let (s, predicate) = cond_predicate(s)?; let (s, x) = cond_predicate(s)?;
let (s, _) = symbol("?")(s)?; let (s, _) = symbol("?")(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, arg0) = expression(s)?; let (s, z) = expression(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
let (s, arg1) = expression(s)?; let (s, v) = expression(s)?;
Ok(( Ok((
s, s,
ConditionalExpression { ConditionalExpression {
predicate, predicate: x,
attribute, attribute: y,
arg0, arg0: z,
arg1, arg1: v,
}, },
)) ))
} }
@ -268,49 +268,49 @@ pub fn constant_expression(s: &str) -> IResult<&str, ConstantExpression> {
} }
pub fn constant_expression_unary(s: &str) -> IResult<&str, ConstantExpression> { pub fn constant_expression_unary(s: &str) -> IResult<&str, ConstantExpression> {
let (s, operator) = unary_operator(s)?; let (s, x) = unary_operator(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, arg0) = constant_primary(s)?; let (s, z) = constant_primary(s)?;
Ok(( Ok((
s, s,
ConstantExpression::Unary(Box::new(ConstantExpressionUnary { ConstantExpression::Unary(Box::new(ConstantExpressionUnary {
operator, operator: x,
attribute, attribute: y,
arg0, arg0: z,
})), })),
)) ))
} }
pub fn constant_expression_binary(s: &str) -> IResult<&str, ConstantExpression> { pub fn constant_expression_binary(s: &str) -> IResult<&str, ConstantExpression> {
let (s, arg0) = constant_expression(s)?; let (s, x) = constant_expression(s)?;
let (s, operator) = binary_operator(s)?; let (s, y) = binary_operator(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, z) = many0(attribute_instance)(s)?;
let (s, arg1) = constant_expression(s)?; let (s, v) = constant_expression(s)?;
Ok(( Ok((
s, s,
ConstantExpression::Binary(Box::new(ConstantExpressionBinary { ConstantExpression::Binary(Box::new(ConstantExpressionBinary {
arg0, arg0: x,
operator, operator: y,
attribute, attribute: z,
arg1, arg1: v,
})), })),
)) ))
} }
pub fn constant_expression_ternary(s: &str) -> IResult<&str, ConstantExpression> { pub fn constant_expression_ternary(s: &str) -> IResult<&str, ConstantExpression> {
let (s, predicate) = constant_expression(s)?; let (s, x) = constant_expression(s)?;
let (s, _) = symbol("?")(s)?; let (s, _) = symbol("?")(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, arg0) = constant_expression(s)?; let (s, z) = constant_expression(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
let (s, arg1) = constant_expression(s)?; let (s, v) = constant_expression(s)?;
Ok(( Ok((
s, s,
ConstantExpression::Ternary(Box::new(ConstantExpressionTernary { ConstantExpression::Ternary(Box::new(ConstantExpressionTernary {
predicate, predicate: x,
attribute, attribute: y,
arg0, arg0: z,
arg1, arg1: v,
})), })),
)) ))
} }
@ -403,57 +403,57 @@ pub fn expression(s: &str) -> IResult<&str, Expression> {
} }
pub fn expression_unary(s: &str) -> IResult<&str, Expression> { pub fn expression_unary(s: &str) -> IResult<&str, Expression> {
let (s, operator) = unary_operator(s)?; let (s, x) = unary_operator(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, arg0) = primary(s)?; let (s, z) = primary(s)?;
Ok(( Ok((
s, s,
Expression::Unary(Box::new(ExpressionUnary { Expression::Unary(Box::new(ExpressionUnary {
operator, operator: x,
attribute, attribute: y,
arg0, arg0: z,
})), })),
)) ))
} }
pub fn expression_binary(s: &str) -> IResult<&str, Expression> { pub fn expression_binary(s: &str) -> IResult<&str, Expression> {
let (s, arg0) = expression(s)?; let (s, x) = expression(s)?;
let (s, operator) = binary_operator(s)?; let (s, y) = binary_operator(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, z) = many0(attribute_instance)(s)?;
let (s, arg1) = expression(s)?; let (s, v) = expression(s)?;
Ok(( Ok((
s, s,
Expression::Binary(Box::new(ExpressionBinary { Expression::Binary(Box::new(ExpressionBinary {
arg0, arg0: x,
operator, operator: y,
attribute, attribute: z,
arg1, arg1: v,
})), })),
)) ))
} }
pub fn tagged_union_expression(s: &str) -> IResult<&str, TaggedUnionExpression> { pub fn tagged_union_expression(s: &str) -> IResult<&str, TaggedUnionExpression> {
let (s, _) = symbol("tagged")(s)?; let (s, _) = symbol("tagged")(s)?;
let (s, identifier) = member_identifier(s)?; let (s, x) = member_identifier(s)?;
let (s, expression) = opt(expression)(s)?; let (s, y) = opt(expression)(s)?;
Ok(( Ok((
s, s,
TaggedUnionExpression { TaggedUnionExpression {
identifier, identifier: x,
expression, expression: y,
}, },
)) ))
} }
pub fn inside_expression(s: &str) -> IResult<&str, InsideExpression> { pub fn inside_expression(s: &str) -> IResult<&str, InsideExpression> {
let (s, expression) = expression(s)?; let (s, x) = expression(s)?;
let (s, _) = symbol("inside")(s)?; let (s, _) = symbol("inside")(s)?;
let (s, open_range_list) = delimited(symbol("{"), open_range_list, symbol("}"))(s)?; let (s, y) = delimited(symbol("{"), open_range_list, symbol("}"))(s)?;
Ok(( Ok((
s, s,
InsideExpression { InsideExpression {
expression, expression: x,
open_range_list, open_range_list: y,
}, },
)) ))
} }
@ -493,19 +493,19 @@ pub fn mintypmax_expression_ternary(s: &str) -> IResult<&str, MintypmaxExpressio
pub fn module_path_conditional_expression( pub fn module_path_conditional_expression(
s: &str, s: &str,
) -> IResult<&str, ModulePathConditionalExpression> { ) -> IResult<&str, ModulePathConditionalExpression> {
let (s, predicate) = module_path_expression(s)?; let (s, x) = module_path_expression(s)?;
let (s, _) = symbol("?")(s)?; let (s, _) = symbol("?")(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, arg0) = module_path_expression(s)?; let (s, z) = module_path_expression(s)?;
let (s, _) = symbol(":")(s)?; let (s, _) = symbol(":")(s)?;
let (s, arg1) = module_path_expression(s)?; let (s, v) = module_path_expression(s)?;
Ok(( Ok((
s, s,
ModulePathConditionalExpression { ModulePathConditionalExpression {
predicate, predicate: x,
attribute, attribute: y,
arg0, arg0: z,
arg1, arg1: v,
}, },
)) ))
} }
@ -524,31 +524,31 @@ pub fn module_path_expression(s: &str) -> IResult<&str, ModulePathExpression> {
} }
pub fn module_path_expression_unary(s: &str) -> IResult<&str, ModulePathExpression> { pub fn module_path_expression_unary(s: &str) -> IResult<&str, ModulePathExpression> {
let (s, operator) = unary_module_path_operator(s)?; let (s, x) = unary_module_path_operator(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, arg0) = module_path_primary(s)?; let (s, z) = module_path_primary(s)?;
Ok(( Ok((
s, s,
ModulePathExpression::Unary(Box::new(ModulePathExpressionUnary { ModulePathExpression::Unary(Box::new(ModulePathExpressionUnary {
operator, operator: x,
attribute, attribute: y,
arg0, arg0: z,
})), })),
)) ))
} }
pub fn module_path_expression_binary(s: &str) -> IResult<&str, ModulePathExpression> { pub fn module_path_expression_binary(s: &str) -> IResult<&str, ModulePathExpression> {
let (s, arg0) = module_path_expression(s)?; let (s, x) = module_path_expression(s)?;
let (s, operator) = binary_module_path_operator(s)?; let (s, y) = binary_module_path_operator(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, z) = many0(attribute_instance)(s)?;
let (s, arg1) = module_path_expression(s)?; let (s, v) = module_path_expression(s)?;
Ok(( Ok((
s, s,
ModulePathExpression::Binary(Box::new(ModulePathExpressionBinary { ModulePathExpression::Binary(Box::new(ModulePathExpressionBinary {
arg0, arg0: x,
operator, operator: y,
attribute, attribute: z,
arg1, arg1: v,
})), })),
)) ))
} }

View File

@ -91,7 +91,7 @@ pub fn integral_number(s: &str) -> IResult<&str, Number> {
} }
pub fn decimal_number(s: &str) -> IResult<&str, IntegralNumber> { pub fn decimal_number(s: &str) -> IResult<&str, IntegralNumber> {
let (s, (size, decimal_base, decimal_value)) = tuple(( let (s, (x, y, z)) = tuple((
opt(size), opt(size),
decimal_base, decimal_base,
alt((unsigned_number, x_number, z_number)), alt((unsigned_number, x_number, z_number)),
@ -99,9 +99,9 @@ pub fn decimal_number(s: &str) -> IResult<&str, IntegralNumber> {
Ok(( Ok((
s, s,
IntegralNumber::DecimalNumber(DecimalNumber { IntegralNumber::DecimalNumber(DecimalNumber {
size, size: x,
decimal_base, decimal_base: y,
decimal_value, decimal_value: z,
}), }),
)) ))
} }
@ -112,37 +112,37 @@ pub fn integral_unsigned_number(s: &str) -> IResult<&str, IntegralNumber> {
} }
pub fn binary_number(s: &str) -> IResult<&str, IntegralNumber> { pub fn binary_number(s: &str) -> IResult<&str, IntegralNumber> {
let (s, (size, binary_base, binary_value)) = tuple((opt(size), binary_base, binary_value))(s)?; let (s, (x, y, z)) = tuple((opt(size), binary_base, binary_value))(s)?;
Ok(( Ok((
s, s,
IntegralNumber::BinaryNumber(BinaryNumber { IntegralNumber::BinaryNumber(BinaryNumber {
size, size: x,
binary_base, binary_base: y,
binary_value, binary_value: z,
}), }),
)) ))
} }
pub fn octal_number(s: &str) -> IResult<&str, IntegralNumber> { pub fn octal_number(s: &str) -> IResult<&str, IntegralNumber> {
let (s, (size, octal_base, octal_value)) = tuple((opt(size), octal_base, octal_value))(s)?; let (s, (x, y, z)) = tuple((opt(size), octal_base, octal_value))(s)?;
Ok(( Ok((
s, s,
IntegralNumber::OctalNumber(OctalNumber { IntegralNumber::OctalNumber(OctalNumber {
size, size: x,
octal_base, octal_base: y,
octal_value, octal_value: z,
}), }),
)) ))
} }
pub fn hex_number(s: &str) -> IResult<&str, IntegralNumber> { pub fn hex_number(s: &str) -> IResult<&str, IntegralNumber> {
let (s, (size, hex_base, hex_value)) = tuple((opt(size), hex_base, hex_value))(s)?; let (s, (x, y, z)) = tuple((opt(size), hex_base, hex_value))(s)?;
Ok(( Ok((
s, s,
IntegralNumber::HexNumber(HexNumber { IntegralNumber::HexNumber(HexNumber {
size, size: x,
hex_base, hex_base: y,
hex_value, hex_value: z,
}), }),
)) ))
} }
@ -164,34 +164,31 @@ pub fn real_number(s: &str) -> IResult<&str, Number> {
} }
pub fn fixed_point_number(s: &str) -> IResult<&str, RealNumber> { pub fn fixed_point_number(s: &str) -> IResult<&str, RealNumber> {
let (s, (integer_value, _, fraction_value)) = let (s, (x, _, y)) = tuple((unsigned_number, symbol("."), unsigned_number))(s)?;
tuple((unsigned_number, symbol("."), unsigned_number))(s)?;
Ok(( Ok((
s, s,
RealNumber::FixedPointNumber(FixedPointNumber { RealNumber::FixedPointNumber(FixedPointNumber {
integer_value, integer_value: x,
fraction_value, fraction_value: y,
}), }),
)) ))
} }
pub fn floating_point_number(s: &str) -> IResult<&str, RealNumber> { pub fn floating_point_number(s: &str) -> IResult<&str, RealNumber> {
let (s, integer_value) = unsigned_number(s)?; let (s, x) = unsigned_number(s)?;
let (s, fraction_value) = opt(tuple((symbol("."), unsigned_number)))(s)?; let (s, y) = opt(preceded(symbol("."), unsigned_number))(s)?;
let (s, exponent) = alt((symbol("e"), symbol("E")))(s)?; let (s, z) = alt((symbol("e"), symbol("E")))(s)?;
let (s, sign) = opt(alt((symbol("+"), symbol("-"))))(s)?; let (s, v) = opt(alt((symbol("+"), symbol("-"))))(s)?;
let (s, exponent_value) = unsigned_number(s)?; let (s, w) = unsigned_number(s)?;
let fraction_value = fraction_value.and_then(|(_, y)| Some(y));
Ok(( Ok((
s, s,
RealNumber::FloatingPointNumber(FloatingPointNumber { RealNumber::FloatingPointNumber(FloatingPointNumber {
integer_value, integer_value: x,
fraction_value, fraction_value: y,
exponent, exponent: z,
sign, sign: v,
exponent_value, exponent_value: w,
}), }),
)) ))
} }

View File

@ -21,7 +21,7 @@ pub enum ConstantPrimary<'a> {
LetExpression(LetExpression<'a>), LetExpression(LetExpression<'a>),
MintypmaxExpression(ConstantMintypmaxExpression<'a>), MintypmaxExpression(ConstantMintypmaxExpression<'a>),
Cast(ConstantCast<'a>), Cast(ConstantCast<'a>),
AssignmentPatternExpression(ConstantAssignmentPatternExpression<'a>), AssignmentPatternExpression(AssignmentPatternExpression<'a>),
TypeReference(TypeReference<'a>), TypeReference(TypeReference<'a>),
Null, Null,
} }
@ -233,48 +233,60 @@ pub fn constant_primary(s: &str) -> IResult<&str, ConstantPrimary> {
} }
pub fn constant_primary_ps_parameter(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary_ps_parameter(s: &str) -> IResult<&str, ConstantPrimary> {
let (s, identifier) = ps_parameter_identifier(s)?; let (s, x) = ps_parameter_identifier(s)?;
let (s, select) = constant_select(s)?; let (s, y) = constant_select(s)?;
Ok(( Ok((
s, s,
ConstantPrimary::PsParameter(ConstantPrimaryPsParameter { identifier, select }), ConstantPrimary::PsParameter(ConstantPrimaryPsParameter {
identifier: x,
select: y,
}),
)) ))
} }
pub fn constant_primary_specparam(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary_specparam(s: &str) -> IResult<&str, ConstantPrimary> {
let (s, identifier) = specparam_identifier(s)?; let (s, x) = specparam_identifier(s)?;
let (s, range) = opt(delimited( let (s, y) = opt(delimited(
symbol("["), symbol("["),
constant_range_expression, constant_range_expression,
symbol("]"), symbol("]"),
))(s)?; ))(s)?;
Ok(( Ok((
s, s,
ConstantPrimary::Specparam(ConstantPrimarySpecparam { identifier, range }), ConstantPrimary::Specparam(ConstantPrimarySpecparam {
identifier: x,
range: y,
}),
)) ))
} }
pub fn constant_primary_formal_port(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary_formal_port(s: &str) -> IResult<&str, ConstantPrimary> {
let (s, identifier) = formal_port_identifier(s)?; let (s, x) = formal_port_identifier(s)?;
let (s, select) = constant_select(s)?; let (s, y) = constant_select(s)?;
Ok(( Ok((
s, s,
ConstantPrimary::FormalPort(ConstantPrimaryFormalPort { identifier, select }), ConstantPrimary::FormalPort(ConstantPrimaryFormalPort {
identifier: x,
select: y,
}),
)) ))
} }
pub fn constant_primary_enum(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary_enum(s: &str) -> IResult<&str, ConstantPrimary> {
let (s, scope) = alt((package_scope, class_scope))(s)?; let (s, x) = alt((package_scope, class_scope))(s)?;
let (s, identifier) = enum_identifier(s)?; let (s, y) = enum_identifier(s)?;
Ok(( Ok((
s, s,
ConstantPrimary::Enum(ConstantPrimaryEnum { scope, identifier }), ConstantPrimary::Enum(ConstantPrimaryEnum {
scope: x,
identifier: y,
}),
)) ))
} }
pub fn constant_primary_concatenation(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary_concatenation(s: &str) -> IResult<&str, ConstantPrimary> {
let (s, concatenation) = constant_concatenation(s)?; let (s, x) = constant_concatenation(s)?;
let (s, range) = opt(delimited( let (s, y) = opt(delimited(
symbol("["), symbol("["),
constant_range_expression, constant_range_expression,
symbol("]"), symbol("]"),
@ -282,15 +294,15 @@ pub fn constant_primary_concatenation(s: &str) -> IResult<&str, ConstantPrimary>
Ok(( Ok((
s, s,
ConstantPrimary::Concatenation(ConstantPrimaryConcatenation { ConstantPrimary::Concatenation(ConstantPrimaryConcatenation {
concatenation, concatenation: x,
range, range: y,
}), }),
)) ))
} }
pub fn constant_primary_multiple_concatenation(s: &str) -> IResult<&str, ConstantPrimary> { pub fn constant_primary_multiple_concatenation(s: &str) -> IResult<&str, ConstantPrimary> {
let (s, concatenation) = constant_multiple_concatenation(s)?; let (s, x) = constant_multiple_concatenation(s)?;
let (s, range) = opt(delimited( let (s, y) = opt(delimited(
symbol("["), symbol("["),
constant_range_expression, constant_range_expression,
symbol("]"), symbol("]"),
@ -298,8 +310,8 @@ pub fn constant_primary_multiple_concatenation(s: &str) -> IResult<&str, Constan
Ok(( Ok((
s, s,
ConstantPrimary::MultipleConcatenation(ConstantPrimaryMultipleConcatenation { ConstantPrimary::MultipleConcatenation(ConstantPrimaryMultipleConcatenation {
concatenation, concatenation: x,
range, range: y,
}), }),
)) ))
} }
@ -360,39 +372,39 @@ pub fn primary(s: &str) -> IResult<&str, Primary> {
} }
pub fn primary_hierarchical(s: &str) -> IResult<&str, Primary> { pub fn primary_hierarchical(s: &str) -> IResult<&str, Primary> {
let (s, qualifier) = opt(primary_hierarchical_qualifier)(s)?; let (s, x) = opt(primary_hierarchical_qualifier)(s)?;
let (s, identifier) = hierarchical_identifier(s)?; let (s, y) = hierarchical_identifier(s)?;
let (s, select) = select(s)?; let (s, z) = select(s)?;
Ok(( Ok((
s, s,
Primary::Hierarchical(PrimaryHierarchical { Primary::Hierarchical(PrimaryHierarchical {
qualifier, qualifier: x,
identifier, identifier: y,
select, select: z,
}), }),
)) ))
} }
pub fn primary_concatenation(s: &str) -> IResult<&str, Primary> { pub fn primary_concatenation(s: &str) -> IResult<&str, Primary> {
let (s, concatenation) = concatenation(s)?; let (s, x) = concatenation(s)?;
let (s, range) = opt(range_expression)(s)?; let (s, y) = opt(range_expression)(s)?;
Ok(( Ok((
s, s,
Primary::Concatenation(PrimaryConcatenation { Primary::Concatenation(PrimaryConcatenation {
concatenation, concatenation: x,
range, range: y,
}), }),
)) ))
} }
pub fn primary_multiple_concatenation(s: &str) -> IResult<&str, Primary> { pub fn primary_multiple_concatenation(s: &str) -> IResult<&str, Primary> {
let (s, concatenation) = multiple_concatenation(s)?; let (s, x) = multiple_concatenation(s)?;
let (s, range) = opt(range_expression)(s)?; let (s, y) = opt(range_expression)(s)?;
Ok(( Ok((
s, s,
Primary::MultipleConcatenation(PrimaryMultipleConcatenation { Primary::MultipleConcatenation(PrimaryMultipleConcatenation {
concatenation, concatenation: x,
range, range: y,
}), }),
)) ))
} }
@ -409,16 +421,16 @@ pub fn primary_hierarchical_qualifier(s: &str) -> IResult<&str, PrimaryHierarchi
} }
pub fn class_qualifier(s: &str) -> IResult<&str, ClassQualifier> { pub fn class_qualifier(s: &str) -> IResult<&str, ClassQualifier> {
let (s, local) = opt(symbol("local::"))(s)?; let (s, x) = opt(symbol("local::"))(s)?;
let (s, scope) = opt(alt(( let (s, y) = opt(alt((
terminated(implicit_class_handle, symbol(".")), terminated(implicit_class_handle, symbol(".")),
class_scope, class_scope,
)))(s)?; )))(s)?;
Ok(( Ok((
s, s,
ClassQualifier { ClassQualifier {
local: local.is_some(), local: x.is_some(),
scope, scope: y,
}, },
)) ))
} }
@ -446,20 +458,20 @@ pub fn time_literal(s: &str) -> IResult<&str, TimeLiteral> {
} }
pub fn unsigned_time_literal(s: &str) -> IResult<&str, TimeLiteral> { pub fn unsigned_time_literal(s: &str) -> IResult<&str, TimeLiteral> {
let (s, number) = unsigned_number(s)?; let (s, x) = unsigned_number(s)?;
let (s, unit) = time_unit(s)?; let (s, y) = time_unit(s)?;
Ok(( Ok((
s, s,
TimeLiteral::UnsignedTimeLiteral(UnsignedTimeLiteral { number, unit }), TimeLiteral::UnsignedTimeLiteral(UnsignedTimeLiteral { number: x, unit: y }),
)) ))
} }
pub fn fixed_point_time_literal(s: &str) -> IResult<&str, TimeLiteral> { pub fn fixed_point_time_literal(s: &str) -> IResult<&str, TimeLiteral> {
let (s, number) = fixed_point_number(s)?; let (s, x) = fixed_point_number(s)?;
let (s, unit) = time_unit(s)?; let (s, y) = time_unit(s)?;
Ok(( Ok((
s, s,
TimeLiteral::FixedPointTimeLiteral(FixedPointTimeLiteral { number, unit }), TimeLiteral::FixedPointTimeLiteral(FixedPointTimeLiteral { number: x, unit: y }),
)) ))
} }
@ -501,15 +513,18 @@ pub fn bit_select(s: &str) -> IResult<&str, Vec<Expression>> {
} }
pub fn select(s: &str) -> IResult<&str, Select> { pub fn select(s: &str) -> IResult<&str, Select> {
let (s, member) = opt(pair( let (s, x) = opt(pair(
many0(preceded(symbol("."), pair(member_identifier, bit_select))), many0(preceded(symbol("."), pair(member_identifier, bit_select))),
preceded(symbol("."), member_identifier), preceded(symbol("."), member_identifier),
))(s)?; ))(s)?;
let (s, bit_select) = bit_select(s)?; let (s, y) = bit_select(s)?;
let (s, part_select_range) = opt(delimited(symbol("["), part_select_range, symbol("]")))(s)?; let (s, z) = opt(delimited(symbol("["), part_select_range, symbol("]")))(s)?;
let member = if let Some((upper, identifier)) = member { let x = if let Some((x, y)) = x {
Some(SelectMember { upper, identifier }) Some(SelectMember {
upper: x,
identifier: y,
})
} else { } else {
None None
}; };
@ -517,22 +532,25 @@ pub fn select(s: &str) -> IResult<&str, Select> {
Ok(( Ok((
s, s,
Select { Select {
member, member: x,
bit_select, bit_select: y,
part_select_range, part_select_range: z,
}, },
)) ))
} }
pub fn nonrange_select(s: &str) -> IResult<&str, Select> { pub fn nonrange_select(s: &str) -> IResult<&str, Select> {
let (s, member) = opt(pair( let (s, x) = opt(pair(
many0(preceded(symbol("."), pair(member_identifier, bit_select))), many0(preceded(symbol("."), pair(member_identifier, bit_select))),
preceded(symbol("."), member_identifier), preceded(symbol("."), member_identifier),
))(s)?; ))(s)?;
let (s, bit_select) = bit_select(s)?; let (s, y) = bit_select(s)?;
let member = if let Some((upper, identifier)) = member { let x = if let Some((x, y)) = x {
Some(SelectMember { upper, identifier }) Some(SelectMember {
upper: x,
identifier: y,
})
} else { } else {
None None
}; };
@ -540,8 +558,8 @@ pub fn nonrange_select(s: &str) -> IResult<&str, Select> {
Ok(( Ok((
s, s,
Select { Select {
member, member: x,
bit_select, bit_select: y,
part_select_range: None, part_select_range: None,
}, },
)) ))
@ -552,19 +570,22 @@ pub fn constant_bit_select(s: &str) -> IResult<&str, Vec<ConstantExpression>> {
} }
pub fn constant_select(s: &str) -> IResult<&str, ConstantSelect> { pub fn constant_select(s: &str) -> IResult<&str, ConstantSelect> {
let (s, member) = opt(pair( let (s, x) = opt(pair(
many0(preceded(symbol("."), pair(member_identifier, bit_select))), many0(preceded(symbol("."), pair(member_identifier, bit_select))),
preceded(symbol("."), member_identifier), preceded(symbol("."), member_identifier),
))(s)?; ))(s)?;
let (s, bit_select) = constant_bit_select(s)?; let (s, y) = constant_bit_select(s)?;
let (s, part_select_range) = opt(delimited( let (s, z) = opt(delimited(
symbol("["), symbol("["),
constant_part_select_range, constant_part_select_range,
symbol("]"), symbol("]"),
))(s)?; ))(s)?;
let member = if let Some((upper, identifier)) = member { let x = if let Some((x, y)) = x {
Some(SelectMember { upper, identifier }) Some(SelectMember {
upper: x,
identifier: y,
})
} else { } else {
None None
}; };
@ -572,18 +593,24 @@ pub fn constant_select(s: &str) -> IResult<&str, ConstantSelect> {
Ok(( Ok((
s, s,
ConstantSelect { ConstantSelect {
member, member: x,
bit_select, bit_select: y,
part_select_range, part_select_range: z,
}, },
)) ))
} }
pub fn constant_cast(s: &str) -> IResult<&str, ConstantCast> { pub fn constant_cast(s: &str) -> IResult<&str, ConstantCast> {
let (s, r#type) = casting_type(s)?; let (s, x) = casting_type(s)?;
let (s, _) = symbol("'")(s)?; let (s, _) = symbol("'")(s)?;
let (s, expression) = delimited(symbol("("), constant_expression, symbol(")"))(s)?; let (s, y) = delimited(symbol("("), constant_expression, symbol(")"))(s)?;
Ok((s, ConstantCast { r#type, expression })) Ok((
s,
ConstantCast {
r#type: x,
expression: y,
},
))
} }
pub fn constant_let_expression(s: &str) -> IResult<&str, LetExpression> { pub fn constant_let_expression(s: &str) -> IResult<&str, LetExpression> {
@ -591,10 +618,16 @@ pub fn constant_let_expression(s: &str) -> IResult<&str, LetExpression> {
} }
pub fn cast(s: &str) -> IResult<&str, Cast> { pub fn cast(s: &str) -> IResult<&str, Cast> {
let (s, r#type) = casting_type(s)?; let (s, x) = casting_type(s)?;
let (s, _) = symbol("'")(s)?; let (s, _) = symbol("'")(s)?;
let (s, expression) = delimited(symbol("("), expression, symbol(")"))(s)?; let (s, y) = delimited(symbol("("), expression, symbol(")"))(s)?;
Ok((s, Cast { r#type, expression })) Ok((
s,
Cast {
r#type: x,
expression: y,
},
))
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -96,15 +96,15 @@ pub fn constant_function_call(s: &str) -> IResult<&str, SubroutineCall> {
} }
pub fn tf_call(s: &str) -> IResult<&str, TfCall> { pub fn tf_call(s: &str) -> IResult<&str, TfCall> {
let (s, identifier) = ps_or_hierarchical_tf_identifier(s)?; let (s, x) = ps_or_hierarchical_tf_identifier(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, argument) = opt(delimited(symbol("("), list_of_arguments, symbol(")")))(s)?; let (s, z) = opt(delimited(symbol("("), list_of_arguments, symbol(")")))(s)?;
Ok(( Ok((
s, s,
TfCall { TfCall {
identifier, identifier: x,
attribute, attribute: y,
argument, argument: z,
}, },
)) ))
} }
@ -118,13 +118,13 @@ pub fn system_tf_call(s: &str) -> IResult<&str, SystemTfCall> {
} }
pub fn system_tf_call_list_of_arguments(s: &str) -> IResult<&str, SystemTfCall> { pub fn system_tf_call_list_of_arguments(s: &str) -> IResult<&str, SystemTfCall> {
let (s, identifier) = system_tf_identifier(s)?; let (s, x) = system_tf_identifier(s)?;
let (s, argument) = opt(delimited(symbol("("), list_of_arguments, symbol(")")))(s)?; let (s, y) = opt(delimited(symbol("("), list_of_arguments, symbol(")")))(s)?;
Ok(( Ok((
s, s,
SystemTfCall { SystemTfCall {
identifier, identifier: x,
argument, argument: y,
data_type: None, data_type: None,
expression: None, expression: None,
clocking_event: None, clocking_event: None,
@ -133,45 +133,38 @@ pub fn system_tf_call_list_of_arguments(s: &str) -> IResult<&str, SystemTfCall>
} }
pub fn system_tf_call_data_type(s: &str) -> IResult<&str, SystemTfCall> { pub fn system_tf_call_data_type(s: &str) -> IResult<&str, SystemTfCall> {
let (s, identifier) = system_tf_identifier(s)?; let (s, x) = system_tf_identifier(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, data_type) = data_type(s)?; let (s, y) = data_type(s)?;
let (s, expression) = preceded(symbol(","), expression)(s)?; let (s, z) = preceded(symbol(","), expression)(s)?;
let (s, _) = symbol(")")(s)?; let (s, _) = symbol(")")(s)?;
let data_type = Some(data_type);
let expression = Some(vec![expression]);
Ok(( Ok((
s, s,
SystemTfCall { SystemTfCall {
identifier, identifier: x,
argument: None, argument: None,
data_type, data_type: Some(y),
expression, expression: Some(vec![z]),
clocking_event: None, clocking_event: None,
}, },
)) ))
} }
pub fn system_tf_call_clocking_event(s: &str) -> IResult<&str, SystemTfCall> { pub fn system_tf_call_clocking_event(s: &str) -> IResult<&str, SystemTfCall> {
let (s, identifier) = system_tf_identifier(s)?; let (s, x) = system_tf_identifier(s)?;
let (s, _) = symbol("(")(s)?; let (s, _) = symbol("(")(s)?;
let (s, expression) = separated_nonempty_list(symbol(","), expression)(s)?; let (s, y) = separated_nonempty_list(symbol(","), expression)(s)?;
let (s, clocking_event) = opt(preceded(symbol(","), opt(clocking_event)))(s)?; let (s, z) = opt(preceded(symbol(","), opt(clocking_event)))(s)?;
let (s, _) = symbol(")")(s)?; let (s, _) = symbol(")")(s)?;
let expression = Some(expression); let z = if let Some(Some(z)) = z { Some(z) } else { None };
let clocking_event = if let Some(Some(x)) = clocking_event {
Some(x)
} else {
None
};
Ok(( Ok((
s, s,
SystemTfCall { SystemTfCall {
identifier, identifier: x,
argument: None, argument: None,
data_type: None, data_type: None,
expression, expression: Some(y),
clocking_event, clocking_event: z,
}, },
)) ))
} }
@ -194,23 +187,29 @@ pub fn function_subroutine_call(s: &str) -> IResult<&str, SubroutineCall> {
} }
pub fn list_of_arguments(s: &str) -> IResult<&str, ListOfArguments> { pub fn list_of_arguments(s: &str) -> IResult<&str, ListOfArguments> {
let (s, unnamed) = separated_list(symbol(","), expression)(s)?; let (s, x) = separated_list(symbol(","), expression)(s)?;
let (s, named) = separated_list( let (s, y) = separated_list(
symbol(","), symbol(","),
pair( pair(
preceded(symbol("."), identifier), preceded(symbol("."), identifier),
delimited(symbol("("), opt(expression), symbol(")")), delimited(symbol("("), opt(expression), symbol(")")),
), ),
)(s)?; )(s)?;
Ok((s, ListOfArguments { unnamed, named })) Ok((
s,
ListOfArguments {
unnamed: x,
named: y,
},
))
} }
pub fn method_call(s: &str) -> IResult<&str, MethodCall> { pub fn method_call(s: &str) -> IResult<&str, MethodCall> {
let (s, root) = method_call_root(s)?; let (s, x) = method_call_root(s)?;
let (s, _) = symbol(".")(s)?; let (s, _) = symbol(".")(s)?;
let (s, body) = method_call_body(s)?; let (s, y) = method_call_body(s)?;
Ok((s, MethodCall { root, body })) Ok((s, MethodCall { root: x, body: y }))
} }
pub fn method_call_body(s: &str) -> IResult<&str, MethodCallBody> { pub fn method_call_body(s: &str) -> IResult<&str, MethodCallBody> {
@ -218,15 +217,15 @@ pub fn method_call_body(s: &str) -> IResult<&str, MethodCallBody> {
} }
pub fn method_call_body_user(s: &str) -> IResult<&str, MethodCallBody> { pub fn method_call_body_user(s: &str) -> IResult<&str, MethodCallBody> {
let (s, identifier) = method_identifier(s)?; let (s, x) = method_identifier(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, argument) = opt(delimited(symbol("("), list_of_arguments, symbol(")")))(s)?; let (s, z) = opt(delimited(symbol("("), list_of_arguments, symbol(")")))(s)?;
Ok(( Ok((
s, s,
MethodCallBody::User(MethodCallBodyUser { MethodCallBody::User(MethodCallBodyUser {
identifier, identifier: x,
attribute, attribute: y,
argument, argument: z,
}), }),
)) ))
} }
@ -239,28 +238,28 @@ pub fn built_in_method_call(s: &str) -> IResult<&str, MethodCallBody> {
} }
pub fn array_manipulation_call(s: &str) -> IResult<&str, ArrayManipulationCall> { pub fn array_manipulation_call(s: &str) -> IResult<&str, ArrayManipulationCall> {
let (s, name) = array_method_name(s)?; let (s, x) = array_method_name(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, y) = many0(attribute_instance)(s)?;
let (s, argument) = opt(delimited(symbol("("), list_of_arguments, symbol(")")))(s)?; let (s, z) = opt(delimited(symbol("("), list_of_arguments, symbol(")")))(s)?;
let (s, with) = opt(preceded( let (s, w) = opt(preceded(
symbol("with"), symbol("with"),
delimited(symbol("("), expression, symbol(")")), delimited(symbol("("), expression, symbol(")")),
))(s)?; ))(s)?;
Ok(( Ok((
s, s,
ArrayManipulationCall { ArrayManipulationCall {
name, name: x,
attribute, attribute: y,
argument, argument: z,
with, with: w,
}, },
)) ))
} }
pub fn randomize_call(s: &str) -> IResult<&str, RandomizeCall> { pub fn randomize_call(s: &str) -> IResult<&str, RandomizeCall> {
let (s, _) = symbol("randomize")(s)?; let (s, _) = symbol("randomize")(s)?;
let (s, attribute) = many0(attribute_instance)(s)?; let (s, x) = many0(attribute_instance)(s)?;
let (s, argument) = opt(delimited( let (s, y) = opt(delimited(
symbol("("), symbol("("),
opt(alt(( opt(alt((
variable_identifier_list, variable_identifier_list,
@ -268,28 +267,24 @@ pub fn randomize_call(s: &str) -> IResult<&str, RandomizeCall> {
))), ))),
symbol(")"), symbol(")"),
))(s)?; ))(s)?;
let (s, with) = opt(tuple(( let (s, z) = opt(tuple((
symbol("with"), symbol("with"),
opt(delimited(symbol("("), opt(identifier_list), symbol(")"))), opt(delimited(symbol("("), opt(identifier_list), symbol(")"))),
constraint_block, constraint_block,
)))(s)?; )))(s)?;
let argument = if let Some(Some(x)) = argument { let y = if let Some(Some(y)) = y { y } else { vec![] };
x let (z, w) = if let Some((_, Some(Some(z)), w)) = z {
} else { (z, Some(w))
vec![]
};
let (with, constraint_block) = if let Some((_, Some(Some(x)), y)) = with {
(x, Some(y))
} else { } else {
(vec![], None) (vec![], None)
}; };
Ok(( Ok((
s, s,
RandomizeCall { RandomizeCall {
attribute, attribute: x,
argument, argument: y,
with, with: z,
constraint_block, constraint_block: w,
}, },
)) ))
} }

View File

@ -21,15 +21,21 @@ pub struct AttrSpec<'a> {
pub fn attribute_instance(s: &str) -> IResult<&str, AttributeInstance> { pub fn attribute_instance(s: &str) -> IResult<&str, AttributeInstance> {
let (s, _) = symbol("(*")(s)?; let (s, _) = symbol("(*")(s)?;
let (s, attr_spec) = separated_nonempty_list(symbol(","), attr_spec)(s)?; let (s, x) = separated_nonempty_list(symbol(","), attr_spec)(s)?;
let (s, _) = symbol("*)")(s)?; let (s, _) = symbol("*)")(s)?;
Ok((s, AttributeInstance { attr_spec })) Ok((s, AttributeInstance { attr_spec: x }))
} }
pub fn attr_spec(s: &str) -> IResult<&str, AttrSpec> { pub fn attr_spec(s: &str) -> IResult<&str, AttrSpec> {
let (s, attr_name) = identifier(s)?; let (s, x) = identifier(s)?;
let (s, rvalue) = opt(preceded(symbol("="), constant_expression))(s)?; let (s, y) = opt(preceded(symbol("="), constant_expression))(s)?;
Ok((s, AttrSpec { attr_name, rvalue })) Ok((
s,
AttrSpec {
attr_name: x,
rvalue: y,
},
))
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -192,28 +192,26 @@ pub fn hierarchical_event_identifier(s: &str) -> IResult<&str, HierarchicalIdent
} }
pub fn hierarchy(s: &str) -> IResult<&str, Hierarchy> { pub fn hierarchy(s: &str) -> IResult<&str, Hierarchy> {
let (s, identifier) = identifier(s)?; let (s, x) = identifier(s)?;
let (s, constant_bit_select) = constant_bit_select(s)?; let (s, y) = constant_bit_select(s)?;
let (s, _) = symbol(".")(s)?; let (s, _) = symbol(".")(s)?;
let constant_bit_select = Some(constant_bit_select);
Ok(( Ok((
s, s,
Hierarchy { Hierarchy {
identifier, identifier: x,
constant_bit_select, constant_bit_select: Some(y),
}, },
)) ))
} }
pub fn hierarchical_identifier(s: &str) -> IResult<&str, HierarchicalIdentifier> { pub fn hierarchical_identifier(s: &str) -> IResult<&str, HierarchicalIdentifier> {
let (s, x) = opt(terminated(symbol("$root"), symbol(".")))(s)?; let (s, x) = opt(terminated(symbol("$root"), symbol(".")))(s)?;
let (s, mut hierarchy) = many0(hierarchy)(s)?; let (s, mut y) = many0(hierarchy)(s)?;
let (s, identifier) = identifier(s)?; let (s, z) = identifier(s)?;
if let Some(x) = x { if let Some(x) = x {
hierarchy.insert( y.insert(
0, 0,
Hierarchy { Hierarchy {
identifier: Identifier { raw: x }, identifier: Identifier { raw: x },
@ -225,8 +223,8 @@ pub fn hierarchical_identifier(s: &str) -> IResult<&str, HierarchicalIdentifier>
Ok(( Ok((
s, s,
HierarchicalIdentifier { HierarchicalIdentifier {
hierarchy, hierarchy: y,
identifier, identifier: z,
}, },
)) ))
} }
@ -351,81 +349,136 @@ pub fn property_identifier(s: &str) -> IResult<&str, Identifier> {
} }
pub fn ps_class_identifier(s: &str) -> IResult<&str, ScopedIdentifier> { pub fn ps_class_identifier(s: &str) -> IResult<&str, ScopedIdentifier> {
let (s, scope) = opt(package_scope)(s)?; let (s, x) = opt(package_scope)(s)?;
let (s, identifier) = class_identifier(s)?; let (s, y) = class_identifier(s)?;
let identifier = identifier.into(); Ok((
Ok((s, ScopedIdentifier { scope, identifier })) s,
ScopedIdentifier {
scope: x,
identifier: y.into(),
},
))
} }
pub fn ps_covergroup_identifier(s: &str) -> IResult<&str, ScopedIdentifier> { pub fn ps_covergroup_identifier(s: &str) -> IResult<&str, ScopedIdentifier> {
let (s, scope) = opt(package_scope)(s)?; let (s, x) = opt(package_scope)(s)?;
let (s, identifier) = covergroup_identifier(s)?; let (s, y) = covergroup_identifier(s)?;
let identifier = identifier.into(); Ok((
Ok((s, ScopedIdentifier { scope, identifier })) s,
ScopedIdentifier {
scope: x,
identifier: y.into(),
},
))
} }
pub fn ps_checker_identifier(s: &str) -> IResult<&str, ScopedIdentifier> { pub fn ps_checker_identifier(s: &str) -> IResult<&str, ScopedIdentifier> {
let (s, scope) = opt(package_scope)(s)?; let (s, x) = opt(package_scope)(s)?;
let (s, identifier) = checker_identifier(s)?; let (s, y) = checker_identifier(s)?;
let identifier = identifier.into(); Ok((
Ok((s, ScopedIdentifier { scope, identifier })) s,
ScopedIdentifier {
scope: x,
identifier: y.into(),
},
))
} }
pub fn ps_identifier(s: &str) -> IResult<&str, ScopedIdentifier> { pub fn ps_identifier(s: &str) -> IResult<&str, ScopedIdentifier> {
let (s, scope) = opt(package_scope)(s)?; let (s, x) = opt(package_scope)(s)?;
let (s, identifier) = identifier(s)?; let (s, y) = identifier(s)?;
let identifier = identifier.into(); Ok((
Ok((s, ScopedIdentifier { scope, identifier })) s,
ScopedIdentifier {
scope: x,
identifier: y.into(),
},
))
} }
pub fn ps_or_hierarchical_array_identifier(s: &str) -> IResult<&str, ScopedIdentifier> { pub fn ps_or_hierarchical_array_identifier(s: &str) -> IResult<&str, ScopedIdentifier> {
let (s, scope) = opt(alt(( let (s, x) = opt(alt((
terminated(implicit_class_handle, symbol(".")), terminated(implicit_class_handle, symbol(".")),
class_scope, class_scope,
package_scope, package_scope,
)))(s)?; )))(s)?;
let (s, identifier) = hierarchical_array_identifier(s)?; let (s, y) = hierarchical_array_identifier(s)?;
Ok((s, ScopedIdentifier { scope, identifier })) Ok((
s,
ScopedIdentifier {
scope: x,
identifier: y,
},
))
} }
pub fn ps_or_hierarchical_net_identifier(s: &str) -> IResult<&str, ScopedIdentifier> { pub fn ps_or_hierarchical_net_identifier(s: &str) -> IResult<&str, ScopedIdentifier> {
let (s, scope) = opt(package_scope)(s)?; let (s, x) = opt(package_scope)(s)?;
let (s, identifier) = alt(( let (s, y) = alt((
map(net_identifier, |x| x.into()), map(net_identifier, |x| x.into()),
hierarchical_net_identifier, hierarchical_net_identifier,
))(s)?; ))(s)?;
Ok((s, ScopedIdentifier { scope, identifier })) Ok((
s,
ScopedIdentifier {
scope: x,
identifier: y,
},
))
} }
pub fn ps_or_hierarchical_property_identifier(s: &str) -> IResult<&str, ScopedIdentifier> { pub fn ps_or_hierarchical_property_identifier(s: &str) -> IResult<&str, ScopedIdentifier> {
let (s, scope) = opt(package_scope)(s)?; let (s, x) = opt(package_scope)(s)?;
let (s, identifier) = alt(( let (s, y) = alt((
map(property_identifier, |x| x.into()), map(property_identifier, |x| x.into()),
hierarchical_property_identifier, hierarchical_property_identifier,
))(s)?; ))(s)?;
Ok((s, ScopedIdentifier { scope, identifier })) Ok((
s,
ScopedIdentifier {
scope: x,
identifier: y,
},
))
} }
pub fn ps_or_hierarchical_sequence_identifier(s: &str) -> IResult<&str, ScopedIdentifier> { pub fn ps_or_hierarchical_sequence_identifier(s: &str) -> IResult<&str, ScopedIdentifier> {
let (s, scope) = opt(package_scope)(s)?; let (s, x) = opt(package_scope)(s)?;
let (s, identifier) = alt(( let (s, y) = alt((
map(sequence_identifier, |x| x.into()), map(sequence_identifier, |x| x.into()),
hierarchical_sequence_identifier, hierarchical_sequence_identifier,
))(s)?; ))(s)?;
Ok((s, ScopedIdentifier { scope, identifier })) Ok((
s,
ScopedIdentifier {
scope: x,
identifier: y,
},
))
} }
pub fn ps_or_hierarchical_tf_identifier(s: &str) -> IResult<&str, ScopedIdentifier> { pub fn ps_or_hierarchical_tf_identifier(s: &str) -> IResult<&str, ScopedIdentifier> {
let (s, scope) = opt(package_scope)(s)?; let (s, x) = opt(package_scope)(s)?;
let (s, identifier) = alt((map(tf_identifier, |x| x.into()), hierarchical_tf_identifier))(s)?; let (s, y) = alt((map(tf_identifier, |x| x.into()), hierarchical_tf_identifier))(s)?;
Ok((s, ScopedIdentifier { scope, identifier })) Ok((
s,
ScopedIdentifier {
scope: x,
identifier: y,
},
))
} }
pub fn ps_parameter_identifier(s: &str) -> IResult<&str, ScopedIdentifier> { pub fn ps_parameter_identifier(s: &str) -> IResult<&str, ScopedIdentifier> {
let (s, scope) = opt(alt((package_scope, class_scope, generate_block_scope)))(s)?; let (s, x) = opt(alt((package_scope, class_scope, generate_block_scope)))(s)?;
let (s, identifier) = parameter_identifier(s)?; let (s, y) = parameter_identifier(s)?;
let identifier = identifier.into(); Ok((
Ok((s, ScopedIdentifier { scope, identifier })) s,
ScopedIdentifier {
scope: x,
identifier: y.into(),
},
))
} }
pub fn generate_block_scope(s: &str) -> IResult<&str, Scope> { pub fn generate_block_scope(s: &str) -> IResult<&str, Scope> {
@ -436,10 +489,10 @@ pub fn generate_block_scope(s: &str) -> IResult<&str, Scope> {
)))(s)?; )))(s)?;
let mut ret = Vec::new(); let mut ret = Vec::new();
for (identifier, constant_expression, _) in x { for (x, y, _) in x {
ret.push(GenerateBlockScope { ret.push(GenerateBlockScope {
identifier, identifier: x,
constant_expression, constant_expression: y,
}); });
} }
@ -447,16 +500,21 @@ pub fn generate_block_scope(s: &str) -> IResult<&str, Scope> {
} }
pub fn ps_type_identifier(s: &str) -> IResult<&str, ScopedIdentifier> { pub fn ps_type_identifier(s: &str) -> IResult<&str, ScopedIdentifier> {
let (s, scope) = opt(alt(( let (s, x) = opt(alt((
map(terminated(symbol("local"), symbol("::")), |_| { map(terminated(symbol("local"), symbol("::")), |_| {
Scope::LocalScope Scope::LocalScope
}), }),
package_scope, package_scope,
class_scope, class_scope,
)))(s)?; )))(s)?;
let (s, identifier) = type_identifier(s)?; let (s, y) = type_identifier(s)?;
let identifier = identifier.into(); Ok((
Ok((s, ScopedIdentifier { scope, identifier })) s,
ScopedIdentifier {
scope: x,
identifier: y.into(),
},
))
} }
pub fn sequence_identifier(s: &str) -> IResult<&str, Identifier> { pub fn sequence_identifier(s: &str) -> IResult<&str, Identifier> {

View File

@ -33,56 +33,21 @@ pub struct LetExpression<'a> {
pub raw: Vec<&'a str>, pub raw: Vec<&'a str>,
} }
#[derive(Debug)]
pub struct ConstantAssignmentPatternExpression<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)] #[derive(Debug)]
pub struct TypeReference<'a> { pub struct TypeReference<'a> {
pub raw: Vec<&'a str>, pub raw: Vec<&'a str>,
} }
#[derive(Debug)]
pub struct AssignmentPatternExpression<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)] #[derive(Debug)]
pub struct SequenceMethodCall<'a> { pub struct SequenceMethodCall<'a> {
pub raw: Vec<&'a str>, pub raw: Vec<&'a str>,
} }
#[derive(Debug)]
pub struct AssignmentPatternExpressionType<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct AssignmentPatternNetLvalue<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct AssignmentPatternVariableLvalue<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct CondPredicate<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)] #[derive(Debug)]
pub struct DataType<'a> { pub struct DataType<'a> {
pub raw: Vec<&'a str>, pub raw: Vec<&'a str>,
} }
#[derive(Debug)]
pub struct OpenRangeList<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)] #[derive(Debug)]
pub struct ClockingEvent<'a> { pub struct ClockingEvent<'a> {
pub raw: Vec<&'a str>, pub raw: Vec<&'a str>,
@ -108,31 +73,6 @@ pub struct Delay3<'a> {
pub raw: Vec<&'a str>, pub raw: Vec<&'a str>,
} }
#[derive(Debug)]
pub struct DelayControl<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct StatementOrNull<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct Statement<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct FunctionStatement<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct DelayOrEventControl<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)] #[derive(Debug)]
pub struct DynamicArrayNew<'a> { pub struct DynamicArrayNew<'a> {
pub raw: Vec<&'a str>, pub raw: Vec<&'a str>,
@ -148,6 +88,61 @@ pub struct BlockItemDeclaration<'a> {
pub raw: Vec<&'a str>, pub raw: Vec<&'a str>,
} }
#[derive(Debug)]
pub struct SubroutineCallStatement<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct LoopStatement<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct ProceduralAssertionStatement<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct ClockingDrive<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct RandsequenceStatement<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct ExpectPropertyStatement<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct SequenceInstance<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct DelayValue<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct CycleDelay<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct EdgeIdentifier<'a> {
pub raw: Vec<&'a str>,
}
#[derive(Debug)]
pub struct IntegerAtomType<'a> {
pub raw: Vec<&'a str>,
}
pub fn class_scope(s: &str) -> IResult<&str, Scope> { pub fn class_scope(s: &str) -> IResult<&str, Scope> {
Ok((s, Scope::ClassScope)) Ok((s, Scope::ClassScope))
} }
@ -160,52 +155,18 @@ pub fn let_expression(s: &str) -> IResult<&str, LetExpression> {
Ok((s, LetExpression { raw: vec![] })) Ok((s, LetExpression { raw: vec![] }))
} }
pub fn constant_assignment_pattern_expression(
s: &str,
) -> IResult<&str, ConstantAssignmentPatternExpression> {
Ok((s, ConstantAssignmentPatternExpression { raw: vec![] }))
}
pub fn type_reference(s: &str) -> IResult<&str, TypeReference> { pub fn type_reference(s: &str) -> IResult<&str, TypeReference> {
Ok((s, TypeReference { raw: vec![] })) Ok((s, TypeReference { raw: vec![] }))
} }
pub fn assignment_pattern_expression(s: &str) -> IResult<&str, AssignmentPatternExpression> {
Ok((s, AssignmentPatternExpression { raw: vec![] }))
}
pub fn sequence_method_call(s: &str) -> IResult<&str, SequenceMethodCall> { pub fn sequence_method_call(s: &str) -> IResult<&str, SequenceMethodCall> {
Ok((s, SequenceMethodCall { raw: vec![] })) Ok((s, SequenceMethodCall { raw: vec![] }))
} }
pub fn assignment_pattern_expression_type(
s: &str,
) -> IResult<&str, AssignmentPatternExpressionType> {
Ok((s, AssignmentPatternExpressionType { raw: vec![] }))
}
pub fn assignment_pattern_net_lvalue(s: &str) -> IResult<&str, AssignmentPatternNetLvalue> {
Ok((s, AssignmentPatternNetLvalue { raw: vec![] }))
}
pub fn assignment_pattern_variable_lvalue(
s: &str,
) -> IResult<&str, AssignmentPatternVariableLvalue> {
Ok((s, AssignmentPatternVariableLvalue { raw: vec![] }))
}
pub fn cond_predicate(s: &str) -> IResult<&str, CondPredicate> {
Ok((s, CondPredicate { raw: vec![] }))
}
pub fn data_type(s: &str) -> IResult<&str, DataType> { pub fn data_type(s: &str) -> IResult<&str, DataType> {
Ok((s, DataType { raw: vec![] })) Ok((s, DataType { raw: vec![] }))
} }
pub fn open_range_list(s: &str) -> IResult<&str, OpenRangeList> {
Ok((s, OpenRangeList { raw: vec![] }))
}
pub fn clocking_event(s: &str) -> IResult<&str, ClockingEvent> { pub fn clocking_event(s: &str) -> IResult<&str, ClockingEvent> {
Ok((s, ClockingEvent { raw: vec![] })) Ok((s, ClockingEvent { raw: vec![] }))
} }
@ -214,10 +175,6 @@ pub fn constraint_block(s: &str) -> IResult<&str, ConstraintBlock> {
Ok((s, ConstraintBlock { raw: vec![] })) Ok((s, ConstraintBlock { raw: vec![] }))
} }
pub fn variable_identifier_list(s: &str) -> IResult<&str, Vec<Identifier>> {
Ok((s, vec![]))
}
pub fn identifier_list(s: &str) -> IResult<&str, Vec<Identifier>> { pub fn identifier_list(s: &str) -> IResult<&str, Vec<Identifier>> {
Ok((s, vec![])) Ok((s, vec![]))
} }
@ -234,26 +191,6 @@ pub fn delay3(s: &str) -> IResult<&str, Delay3> {
Ok((s, Delay3 { raw: vec![] })) Ok((s, Delay3 { raw: vec![] }))
} }
pub fn delay_control(s: &str) -> IResult<&str, DelayControl> {
Ok((s, DelayControl { raw: vec![] }))
}
pub fn statement_or_null(s: &str) -> IResult<&str, StatementOrNull> {
Ok((s, StatementOrNull { raw: vec![] }))
}
pub fn statement(s: &str) -> IResult<&str, Statement> {
Ok((s, Statement { raw: vec![] }))
}
pub fn function_statement(s: &str) -> IResult<&str, FunctionStatement> {
Ok((s, FunctionStatement { raw: vec![] }))
}
pub fn delay_or_event_control(s: &str) -> IResult<&str, DelayOrEventControl> {
Ok((s, DelayOrEventControl { raw: vec![] }))
}
pub fn dynamic_array_new(s: &str) -> IResult<&str, DynamicArrayNew> { pub fn dynamic_array_new(s: &str) -> IResult<&str, DynamicArrayNew> {
Ok((s, DynamicArrayNew { raw: vec![] })) Ok((s, DynamicArrayNew { raw: vec![] }))
} }
@ -265,3 +202,47 @@ pub fn class_new(s: &str) -> IResult<&str, ClassNew> {
pub fn block_item_declaration(s: &str) -> IResult<&str, BlockItemDeclaration> { pub fn block_item_declaration(s: &str) -> IResult<&str, BlockItemDeclaration> {
Ok((s, BlockItemDeclaration { raw: vec![] })) Ok((s, BlockItemDeclaration { raw: vec![] }))
} }
pub fn subroutine_call_statement(s: &str) -> IResult<&str, SubroutineCallStatement> {
Ok((s, SubroutineCallStatement { raw: vec![] }))
}
pub fn loop_statement(s: &str) -> IResult<&str, LoopStatement> {
Ok((s, LoopStatement { raw: vec![] }))
}
pub fn procedural_assertion_statement(s: &str) -> IResult<&str, ProceduralAssertionStatement> {
Ok((s, ProceduralAssertionStatement { raw: vec![] }))
}
pub fn clocking_drive(s: &str) -> IResult<&str, ClockingDrive> {
Ok((s, ClockingDrive { raw: vec![] }))
}
pub fn randsequence_statement(s: &str) -> IResult<&str, RandsequenceStatement> {
Ok((s, RandsequenceStatement { raw: vec![] }))
}
pub fn expect_property_statement(s: &str) -> IResult<&str, ExpectPropertyStatement> {
Ok((s, ExpectPropertyStatement { raw: vec![] }))
}
pub fn sequence_instance(s: &str) -> IResult<&str, SequenceInstance> {
Ok((s, SequenceInstance { raw: vec![] }))
}
pub fn delay_value(s: &str) -> IResult<&str, DelayValue> {
Ok((s, DelayValue { raw: vec![] }))
}
pub fn cycle_delay(s: &str) -> IResult<&str, CycleDelay> {
Ok((s, CycleDelay { raw: vec![] }))
}
pub fn edge_identifier(s: &str) -> IResult<&str, EdgeIdentifier> {
Ok((s, EdgeIdentifier { raw: vec![] }))
}
pub fn integer_atom_type(s: &str) -> IResult<&str, IntegerAtomType> {
Ok((s, IntegerAtomType { raw: vec![] }))
}