Refactoring
This commit is contained in:
parent
2c3b3d8442
commit
9c4aceb631
76
README.md
76
README.md
@ -1,2 +1,78 @@
|
|||||||
# sv-parser
|
# sv-parser
|
||||||
A parser library for System Verilog.
|
A parser library for System Verilog.
|
||||||
|
|
||||||
|
## Implementation Status
|
||||||
|
|
||||||
|
| Category | Module | Type | Parser | Test |
|
||||||
|
| --------------------------------- | ------------------------------------- | ---- | ------ | ---- |
|
||||||
|
| source_text | library_source_text | x | x | x |
|
||||||
|
| source_text | system_verilog_source_text | x | x | |
|
||||||
|
| source_text | module_parameters_and_ports | | | |
|
||||||
|
| source_text | module_items | | | |
|
||||||
|
| source_text | configuration_source_text | | | |
|
||||||
|
| source_text | interface_items | | | |
|
||||||
|
| source_text | program_items | | | |
|
||||||
|
| source_text | checker_items | | | |
|
||||||
|
| source_text | class_items | | | |
|
||||||
|
| source_text | constraints | | | |
|
||||||
|
| source_text | package_items | | | |
|
||||||
|
| declaration | module_parameter_declarations | | | |
|
||||||
|
| declaration | port_declarations | | | |
|
||||||
|
| declaration | type_declarations | | | |
|
||||||
|
| declaration | net_and_variable_types | | | |
|
||||||
|
| declaration | strengths | | | |
|
||||||
|
| declaration | delays | | | |
|
||||||
|
| declaration | declaration_lists | | | |
|
||||||
|
| declaration | declaration_assignments | | | |
|
||||||
|
| declaration | declaration_ranges | | | |
|
||||||
|
| declaration | function_declarations | | | |
|
||||||
|
| declaration | task_declarations | | | |
|
||||||
|
| declaration | block_item_declarations | | | |
|
||||||
|
| declaration | interface_declarations | | | |
|
||||||
|
| declaration | assertion_declarations | | | |
|
||||||
|
| declaration | covergroup_declarations | | | |
|
||||||
|
| declaration | let_declarations | | | |
|
||||||
|
| primitive_instance | primitive_instantiation_and_instances | | | |
|
||||||
|
| primitive_instance | primitive_strengths | | | |
|
||||||
|
| primitive_instance | primitive_terminals | | | |
|
||||||
|
| primitive_instance | primitive_gate_and_switch_types | | | |
|
||||||
|
| instantiations | module_instantiation | | | |
|
||||||
|
| instantiations | interface_instantiation | x | x | |
|
||||||
|
| instantiations | program_instantiation | x | x | |
|
||||||
|
| instantiations | checker_instantiation | x | x | |
|
||||||
|
| instantiations | generated_instantiation | | | |
|
||||||
|
| udp_declaration_and_instantiation | udp_declaration | | | |
|
||||||
|
| udp_declaration_and_instantiation | udp_ports | | | |
|
||||||
|
| udp_declaration_and_instantiation | udp_body | | | |
|
||||||
|
| udp_declaration_and_instantiation | udp_instantiation | | | |
|
||||||
|
| behavioral_statements | continuous_assignment_and_net_alias | | | |
|
||||||
|
| behavioral_statements | procedural_blocks_and_assignments | | | |
|
||||||
|
| behavioral_statements | parallel_and_sequential_blocks | | | |
|
||||||
|
| behavioral_statements | statements | | | |
|
||||||
|
| behavioral_statements | timing_control_statements | | | |
|
||||||
|
| behavioral_statements | conditional_statements | | | |
|
||||||
|
| behavioral_statements | case_statements | | | |
|
||||||
|
| behavioral_statements | patterns | | | |
|
||||||
|
| behavioral_statements | looping_statements | | | |
|
||||||
|
| behavioral_statements | subroutine_call_statements | | | |
|
||||||
|
| behavioral_statements | assertion_statements | | | |
|
||||||
|
| behavioral_statements | clocking_block | | | |
|
||||||
|
| behavioral_statements | randsequence | | | |
|
||||||
|
| specify_section | specify_block_declaration | | | |
|
||||||
|
| specify_section | specify_path_declarations | | | |
|
||||||
|
| specify_section | specify_block_terminals | | | |
|
||||||
|
| specify_section | specify_path_delays | | | |
|
||||||
|
| specify_section | system_timing_check_commands | | | |
|
||||||
|
| specify_section | system_timing_check_command_arguments | | | |
|
||||||
|
| specify_section | system_timing_check_event_definitions | | | |
|
||||||
|
| expressions | concatenations | | | |
|
||||||
|
| expressions | subroutine_calls | | | |
|
||||||
|
| expressions | expressions | x | x | |
|
||||||
|
| expressions | primaries | x | x | |
|
||||||
|
| expressions | expression_leftside_values | x | x | |
|
||||||
|
| expressions | operators | x | x | x |
|
||||||
|
| expressions | numbers | x | x | x |
|
||||||
|
| expressions | strings | x | x | x |
|
||||||
|
| general | attributes | x | x | x |
|
||||||
|
| general | comments | x | x | x |
|
||||||
|
| general | identifiers | x | x | x |
|
||||||
|
@ -76,9 +76,9 @@ pub struct Var {}
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ForStepAssignment<'a> {
|
pub enum ForStepAssignment<'a> {
|
||||||
Operator(OperatorAssignment<'a>),
|
OperatorAssignment(OperatorAssignment<'a>),
|
||||||
IncOrDec(IncOrDecExpression<'a>),
|
IncOrDecExpression(IncOrDecExpression<'a>),
|
||||||
Subroutine(SubroutineCall<'a>),
|
FunctionSubroutineCall(FunctionSubroutineCall<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -212,10 +212,14 @@ pub fn for_step(s: Span) -> IResult<Span, Vec<ForStepAssignment>> {
|
|||||||
|
|
||||||
pub fn for_step_assignment(s: Span) -> IResult<Span, ForStepAssignment> {
|
pub fn for_step_assignment(s: Span) -> IResult<Span, ForStepAssignment> {
|
||||||
alt((
|
alt((
|
||||||
map(operator_assignment, |x| ForStepAssignment::Operator(x)),
|
map(operator_assignment, |x| {
|
||||||
map(inc_or_dec_expression, |x| ForStepAssignment::IncOrDec(x)),
|
ForStepAssignment::OperatorAssignment(x)
|
||||||
|
}),
|
||||||
|
map(inc_or_dec_expression, |x| {
|
||||||
|
ForStepAssignment::IncOrDecExpression(x)
|
||||||
|
}),
|
||||||
map(function_subroutine_call, |x| {
|
map(function_subroutine_call, |x| {
|
||||||
ForStepAssignment::Subroutine(x)
|
ForStepAssignment::FunctionSubroutineCall(x)
|
||||||
}),
|
}),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,11 @@ pub enum AssignmentPatternExpressionType<'a> {
|
|||||||
TypeReference(TypeReference<'a>),
|
TypeReference(TypeReference<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ConstantAssignmentPatternExpression<'a> {
|
||||||
|
pub nodes: (AssignmentPatternExpression<'a>,),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AssignmentPatternNetLvalue<'a> {
|
pub struct AssignmentPatternNetLvalue<'a> {
|
||||||
pub nodes: (Vec<NetLvalue<'a>>,),
|
pub nodes: (Vec<NetLvalue<'a>>,),
|
||||||
@ -178,8 +183,9 @@ pub fn assignment_pattern_expression_type(
|
|||||||
|
|
||||||
pub fn constant_assignment_pattern_expression(
|
pub fn constant_assignment_pattern_expression(
|
||||||
s: Span,
|
s: Span,
|
||||||
) -> IResult<Span, AssignmentPatternExpression> {
|
) -> IResult<Span, ConstantAssignmentPatternExpression> {
|
||||||
assignment_pattern_expression(s)
|
let (s, a) = assignment_pattern_expression(s)?;
|
||||||
|
Ok((s, ConstantAssignmentPatternExpression { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn assignment_pattern_net_lvalue(s: Span) -> IResult<Span, AssignmentPatternNetLvalue> {
|
pub fn assignment_pattern_net_lvalue(s: Span) -> IResult<Span, AssignmentPatternNetLvalue> {
|
||||||
|
@ -9,7 +9,7 @@ use nom::IResult;
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum SubroutineCallStatement<'a> {
|
pub enum SubroutineCallStatement<'a> {
|
||||||
SubroutineCall(SubroutineCall<'a>),
|
SubroutineCall(SubroutineCall<'a>),
|
||||||
FunctionSubroutineCall(SubroutineCall<'a>),
|
FunctionSubroutineCall(FunctionSubroutineCall<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -21,7 +21,7 @@ pub fn subroutine_call_statement(s: Span) -> IResult<Span, SubroutineCallStateme
|
|||||||
}),
|
}),
|
||||||
map(
|
map(
|
||||||
delimited(
|
delimited(
|
||||||
tuple((symbol("void"), symbol("'"), symbol("("))),
|
triple(symbol("void"), symbol("'"), symbol("(")),
|
||||||
function_subroutine_call,
|
function_subroutine_call,
|
||||||
pair(symbol(")"), symbol(";")),
|
pair(symbol(")"), symbol(";")),
|
||||||
),
|
),
|
||||||
|
@ -14,7 +14,7 @@ pub enum FunctionDataTypeOrImplicit<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FunctionDeclaration<'a> {
|
pub struct FunctionDeclaration<'a> {
|
||||||
pub nodes: (Option<Lifetime>, FunctionBodyDeclaration<'a>),
|
pub nodes: (Option<Lifetime<'a>>, FunctionBodyDeclaration<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -287,6 +287,10 @@ pub fn class_scope(s: Span) -> IResult<Span, ClassScope> {
|
|||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn class_type(s: Span) -> IResult<Span, ClassType> {
|
||||||
|
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn integer_type(s: Span) -> IResult<Span, IntegerType> {
|
pub fn integer_type(s: Span) -> IResult<Span, IntegerType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use nom::{Err, IResult};
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TaskDeclaration<'a> {
|
pub struct TaskDeclaration<'a> {
|
||||||
pub nodes: (Option<Lifetime>, TaskBodyDeclaration<'a>),
|
pub nodes: (Option<Lifetime<'a>>, TaskBodyDeclaration<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -20,7 +20,7 @@ pub struct DataDeclarationVariable<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
Option<Const>,
|
Option<Const>,
|
||||||
Option<Var>,
|
Option<Var>,
|
||||||
Option<Lifetime>,
|
Option<Lifetime<'a>>,
|
||||||
DataTypeOrImplicit<'a>,
|
DataTypeOrImplicit<'a>,
|
||||||
ListOfVariableDeclAssignments<'a>,
|
ListOfVariableDeclAssignments<'a>,
|
||||||
),
|
),
|
||||||
@ -176,9 +176,9 @@ pub struct NetTypeDeclarationNetType<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Lifetime {
|
pub enum Lifetime<'a> {
|
||||||
Static,
|
Static(Symbol<'a>),
|
||||||
Automatic,
|
Automatic(Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -429,7 +429,7 @@ pub fn net_type_declaration_net_type(s: Span) -> IResult<Span, NetTypeDeclaratio
|
|||||||
|
|
||||||
pub fn lifetime(s: Span) -> IResult<Span, Lifetime> {
|
pub fn lifetime(s: Span) -> IResult<Span, Lifetime> {
|
||||||
alt((
|
alt((
|
||||||
map(symbol("static"), |_| Lifetime::Static),
|
map(symbol("static"), |x| Lifetime::Static(x)),
|
||||||
map(symbol("automatic"), |_| Lifetime::Automatic),
|
map(symbol("automatic"), |x| Lifetime::Automatic(x)),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,11 @@ pub struct ArrayRangeOperator<'a> {
|
|||||||
pub nodes: (Symbol<'a>,),
|
pub nodes: (Symbol<'a>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct EmptyUnpackedArrayConcatenation<'a> {
|
||||||
|
pub nodes: (Symbol<'a>, Symbol<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn concatenation(s: Span) -> IResult<Span, Concatenation> {
|
pub fn concatenation(s: Span) -> IResult<Span, Concatenation> {
|
||||||
@ -177,10 +182,12 @@ pub fn array_range_operator(s: Span) -> IResult<Span, ArrayRangeOperator> {
|
|||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn empty_unpacked_array_concatenation(s: Span) -> IResult<Span, ()> {
|
pub fn empty_unpacked_array_concatenation(
|
||||||
let (s, _) = symbol("{")(s)?;
|
s: Span,
|
||||||
let (s, _) = symbol("}")(s)?;
|
) -> IResult<Span, EmptyUnpackedArrayConcatenation> {
|
||||||
Ok((s, ()))
|
let (s, a) = symbol("{")(s)?;
|
||||||
|
let (s, b) = symbol("}")(s)?;
|
||||||
|
Ok((s, EmptyUnpackedArrayConcatenation { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -9,9 +9,9 @@ use nom::IResult;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum NetLvalue<'a> {
|
pub enum NetLvalue<'a> {
|
||||||
Identifier(Box<NetLvalueIdentifier<'a>>),
|
Identifier(NetLvalueIdentifier<'a>),
|
||||||
Lvalue(Box<Vec<NetLvalue<'a>>>),
|
Lvalue(Box<NetLvalueLvalue<'a>>),
|
||||||
Pattern(Box<NetLvaluePattern<'a>>),
|
Pattern(NetLvaluePattern<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -19,6 +19,16 @@ pub struct NetLvalueIdentifier<'a> {
|
|||||||
pub nodes: (PsOrHierarchicalNetIdentifier<'a>, ConstantSelect<'a>),
|
pub nodes: (PsOrHierarchicalNetIdentifier<'a>, ConstantSelect<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct NetLvalueLvalue<'a> {
|
||||||
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
NetLvalue<'a>,
|
||||||
|
Vec<(Symbol<'a>, NetLvalue<'a>)>,
|
||||||
|
Symbol<'a>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NetLvaluePattern<'a> {
|
pub struct NetLvaluePattern<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
@ -29,10 +39,10 @@ pub struct NetLvaluePattern<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum VariableLvalue<'a> {
|
pub enum VariableLvalue<'a> {
|
||||||
Identifier(Box<VariableLvalueIdentifier<'a>>),
|
Identifier(VariableLvalueIdentifier<'a>),
|
||||||
Lvalue(Box<Vec<VariableLvalue<'a>>>),
|
Lvalue(Box<VariableLvalueLvalue<'a>>),
|
||||||
Pattern(Box<VariableLvaluePattern<'a>>),
|
Pattern(VariableLvaluePattern<'a>),
|
||||||
Concatenation(Box<StreamingConcatenation<'a>>),
|
StreamingConcatenation(StreamingConcatenation<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -44,6 +54,16 @@ pub struct VariableLvalueIdentifier<'a> {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct VariableLvalueLvalue<'a> {
|
||||||
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
VariableLvalue<'a>,
|
||||||
|
Vec<(Symbol<'a>, VariableLvalue<'a>)>,
|
||||||
|
Symbol<'a>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct VariableLvaluePattern<'a> {
|
pub struct VariableLvaluePattern<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
@ -57,7 +77,7 @@ pub struct NonrangeVariableLvalue<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
Option<ImplicitClassHandleOrPackageScope<'a>>,
|
Option<ImplicitClassHandleOrPackageScope<'a>>,
|
||||||
HierarchicalVariableIdentifier<'a>,
|
HierarchicalVariableIdentifier<'a>,
|
||||||
Select<'a>,
|
NonrangeSelect<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,36 +88,31 @@ pub fn net_lvalue(s: Span) -> IResult<Span, NetLvalue> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn net_lvalue_identifier(s: Span) -> IResult<Span, NetLvalue> {
|
pub fn net_lvalue_identifier(s: Span) -> IResult<Span, NetLvalue> {
|
||||||
let (s, x) = ps_or_hierarchical_net_identifier(s)?;
|
let (s, a) = ps_or_hierarchical_net_identifier(s)?;
|
||||||
let (s, y) = constant_select(s)?;
|
let (s, b) = constant_select(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
NetLvalue::Identifier(Box::new(NetLvalueIdentifier { nodes: (x, y) })),
|
NetLvalue::Identifier(NetLvalueIdentifier { nodes: (a, b) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn net_lvalue_pattern(s: Span) -> IResult<Span, NetLvalue> {
|
pub fn net_lvalue_pattern(s: Span) -> IResult<Span, NetLvalue> {
|
||||||
let (s, x) = opt(assignment_pattern_expression_type)(s)?;
|
let (s, a) = opt(assignment_pattern_expression_type)(s)?;
|
||||||
let (s, y) = assignment_pattern_net_lvalue(s)?;
|
let (s, b) = assignment_pattern_net_lvalue(s)?;
|
||||||
Ok((
|
Ok((s, NetLvalue::Pattern(NetLvaluePattern { nodes: (a, b) })))
|
||||||
s,
|
|
||||||
NetLvalue::Pattern(Box::new(NetLvaluePattern { nodes: (x, y) })),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn net_lvalue_lvalue(s: Span) -> IResult<Span, NetLvalue> {
|
pub fn net_lvalue_lvalue(s: Span) -> IResult<Span, NetLvalue> {
|
||||||
let (s, _) = symbol("{")(s)?;
|
let (s, a) = symbol("{")(s)?;
|
||||||
let (s, x) = net_lvalue(s)?;
|
let (s, b) = net_lvalue(s)?;
|
||||||
let (s, y) = many0(preceded(symbol(","), net_lvalue))(s)?;
|
let (s, c) = many0(pair(symbol(","), net_lvalue))(s)?;
|
||||||
let (s, _) = symbol("}")(s)?;
|
let (s, d) = symbol("}")(s)?;
|
||||||
|
Ok((
|
||||||
let mut ret = Vec::new();
|
s,
|
||||||
ret.push(x);
|
NetLvalue::Lvalue(Box::new(NetLvalueLvalue {
|
||||||
for y in y {
|
nodes: (a, b, c, d),
|
||||||
ret.push(y);
|
})),
|
||||||
}
|
))
|
||||||
|
|
||||||
Ok((s, NetLvalue::Lvalue(Box::new(ret))))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn variable_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
|
pub fn variable_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
|
||||||
@ -106,99 +121,56 @@ pub fn variable_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
|
|||||||
variable_lvalue_lvalue,
|
variable_lvalue_lvalue,
|
||||||
variable_lvalue_pattern,
|
variable_lvalue_pattern,
|
||||||
map(streaming_concatenation, |x| {
|
map(streaming_concatenation, |x| {
|
||||||
VariableLvalue::Concatenation(Box::new(x))
|
VariableLvalue::StreamingConcatenation(x)
|
||||||
}),
|
}),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn variable_lvalue_identifier(s: Span) -> IResult<Span, VariableLvalue> {
|
pub fn variable_lvalue_identifier(s: Span) -> IResult<Span, VariableLvalue> {
|
||||||
let (s, x) = opt(implicit_class_handle_or_package_scope)(s)?;
|
let (s, a) = opt(implicit_class_handle_or_package_scope)(s)?;
|
||||||
let (s, y) = hierarchical_variable_identifier(s)?;
|
let (s, b) = hierarchical_variable_identifier(s)?;
|
||||||
let (s, z) = select(s)?;
|
let (s, c) = select(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
VariableLvalue::Identifier(Box::new(VariableLvalueIdentifier { nodes: (x, y, z) })),
|
VariableLvalue::Identifier(VariableLvalueIdentifier { nodes: (a, b, c) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn variable_lvalue_pattern(s: Span) -> IResult<Span, VariableLvalue> {
|
pub fn variable_lvalue_pattern(s: Span) -> IResult<Span, VariableLvalue> {
|
||||||
let (s, x) = opt(assignment_pattern_expression_type)(s)?;
|
let (s, a) = opt(assignment_pattern_expression_type)(s)?;
|
||||||
let (s, y) = assignment_pattern_variable_lvalue(s)?;
|
let (s, b) = assignment_pattern_variable_lvalue(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
VariableLvalue::Pattern(Box::new(VariableLvaluePattern { nodes: (x, y) })),
|
VariableLvalue::Pattern(VariableLvaluePattern { nodes: (a, b) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn variable_lvalue_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
|
pub fn variable_lvalue_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
|
||||||
let (s, _) = symbol("{")(s)?;
|
let (s, a) = symbol("{")(s)?;
|
||||||
let (s, x) = variable_lvalue(s)?;
|
let (s, b) = variable_lvalue(s)?;
|
||||||
let (s, y) = many0(preceded(symbol(","), variable_lvalue))(s)?;
|
let (s, c) = many0(pair(symbol(","), variable_lvalue))(s)?;
|
||||||
let (s, _) = symbol("}")(s)?;
|
let (s, d) = symbol("}")(s)?;
|
||||||
|
Ok((
|
||||||
let mut ret = Vec::new();
|
s,
|
||||||
ret.push(x);
|
VariableLvalue::Lvalue(Box::new(VariableLvalueLvalue {
|
||||||
for y in y {
|
nodes: (a, b, c, d),
|
||||||
ret.push(y);
|
})),
|
||||||
}
|
))
|
||||||
|
|
||||||
Ok((s, VariableLvalue::Lvalue(Box::new(ret))))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn nonrange_variable_lvalue(s: Span) -> IResult<Span, NonrangeVariableLvalue> {
|
pub fn nonrange_variable_lvalue(s: Span) -> IResult<Span, NonrangeVariableLvalue> {
|
||||||
let (s, x) = opt(implicit_class_handle_or_package_scope)(s)?;
|
let (s, a) = opt(implicit_class_handle_or_package_scope)(s)?;
|
||||||
let (s, y) = hierarchical_variable_identifier(s)?;
|
let (s, b) = hierarchical_variable_identifier(s)?;
|
||||||
let (s, z) = nonrange_select(s)?;
|
let (s, c) = nonrange_select(s)?;
|
||||||
Ok((s, NonrangeVariableLvalue { nodes: (x, y, z) }))
|
Ok((s, NonrangeVariableLvalue { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
//use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test() {
|
fn test() {}
|
||||||
//assert_eq!(
|
|
||||||
// format!("{:?}", all_consuming(net_lvalue)(Span::new("a"))),
|
|
||||||
// "Ok((\"\", Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } } }, select: ConstantSelect { member: None, bit_select: [], part_select_range: None } })))"
|
|
||||||
//);
|
|
||||||
//assert_eq!(
|
|
||||||
// format!("{:?}", all_consuming(net_lvalue)(Span::new("a[1][2]"))),
|
|
||||||
// "Ok((\"\", Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } } }, select: ConstantSelect { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"2\")))))], part_select_range: None } })))"
|
|
||||||
//);
|
|
||||||
//assert_eq!(
|
|
||||||
// format!("{:?}", all_consuming(net_lvalue)(Span::new("a[1][10:5]"))),
|
|
||||||
// "Ok((\"\", Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } } }, select: ConstantSelect { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))], part_select_range: Some(Range((Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"10\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"5\")))))))) } })))"
|
|
||||||
//);
|
|
||||||
//assert_eq!(
|
|
||||||
// format!("{:?}", all_consuming(net_lvalue)(Span::new("{a, b[1], c}"))),
|
|
||||||
// "Ok((\"\", Lvalue([Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } } }, select: ConstantSelect { member: None, bit_select: [], part_select_range: None } }), Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"b\" } } }, select: ConstantSelect { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))], part_select_range: None } }), Identifier(NetLvalueIdentifier { identifier: ScopedIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"c\" } } }, select: ConstantSelect { member: None, bit_select: [], part_select_range: None } })])))"
|
|
||||||
//);
|
|
||||||
//assert_eq!(
|
|
||||||
// format!("{:?}", all_consuming(variable_lvalue)(Span::new("a"))),
|
|
||||||
// "Ok((\"\", Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [], part_select_range: None } })))"
|
|
||||||
//);
|
|
||||||
//assert_eq!(
|
|
||||||
// format!("{:?}", all_consuming(variable_lvalue)(Span::new("a[1][2]"))),
|
|
||||||
// "Ok((\"\", Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"2\")))))], part_select_range: None } })))"
|
|
||||||
//);
|
|
||||||
//assert_eq!(
|
|
||||||
// format!("{:?}", all_consuming(variable_lvalue)(Span::new("a[1][10:5]"))),
|
|
||||||
// "Ok((\"\", Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))], part_select_range: Some(Range((Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"10\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"5\")))))))) } })))"
|
|
||||||
//);
|
|
||||||
//assert_eq!(
|
|
||||||
// format!("{:?}", all_consuming(variable_lvalue)(Span::new("{a, b[1], c}"))),
|
|
||||||
// "Ok((\"\", Lvalue([Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [], part_select_range: None } }), Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"b\" } }, select: Select { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\")))))], part_select_range: None } }), Identifier(VariableLvalueIdentifier { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"c\" } }, select: Select { member: None, bit_select: [], part_select_range: None } })])))"
|
|
||||||
//);
|
|
||||||
//assert_eq!(
|
|
||||||
// format!("{:?}", all_consuming(nonrange_variable_lvalue)(Span::new("a"))),
|
|
||||||
// "Ok((\"\", NonrangeVariableLvalue { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [], part_select_range: None } }))"
|
|
||||||
//);
|
|
||||||
//assert_eq!(
|
|
||||||
// format!("{:?}", all_consuming(nonrange_variable_lvalue)(Span::new("a[1][2]"))),
|
|
||||||
// "Ok((\"\", NonrangeVariableLvalue { scope: None, identifier: HierarchicalIdentifier { hierarchy: [], identifier: Identifier { raw: \"a\" } }, select: Select { member: None, bit_select: [Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"1\"))))), Nullary(PrimaryLiteral(Number(IntegralNumber(UnsignedNumber(\"2\")))))], part_select_range: None } }))"
|
|
||||||
//);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -34,15 +34,17 @@ pub struct IncOrDecExpressionSuffix<'a> {
|
|||||||
pub struct ConditionalExpression<'a> {
|
pub struct ConditionalExpression<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
CondPredicate<'a>,
|
CondPredicate<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
Vec<AttributeInstance<'a>>,
|
Vec<AttributeInstance<'a>>,
|
||||||
Expression<'a>,
|
Expression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
Expression<'a>,
|
Expression<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ConstantExpression<'a> {
|
pub enum ConstantExpression<'a> {
|
||||||
Nullary(Box<ConstantPrimary<'a>>),
|
ConstantPrimary(Box<ConstantPrimary<'a>>),
|
||||||
Unary(Box<ConstantExpressionUnary<'a>>),
|
Unary(Box<ConstantExpressionUnary<'a>>),
|
||||||
Binary(Box<ConstantExpressionBinary<'a>>),
|
Binary(Box<ConstantExpressionBinary<'a>>),
|
||||||
Ternary(Box<ConstantExpressionTernary<'a>>),
|
Ternary(Box<ConstantExpressionTernary<'a>>),
|
||||||
@ -71,8 +73,10 @@ pub struct ConstantExpressionBinary<'a> {
|
|||||||
pub struct ConstantExpressionTernary<'a> {
|
pub struct ConstantExpressionTernary<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
ConstantExpression<'a>,
|
ConstantExpression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
Vec<AttributeInstance<'a>>,
|
Vec<AttributeInstance<'a>>,
|
||||||
ConstantExpression<'a>,
|
ConstantExpression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
ConstantExpression<'a>,
|
ConstantExpression<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@ -80,70 +84,66 @@ pub struct ConstantExpressionTernary<'a> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ConstantMintypmaxExpression<'a> {
|
pub enum ConstantMintypmaxExpression<'a> {
|
||||||
Unary(ConstantExpression<'a>),
|
Unary(ConstantExpression<'a>),
|
||||||
Ternary(
|
Ternary(ConstantMintypmaxExpressionTernary<'a>),
|
||||||
(
|
}
|
||||||
ConstantExpression<'a>,
|
|
||||||
ConstantExpression<'a>,
|
#[derive(Debug)]
|
||||||
ConstantExpression<'a>,
|
pub struct ConstantMintypmaxExpressionTernary<'a> {
|
||||||
),
|
pub nodes: (
|
||||||
|
ConstantExpression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
ConstantExpression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
ConstantExpression<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ConstantParamExpression<'a> {
|
pub enum ConstantParamExpression<'a> {
|
||||||
Mintypmax(ConstantMintypmaxExpression<'a>),
|
ConstantMintypmaxExpression(ConstantMintypmaxExpression<'a>),
|
||||||
DataType(DataType<'a>),
|
DataType(DataType<'a>),
|
||||||
Dollar,
|
Dollar(Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ParamExpression<'a> {
|
pub enum ParamExpression<'a> {
|
||||||
Mintypmax(MintypmaxExpression<'a>),
|
MintypmaxExpression(MintypmaxExpression<'a>),
|
||||||
DataType(DataType<'a>),
|
DataType(DataType<'a>),
|
||||||
Dollar,
|
Dollar(Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ConstantRangeExpression<'a> {
|
pub enum ConstantRangeExpression<'a> {
|
||||||
Expression(ConstantExpression<'a>),
|
ConstantExpression(ConstantExpression<'a>),
|
||||||
PartSelectRange(ConstantPartSelectRange<'a>),
|
ConstantPartSelectRange(ConstantPartSelectRange<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ConstantPartSelectRange<'a> {
|
pub enum ConstantPartSelectRange<'a> {
|
||||||
Range(ConstantRange<'a>),
|
ConstantRange(ConstantRange<'a>),
|
||||||
IndexedRange(ConstantIndexedRange<'a>),
|
ConstantIndexedRange(ConstantIndexedRange<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ConstantRange<'a> {
|
pub struct ConstantRange<'a> {
|
||||||
pub nodes: (ConstantExpression<'a>, ConstantExpression<'a>),
|
pub nodes: (ConstantExpression<'a>, Symbol<'a>, ConstantExpression<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ConstantIndexedRange<'a> {
|
pub struct ConstantIndexedRange<'a> {
|
||||||
pub nodes: (
|
pub nodes: (ConstantExpression<'a>, Symbol<'a>, ConstantExpression<'a>),
|
||||||
ConstantExpression<'a>,
|
|
||||||
ConstantIndexedRangeOperator<'a>,
|
|
||||||
ConstantExpression<'a>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct ConstantIndexedRangeOperator<'a> {
|
|
||||||
pub nodes: (Symbol<'a>,),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Expression<'a> {
|
pub enum Expression<'a> {
|
||||||
Nullary(Box<Primary<'a>>),
|
Primary(Box<Primary<'a>>),
|
||||||
Unary(Box<ExpressionUnary<'a>>),
|
Unary(Box<ExpressionUnary<'a>>),
|
||||||
IncOrDec(Box<IncOrDecExpression<'a>>),
|
IncOrDecExpression(Box<IncOrDecExpression<'a>>),
|
||||||
Assignment(Box<OperatorAssignment<'a>>),
|
OperatorAssignment(Box<ExpressionOperatorAssignment<'a>>),
|
||||||
Binary(Box<ExpressionBinary<'a>>),
|
Binary(Box<ExpressionBinary<'a>>),
|
||||||
Conditional(Box<ConditionalExpression<'a>>),
|
ConditionalExpression(Box<ConditionalExpression<'a>>),
|
||||||
Inside(Box<InsideExpression<'a>>),
|
InsideExpression(Box<InsideExpression<'a>>),
|
||||||
TaggedUnion(Box<TaggedUnionExpression<'a>>),
|
TaggedUnionExpression(Box<TaggedUnionExpression<'a>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -151,6 +151,11 @@ pub struct ExpressionUnary<'a> {
|
|||||||
pub nodes: (UnaryOperator<'a>, Vec<AttributeInstance<'a>>, Primary<'a>),
|
pub nodes: (UnaryOperator<'a>, Vec<AttributeInstance<'a>>, Primary<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ExpressionOperatorAssignment<'a> {
|
||||||
|
pub nodes: (Symbol<'a>, OperatorAssignment<'a>, Symbol<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ExpressionBinary<'a> {
|
pub struct ExpressionBinary<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
@ -163,42 +168,72 @@ pub struct ExpressionBinary<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TaggedUnionExpression<'a> {
|
pub struct TaggedUnionExpression<'a> {
|
||||||
pub nodes: (MemberIdentifier<'a>, Option<Expression<'a>>),
|
pub nodes: (Symbol<'a>, MemberIdentifier<'a>, Option<Expression<'a>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct InsideExpression<'a> {
|
pub struct InsideExpression<'a> {
|
||||||
pub nodes: (Expression<'a>, Vec<ValueRange<'a>>),
|
pub nodes: (
|
||||||
|
Expression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Vec<ValueRange<'a>>,
|
||||||
|
Symbol<'a>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ValueRange<'a> {
|
pub enum ValueRange<'a> {
|
||||||
Unary(Expression<'a>),
|
Expression(Expression<'a>),
|
||||||
Binary((Expression<'a>, Expression<'a>)),
|
Binary(ValueRangeBinary<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ValueRangeBinary<'a> {
|
||||||
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
Expression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Expression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum MintypmaxExpression<'a> {
|
pub enum MintypmaxExpression<'a> {
|
||||||
Unary(Expression<'a>),
|
Expression(Expression<'a>),
|
||||||
Ternary((Expression<'a>, Expression<'a>, Expression<'a>)),
|
Ternary(MintypmaxExpressionTernary<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct MintypmaxExpressionTernary<'a> {
|
||||||
|
pub nodes: (
|
||||||
|
Expression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Expression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Expression<'a>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ModulePathConditionalExpression<'a> {
|
pub struct ModulePathConditionalExpression<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
ModulePathExpression<'a>,
|
ModulePathExpression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
Vec<AttributeInstance<'a>>,
|
Vec<AttributeInstance<'a>>,
|
||||||
ModulePathExpression<'a>,
|
ModulePathExpression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
ModulePathExpression<'a>,
|
ModulePathExpression<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ModulePathExpression<'a> {
|
pub enum ModulePathExpression<'a> {
|
||||||
Nullary(Box<ModulePathPrimary<'a>>),
|
ModulePathPrimary(Box<ModulePathPrimary<'a>>),
|
||||||
Unary(Box<ModulePathExpressionUnary<'a>>),
|
Unary(Box<ModulePathExpressionUnary<'a>>),
|
||||||
Binary(Box<ModulePathExpressionBinary<'a>>),
|
Binary(Box<ModulePathExpressionBinary<'a>>),
|
||||||
Conditional(Box<ModulePathConditionalExpression<'a>>),
|
ModulePathConditionalExpression(Box<ModulePathConditionalExpression<'a>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -222,20 +257,35 @@ pub struct ModulePathExpressionBinary<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ModulePathMintypmaxExpression<'a> {
|
pub enum ModulePathMintypmaxExpression<'a> {
|
||||||
Unary(ModulePathExpression<'a>),
|
ModulePathExpression(ModulePathExpression<'a>),
|
||||||
Ternary(
|
Ternary(ModulePathMintypmaxExpressionTernary<'a>),
|
||||||
(
|
}
|
||||||
ModulePathExpression<'a>,
|
|
||||||
ModulePathExpression<'a>,
|
#[derive(Debug)]
|
||||||
ModulePathExpression<'a>,
|
pub struct ModulePathMintypmaxExpressionTernary<'a> {
|
||||||
),
|
pub nodes: (
|
||||||
|
ModulePathExpression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
ModulePathExpression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
ModulePathExpression<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum PartSelectRange<'a> {
|
pub enum PartSelectRange<'a> {
|
||||||
Range((ConstantExpression<'a>, ConstantExpression<'a>)),
|
ConstantRange(ConstantRange<'a>),
|
||||||
IndexedRange((Expression<'a>, Symbol<'a>, ConstantExpression<'a>)),
|
IndexedRange(IndexedRange<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct IndexedRange<'a> {
|
||||||
|
pub nodes: (Expression<'a>, Symbol<'a>, ConstantExpression<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct GenvarExpression<'a> {
|
||||||
|
pub nodes: (ConstantExpression<'a>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -245,36 +295,36 @@ pub fn inc_or_dec_expression(s: Span) -> IResult<Span, IncOrDecExpression> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn inc_or_dec_expression_prefix(s: Span) -> IResult<Span, IncOrDecExpression> {
|
pub fn inc_or_dec_expression_prefix(s: Span) -> IResult<Span, IncOrDecExpression> {
|
||||||
let (s, x) = inc_or_dec_operator(s)?;
|
let (s, a) = inc_or_dec_operator(s)?;
|
||||||
let (s, y) = many0(attribute_instance)(s)?;
|
let (s, b) = many0(attribute_instance)(s)?;
|
||||||
let (s, z) = variable_lvalue(s)?;
|
let (s, c) = variable_lvalue(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
IncOrDecExpression::Prefix(IncOrDecExpressionPrefix { nodes: (x, y, z) }),
|
IncOrDecExpression::Prefix(IncOrDecExpressionPrefix { nodes: (a, b, c) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inc_or_dec_expression_suffix(s: Span) -> IResult<Span, IncOrDecExpression> {
|
pub fn inc_or_dec_expression_suffix(s: Span) -> IResult<Span, IncOrDecExpression> {
|
||||||
let (s, x) = variable_lvalue(s)?;
|
let (s, a) = variable_lvalue(s)?;
|
||||||
let (s, y) = many0(attribute_instance)(s)?;
|
let (s, b) = many0(attribute_instance)(s)?;
|
||||||
let (s, z) = inc_or_dec_operator(s)?;
|
let (s, c) = inc_or_dec_operator(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
IncOrDecExpression::Suffix(IncOrDecExpressionSuffix { nodes: (x, y, z) }),
|
IncOrDecExpression::Suffix(IncOrDecExpressionSuffix { nodes: (a, b, c) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn conditional_expression(s: Span) -> IResult<Span, ConditionalExpression> {
|
pub fn conditional_expression(s: Span) -> IResult<Span, ConditionalExpression> {
|
||||||
let (s, x) = cond_predicate(s)?;
|
let (s, a) = cond_predicate(s)?;
|
||||||
let (s, _) = symbol("?")(s)?;
|
let (s, b) = symbol("?")(s)?;
|
||||||
let (s, y) = many0(attribute_instance)(s)?;
|
let (s, c) = many0(attribute_instance)(s)?;
|
||||||
let (s, z) = expression(s)?;
|
let (s, d) = expression(s)?;
|
||||||
let (s, _) = symbol(":")(s)?;
|
let (s, e) = symbol(":")(s)?;
|
||||||
let (s, v) = expression(s)?;
|
let (s, f) = expression(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ConditionalExpression {
|
ConditionalExpression {
|
||||||
nodes: (x, y, z, v),
|
nodes: (a, b, c, d, e, f),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -282,7 +332,7 @@ pub fn conditional_expression(s: Span) -> IResult<Span, ConditionalExpression> {
|
|||||||
pub fn constant_expression(s: Span) -> IResult<Span, ConstantExpression> {
|
pub fn constant_expression(s: Span) -> IResult<Span, ConstantExpression> {
|
||||||
alt((
|
alt((
|
||||||
map(constant_primary, |x| {
|
map(constant_primary, |x| {
|
||||||
ConstantExpression::Nullary(Box::new(x))
|
ConstantExpression::ConstantPrimary(Box::new(x))
|
||||||
}),
|
}),
|
||||||
constant_expression_unary,
|
constant_expression_unary,
|
||||||
constant_expression_binary,
|
constant_expression_binary,
|
||||||
@ -291,39 +341,39 @@ pub fn constant_expression(s: Span) -> IResult<Span, ConstantExpression> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_expression_unary(s: Span) -> IResult<Span, ConstantExpression> {
|
pub fn constant_expression_unary(s: Span) -> IResult<Span, ConstantExpression> {
|
||||||
let (s, x) = unary_operator(s)?;
|
let (s, a) = unary_operator(s)?;
|
||||||
let (s, y) = many0(attribute_instance)(s)?;
|
let (s, b) = many0(attribute_instance)(s)?;
|
||||||
let (s, z) = constant_primary(s)?;
|
let (s, c) = constant_primary(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ConstantExpression::Unary(Box::new(ConstantExpressionUnary { nodes: (x, y, z) })),
|
ConstantExpression::Unary(Box::new(ConstantExpressionUnary { nodes: (a, b, c) })),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_expression_binary(s: Span) -> IResult<Span, ConstantExpression> {
|
pub fn constant_expression_binary(s: Span) -> IResult<Span, ConstantExpression> {
|
||||||
let (s, x) = constant_expression(s)?;
|
let (s, a) = constant_expression(s)?;
|
||||||
let (s, y) = binary_operator(s)?;
|
let (s, b) = binary_operator(s)?;
|
||||||
let (s, z) = many0(attribute_instance)(s)?;
|
let (s, c) = many0(attribute_instance)(s)?;
|
||||||
let (s, v) = constant_expression(s)?;
|
let (s, d) = constant_expression(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ConstantExpression::Binary(Box::new(ConstantExpressionBinary {
|
ConstantExpression::Binary(Box::new(ConstantExpressionBinary {
|
||||||
nodes: (x, y, z, v),
|
nodes: (a, b, c, d),
|
||||||
})),
|
})),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_expression_ternary(s: Span) -> IResult<Span, ConstantExpression> {
|
pub fn constant_expression_ternary(s: Span) -> IResult<Span, ConstantExpression> {
|
||||||
let (s, x) = constant_expression(s)?;
|
let (s, a) = constant_expression(s)?;
|
||||||
let (s, _) = symbol("?")(s)?;
|
let (s, b) = symbol("?")(s)?;
|
||||||
let (s, y) = many0(attribute_instance)(s)?;
|
let (s, c) = many0(attribute_instance)(s)?;
|
||||||
let (s, z) = constant_expression(s)?;
|
let (s, d) = constant_expression(s)?;
|
||||||
let (s, _) = symbol(":")(s)?;
|
let (s, e) = symbol(":")(s)?;
|
||||||
let (s, v) = constant_expression(s)?;
|
let (s, f) = constant_expression(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ConstantExpression::Ternary(Box::new(ConstantExpressionTernary {
|
ConstantExpression::Ternary(Box::new(ConstantExpressionTernary {
|
||||||
nodes: (x, y, z, v),
|
nodes: (a, b, c, d, e, f),
|
||||||
})),
|
})),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -340,19 +390,24 @@ pub fn constant_mintypmax_expression(s: Span) -> IResult<Span, ConstantMintypmax
|
|||||||
pub fn constant_mintypmax_expression_ternary(
|
pub fn constant_mintypmax_expression_ternary(
|
||||||
s: Span,
|
s: Span,
|
||||||
) -> IResult<Span, ConstantMintypmaxExpression> {
|
) -> IResult<Span, ConstantMintypmaxExpression> {
|
||||||
let (s, x) = constant_expression(s)?;
|
let (s, a) = constant_expression(s)?;
|
||||||
let (s, _) = symbol(":")(s)?;
|
let (s, b) = symbol(":")(s)?;
|
||||||
let (s, y) = constant_expression(s)?;
|
let (s, c) = constant_expression(s)?;
|
||||||
let (s, _) = symbol(":")(s)?;
|
let (s, d) = symbol(":")(s)?;
|
||||||
let (s, z) = constant_expression(s)?;
|
let (s, e) = constant_expression(s)?;
|
||||||
Ok((s, ConstantMintypmaxExpression::Ternary((x, y, z))))
|
Ok((
|
||||||
|
s,
|
||||||
|
ConstantMintypmaxExpression::Ternary(ConstantMintypmaxExpressionTernary {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
}),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_param_expression(s: Span) -> IResult<Span, ConstantParamExpression> {
|
pub fn constant_param_expression(s: Span) -> IResult<Span, ConstantParamExpression> {
|
||||||
alt((
|
alt((
|
||||||
map(symbol("$"), |_| ConstantParamExpression::Dollar),
|
map(symbol("$"), |x| ConstantParamExpression::Dollar(x)),
|
||||||
map(constant_mintypmax_expression, |x| {
|
map(constant_mintypmax_expression, |x| {
|
||||||
ConstantParamExpression::Mintypmax(x)
|
ConstantParamExpression::ConstantMintypmaxExpression(x)
|
||||||
}),
|
}),
|
||||||
map(data_type, |x| ConstantParamExpression::DataType(x)),
|
map(data_type, |x| ConstantParamExpression::DataType(x)),
|
||||||
))(s)
|
))(s)
|
||||||
@ -360,8 +415,10 @@ pub fn constant_param_expression(s: Span) -> IResult<Span, ConstantParamExpressi
|
|||||||
|
|
||||||
pub fn param_expression(s: Span) -> IResult<Span, ParamExpression> {
|
pub fn param_expression(s: Span) -> IResult<Span, ParamExpression> {
|
||||||
alt((
|
alt((
|
||||||
map(symbol("$"), |_| ParamExpression::Dollar),
|
map(symbol("$"), |x| ParamExpression::Dollar(x)),
|
||||||
map(mintypmax_expression, |x| ParamExpression::Mintypmax(x)),
|
map(mintypmax_expression, |x| {
|
||||||
|
ParamExpression::MintypmaxExpression(x)
|
||||||
|
}),
|
||||||
map(data_type, |x| ParamExpression::DataType(x)),
|
map(data_type, |x| ParamExpression::DataType(x)),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
@ -369,54 +426,56 @@ pub fn param_expression(s: Span) -> IResult<Span, ParamExpression> {
|
|||||||
pub fn constant_range_expression(s: Span) -> IResult<Span, ConstantRangeExpression> {
|
pub fn constant_range_expression(s: Span) -> IResult<Span, ConstantRangeExpression> {
|
||||||
alt((
|
alt((
|
||||||
map(constant_part_select_range, |x| {
|
map(constant_part_select_range, |x| {
|
||||||
ConstantRangeExpression::PartSelectRange(x)
|
ConstantRangeExpression::ConstantPartSelectRange(x)
|
||||||
}),
|
}),
|
||||||
map(constant_expression, |x| {
|
map(constant_expression, |x| {
|
||||||
ConstantRangeExpression::Expression(x)
|
ConstantRangeExpression::ConstantExpression(x)
|
||||||
}),
|
}),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_part_select_range(s: Span) -> IResult<Span, ConstantPartSelectRange> {
|
pub fn constant_part_select_range(s: Span) -> IResult<Span, ConstantPartSelectRange> {
|
||||||
alt((
|
alt((
|
||||||
map(constant_range, |x| ConstantPartSelectRange::Range(x)),
|
map(constant_range, |x| {
|
||||||
|
ConstantPartSelectRange::ConstantRange(x)
|
||||||
|
}),
|
||||||
map(constant_indexed_range, |x| {
|
map(constant_indexed_range, |x| {
|
||||||
ConstantPartSelectRange::IndexedRange(x)
|
ConstantPartSelectRange::ConstantIndexedRange(x)
|
||||||
}),
|
}),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_range(s: Span) -> IResult<Span, ConstantRange> {
|
pub fn constant_range(s: Span) -> IResult<Span, ConstantRange> {
|
||||||
let (s, x) = constant_expression(s)?;
|
let (s, a) = constant_expression(s)?;
|
||||||
let (s, _) = symbol(":")(s)?;
|
let (s, b) = symbol(":")(s)?;
|
||||||
let (s, y) = constant_expression(s)?;
|
let (s, c) = constant_expression(s)?;
|
||||||
Ok((s, ConstantRange { nodes: (x, y) }))
|
Ok((s, ConstantRange { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_indexed_range(s: Span) -> IResult<Span, ConstantIndexedRange> {
|
pub fn constant_indexed_range(s: Span) -> IResult<Span, ConstantIndexedRange> {
|
||||||
let (s, x) = constant_expression(s)?;
|
let (s, a) = constant_expression(s)?;
|
||||||
let (s, y) = map(alt((symbol("+:"), symbol("-:"))), |x| {
|
let (s, b) = alt((symbol("+:"), symbol("-:")))(s)?;
|
||||||
ConstantIndexedRangeOperator { nodes: (x,) }
|
let (s, c) = constant_expression(s)?;
|
||||||
})(s)?;
|
Ok((s, ConstantIndexedRange { nodes: (a, b, c) }))
|
||||||
let (s, z) = constant_expression(s)?;
|
|
||||||
Ok((s, ConstantIndexedRange { nodes: (x, y, z) }))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expression(s: Span) -> IResult<Span, Expression> {
|
pub fn expression(s: Span) -> IResult<Span, Expression> {
|
||||||
alt((
|
alt((
|
||||||
map(primary, |x| Expression::Nullary(Box::new(x))),
|
map(primary, |x| Expression::Primary(Box::new(x))),
|
||||||
expression_unary,
|
expression_unary,
|
||||||
map(inc_or_dec_expression, |x| Expression::IncOrDec(Box::new(x))),
|
map(inc_or_dec_expression, |x| {
|
||||||
map(paren(operator_assignment), |x| {
|
Expression::IncOrDecExpression(Box::new(x))
|
||||||
Expression::Assignment(Box::new(x))
|
|
||||||
}),
|
}),
|
||||||
|
expression_operator_assignment,
|
||||||
expression_binary,
|
expression_binary,
|
||||||
map(conditional_expression, |x| {
|
map(conditional_expression, |x| {
|
||||||
Expression::Conditional(Box::new(x))
|
Expression::ConditionalExpression(Box::new(x))
|
||||||
|
}),
|
||||||
|
map(inside_expression, |x| {
|
||||||
|
Expression::InsideExpression(Box::new(x))
|
||||||
}),
|
}),
|
||||||
map(inside_expression, |x| Expression::Inside(Box::new(x))),
|
|
||||||
map(tagged_union_expression, |x| {
|
map(tagged_union_expression, |x| {
|
||||||
Expression::TaggedUnion(Box::new(x))
|
Expression::TaggedUnionExpression(Box::new(x))
|
||||||
}),
|
}),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
@ -431,78 +490,103 @@ pub fn expression_unary(s: Span) -> IResult<Span, Expression> {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn expression_operator_assignment(s: Span) -> IResult<Span, Expression> {
|
||||||
|
let (s, a) = paren2(operator_assignment)(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
Expression::OperatorAssignment(Box::new(ExpressionOperatorAssignment { nodes: a })),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn expression_binary(s: Span) -> IResult<Span, Expression> {
|
pub fn expression_binary(s: Span) -> IResult<Span, Expression> {
|
||||||
let (s, x) = expression(s)?;
|
let (s, a) = expression(s)?;
|
||||||
let (s, y) = binary_operator(s)?;
|
let (s, b) = binary_operator(s)?;
|
||||||
let (s, z) = many0(attribute_instance)(s)?;
|
let (s, c) = many0(attribute_instance)(s)?;
|
||||||
let (s, v) = expression(s)?;
|
let (s, d) = expression(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
Expression::Binary(Box::new(ExpressionBinary {
|
Expression::Binary(Box::new(ExpressionBinary {
|
||||||
nodes: (x, y, z, v),
|
nodes: (a, b, c, d),
|
||||||
})),
|
})),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tagged_union_expression(s: Span) -> IResult<Span, TaggedUnionExpression> {
|
pub fn tagged_union_expression(s: Span) -> IResult<Span, TaggedUnionExpression> {
|
||||||
let (s, _) = symbol("tagged")(s)?;
|
let (s, a) = symbol("tagged")(s)?;
|
||||||
let (s, x) = member_identifier(s)?;
|
let (s, b) = member_identifier(s)?;
|
||||||
let (s, y) = opt(expression)(s)?;
|
let (s, c) = opt(expression)(s)?;
|
||||||
Ok((s, TaggedUnionExpression { nodes: (x, y) }))
|
Ok((s, TaggedUnionExpression { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inside_expression(s: Span) -> IResult<Span, InsideExpression> {
|
pub fn inside_expression(s: Span) -> IResult<Span, InsideExpression> {
|
||||||
let (s, x) = expression(s)?;
|
let (s, a) = expression(s)?;
|
||||||
let (s, _) = symbol("inside")(s)?;
|
let (s, b) = symbol("inside")(s)?;
|
||||||
let (s, y) = brace(open_range_list)(s)?;
|
let (s, c) = symbol("{")(s)?;
|
||||||
Ok((s, InsideExpression { nodes: (x, y) }))
|
let (s, d) = brace(open_range_list)(s)?;
|
||||||
|
let (s, e) = symbol("}")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
InsideExpression {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn value_range(s: Span) -> IResult<Span, ValueRange> {
|
pub fn value_range(s: Span) -> IResult<Span, ValueRange> {
|
||||||
alt((
|
alt((
|
||||||
value_range_binary,
|
value_range_binary,
|
||||||
map(expression, |x| ValueRange::Unary(x)),
|
map(expression, |x| ValueRange::Expression(x)),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn value_range_binary(s: Span) -> IResult<Span, ValueRange> {
|
pub fn value_range_binary(s: Span) -> IResult<Span, ValueRange> {
|
||||||
let (s, _) = symbol("[")(s)?;
|
let (s, a) = symbol("[")(s)?;
|
||||||
let (s, x) = expression(s)?;
|
let (s, b) = expression(s)?;
|
||||||
let (s, _) = symbol(":")(s)?;
|
let (s, c) = symbol(":")(s)?;
|
||||||
let (s, y) = expression(s)?;
|
let (s, d) = expression(s)?;
|
||||||
let (s, _) = symbol("]")(s)?;
|
let (s, e) = symbol("]")(s)?;
|
||||||
Ok((s, ValueRange::Binary((x, y))))
|
Ok((
|
||||||
|
s,
|
||||||
|
ValueRange::Binary(ValueRangeBinary {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
}),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mintypmax_expression(s: Span) -> IResult<Span, MintypmaxExpression> {
|
pub fn mintypmax_expression(s: Span) -> IResult<Span, MintypmaxExpression> {
|
||||||
alt((
|
alt((
|
||||||
mintypmax_expression_ternary,
|
mintypmax_expression_ternary,
|
||||||
map(expression, |x| MintypmaxExpression::Unary(x)),
|
map(expression, |x| MintypmaxExpression::Expression(x)),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mintypmax_expression_ternary(s: Span) -> IResult<Span, MintypmaxExpression> {
|
pub fn mintypmax_expression_ternary(s: Span) -> IResult<Span, MintypmaxExpression> {
|
||||||
let (s, x) = expression(s)?;
|
let (s, a) = expression(s)?;
|
||||||
let (s, _) = symbol(":")(s)?;
|
let (s, b) = symbol(":")(s)?;
|
||||||
let (s, y) = expression(s)?;
|
let (s, c) = expression(s)?;
|
||||||
let (s, _) = symbol(":")(s)?;
|
let (s, d) = symbol(":")(s)?;
|
||||||
let (s, z) = expression(s)?;
|
let (s, e) = expression(s)?;
|
||||||
Ok((s, MintypmaxExpression::Ternary((x, y, z))))
|
Ok((
|
||||||
|
s,
|
||||||
|
MintypmaxExpression::Ternary(MintypmaxExpressionTernary {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
}),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn module_path_conditional_expression(
|
pub fn module_path_conditional_expression(
|
||||||
s: Span,
|
s: Span,
|
||||||
) -> IResult<Span, ModulePathConditionalExpression> {
|
) -> IResult<Span, ModulePathConditionalExpression> {
|
||||||
let (s, x) = module_path_expression(s)?;
|
let (s, a) = module_path_expression(s)?;
|
||||||
let (s, _) = symbol("?")(s)?;
|
let (s, b) = symbol("?")(s)?;
|
||||||
let (s, y) = many0(attribute_instance)(s)?;
|
let (s, c) = many0(attribute_instance)(s)?;
|
||||||
let (s, z) = module_path_expression(s)?;
|
let (s, d) = module_path_expression(s)?;
|
||||||
let (s, _) = symbol(":")(s)?;
|
let (s, e) = symbol(":")(s)?;
|
||||||
let (s, v) = module_path_expression(s)?;
|
let (s, f) = module_path_expression(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ModulePathConditionalExpression {
|
ModulePathConditionalExpression {
|
||||||
nodes: (x, y, z, v),
|
nodes: (a, b, c, d, e, f),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -510,35 +594,35 @@ pub fn module_path_conditional_expression(
|
|||||||
pub fn module_path_expression(s: Span) -> IResult<Span, ModulePathExpression> {
|
pub fn module_path_expression(s: Span) -> IResult<Span, ModulePathExpression> {
|
||||||
alt((
|
alt((
|
||||||
map(module_path_primary, |x| {
|
map(module_path_primary, |x| {
|
||||||
ModulePathExpression::Nullary(Box::new(x))
|
ModulePathExpression::ModulePathPrimary(Box::new(x))
|
||||||
}),
|
}),
|
||||||
module_path_expression_unary,
|
module_path_expression_unary,
|
||||||
module_path_expression_binary,
|
module_path_expression_binary,
|
||||||
map(module_path_conditional_expression, |x| {
|
map(module_path_conditional_expression, |x| {
|
||||||
ModulePathExpression::Conditional(Box::new(x))
|
ModulePathExpression::ModulePathConditionalExpression(Box::new(x))
|
||||||
}),
|
}),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn module_path_expression_unary(s: Span) -> IResult<Span, ModulePathExpression> {
|
pub fn module_path_expression_unary(s: Span) -> IResult<Span, ModulePathExpression> {
|
||||||
let (s, x) = unary_module_path_operator(s)?;
|
let (s, a) = unary_module_path_operator(s)?;
|
||||||
let (s, y) = many0(attribute_instance)(s)?;
|
let (s, b) = many0(attribute_instance)(s)?;
|
||||||
let (s, z) = module_path_primary(s)?;
|
let (s, c) = module_path_primary(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ModulePathExpression::Unary(Box::new(ModulePathExpressionUnary { nodes: (x, y, z) })),
|
ModulePathExpression::Unary(Box::new(ModulePathExpressionUnary { nodes: (a, b, c) })),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn module_path_expression_binary(s: Span) -> IResult<Span, ModulePathExpression> {
|
pub fn module_path_expression_binary(s: Span) -> IResult<Span, ModulePathExpression> {
|
||||||
let (s, x) = module_path_expression(s)?;
|
let (s, a) = module_path_expression(s)?;
|
||||||
let (s, y) = binary_module_path_operator(s)?;
|
let (s, b) = binary_module_path_operator(s)?;
|
||||||
let (s, z) = many0(attribute_instance)(s)?;
|
let (s, c) = many0(attribute_instance)(s)?;
|
||||||
let (s, v) = module_path_expression(s)?;
|
let (s, d) = module_path_expression(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ModulePathExpression::Binary(Box::new(ModulePathExpressionBinary {
|
ModulePathExpression::Binary(Box::new(ModulePathExpressionBinary {
|
||||||
nodes: (x, y, z, v),
|
nodes: (a, b, c, d),
|
||||||
})),
|
})),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -547,7 +631,7 @@ pub fn module_path_mintypmax_expression(s: Span) -> IResult<Span, ModulePathMint
|
|||||||
alt((
|
alt((
|
||||||
module_path_mintypmax_expression_ternary,
|
module_path_mintypmax_expression_ternary,
|
||||||
map(module_path_expression, |x| {
|
map(module_path_expression, |x| {
|
||||||
ModulePathMintypmaxExpression::Unary(x)
|
ModulePathMintypmaxExpression::ModulePathExpression(x)
|
||||||
}),
|
}),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
@ -555,34 +639,36 @@ pub fn module_path_mintypmax_expression(s: Span) -> IResult<Span, ModulePathMint
|
|||||||
pub fn module_path_mintypmax_expression_ternary(
|
pub fn module_path_mintypmax_expression_ternary(
|
||||||
s: Span,
|
s: Span,
|
||||||
) -> IResult<Span, ModulePathMintypmaxExpression> {
|
) -> IResult<Span, ModulePathMintypmaxExpression> {
|
||||||
let (s, x) = module_path_expression(s)?;
|
let (s, a) = module_path_expression(s)?;
|
||||||
let (s, _) = symbol(":")(s)?;
|
let (s, b) = symbol(":")(s)?;
|
||||||
let (s, y) = module_path_expression(s)?;
|
let (s, c) = module_path_expression(s)?;
|
||||||
let (s, _) = symbol(":")(s)?;
|
let (s, d) = symbol(":")(s)?;
|
||||||
let (s, z) = module_path_expression(s)?;
|
let (s, e) = module_path_expression(s)?;
|
||||||
Ok((s, ModulePathMintypmaxExpression::Ternary((x, y, z))))
|
Ok((
|
||||||
|
s,
|
||||||
|
ModulePathMintypmaxExpression::Ternary(ModulePathMintypmaxExpressionTernary {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
}),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn part_select_range(s: Span) -> IResult<Span, PartSelectRange> {
|
pub fn part_select_range(s: Span) -> IResult<Span, PartSelectRange> {
|
||||||
alt((range, indexed_range))(s)
|
alt((
|
||||||
|
map(constant_range, |x| PartSelectRange::ConstantRange(x)),
|
||||||
|
map(indexed_range, |x| PartSelectRange::IndexedRange(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn range(s: Span) -> IResult<Span, PartSelectRange> {
|
pub fn indexed_range(s: Span) -> IResult<Span, IndexedRange> {
|
||||||
let (s, x) = constant_expression(s)?;
|
let (s, a) = expression(s)?;
|
||||||
let (s, _) = symbol(":")(s)?;
|
let (s, b) = alt((symbol("+:"), symbol("-:")))(s)?;
|
||||||
let (s, y) = constant_expression(s)?;
|
let (s, c) = constant_expression(s)?;
|
||||||
Ok((s, PartSelectRange::Range((x, y))))
|
Ok((s, IndexedRange { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn indexed_range(s: Span) -> IResult<Span, PartSelectRange> {
|
pub fn genvar_expression(s: Span) -> IResult<Span, GenvarExpression> {
|
||||||
let (s, x) = expression(s)?;
|
let (s, a) = constant_expression(s)?;
|
||||||
let (s, y) = alt((symbol("+:"), symbol("-:")))(s)?;
|
Ok((s, GenvarExpression { nodes: (a,) }))
|
||||||
let (s, z) = constant_expression(s)?;
|
|
||||||
Ok((s, PartSelectRange::IndexedRange((x, y, z))))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn genvar_expression(s: Span) -> IResult<Span, ConstantExpression> {
|
|
||||||
constant_expression(s)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -591,22 +677,5 @@ pub fn genvar_expression(s: Span) -> IResult<Span, ConstantExpression> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test() {
|
fn test() {}
|
||||||
// TODO after operator_assignment
|
|
||||||
//assert_eq!(
|
|
||||||
// format!(
|
|
||||||
// "{:?}",
|
|
||||||
// all_consuming(expression)("(a:b:c) + (d:e:f)")
|
|
||||||
// ),
|
|
||||||
// ""
|
|
||||||
//);
|
|
||||||
// TODO after operator_assignment
|
|
||||||
//assert_eq!(
|
|
||||||
// format!(
|
|
||||||
// "{:?}",
|
|
||||||
// all_consuming(expression)("val - (32'd 50: 32'd 75: 32'd 100)")
|
|
||||||
// ),
|
|
||||||
// ""
|
|
||||||
//);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ use crate::parser::*;
|
|||||||
use nom::branch::*;
|
use nom::branch::*;
|
||||||
use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::multi::*;
|
use nom::multi::*;
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -12,18 +11,18 @@ pub enum ConstantPrimary<'a> {
|
|||||||
PrimaryLiteral(PrimaryLiteral<'a>),
|
PrimaryLiteral(PrimaryLiteral<'a>),
|
||||||
PsParameter(ConstantPrimaryPsParameter<'a>),
|
PsParameter(ConstantPrimaryPsParameter<'a>),
|
||||||
Specparam(ConstantPrimarySpecparam<'a>),
|
Specparam(ConstantPrimarySpecparam<'a>),
|
||||||
Genvar(GenvarIdentifier<'a>),
|
GenvarIdentifier(GenvarIdentifier<'a>),
|
||||||
FormalPort(ConstantPrimaryFormalPort<'a>),
|
FormalPort(ConstantPrimaryFormalPort<'a>),
|
||||||
Enum(ConstantPrimaryEnum<'a>),
|
Enum(ConstantPrimaryEnum<'a>),
|
||||||
Concatenation(ConstantPrimaryConcatenation<'a>),
|
Concatenation(ConstantPrimaryConcatenation<'a>),
|
||||||
MultipleConcatenation(ConstantPrimaryMultipleConcatenation<'a>),
|
MultipleConcatenation(ConstantPrimaryMultipleConcatenation<'a>),
|
||||||
FunctionCall(SubroutineCall<'a>),
|
ConstantFunctionCall(ConstantFunctionCall<'a>),
|
||||||
LetExpression(LetExpression<'a>),
|
ConstantLetExpression(ConstantLetExpression<'a>),
|
||||||
MintypmaxExpression(ConstantMintypmaxExpression<'a>),
|
MintypmaxExpression(ConstantPrimaryMintypmaxExpression<'a>),
|
||||||
Cast(ConstantCast<'a>),
|
ConstantCast(ConstantCast<'a>),
|
||||||
AssignmentPatternExpression(AssignmentPatternExpression<'a>),
|
ConstantAssignmentPatternExpression(ConstantAssignmentPatternExpression<'a>),
|
||||||
TypeReference(TypeReference<'a>),
|
TypeReference(TypeReference<'a>),
|
||||||
Null,
|
Null(Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -33,7 +32,10 @@ pub struct ConstantPrimaryPsParameter<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ConstantPrimarySpecparam<'a> {
|
pub struct ConstantPrimarySpecparam<'a> {
|
||||||
pub nodes: (SpecparamIdentifier<'a>, Option<ConstantRangeExpression<'a>>),
|
pub nodes: (
|
||||||
|
SpecparamIdentifier<'a>,
|
||||||
|
Option<(Symbol<'a>, ConstantRangeExpression<'a>, Symbol<'a>)>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -50,7 +52,7 @@ pub struct ConstantPrimaryEnum<'a> {
|
|||||||
pub struct ConstantPrimaryConcatenation<'a> {
|
pub struct ConstantPrimaryConcatenation<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
ConstantConcatenation<'a>,
|
ConstantConcatenation<'a>,
|
||||||
Option<ConstantRangeExpression<'a>>,
|
Option<(Symbol<'a>, ConstantRangeExpression<'a>, Symbol<'a>)>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,58 +60,53 @@ pub struct ConstantPrimaryConcatenation<'a> {
|
|||||||
pub struct ConstantPrimaryMultipleConcatenation<'a> {
|
pub struct ConstantPrimaryMultipleConcatenation<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
ConstantMultipleConcatenation<'a>,
|
ConstantMultipleConcatenation<'a>,
|
||||||
Option<ConstantRangeExpression<'a>>,
|
Option<(Symbol<'a>, ConstantRangeExpression<'a>, Symbol<'a>)>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ConstantPrimaryMintypmaxExpression<'a> {
|
||||||
|
pub nodes: (Symbol<'a>, ConstantMintypmaxExpression<'a>, Symbol<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ModulePathPrimary<'a> {
|
pub enum ModulePathPrimary<'a> {
|
||||||
Number(Number<'a>),
|
Number(Number<'a>),
|
||||||
Identifier(Identifier<'a>),
|
Identifier(Identifier<'a>),
|
||||||
ModulePathConcatenation(ModulePathConcatenation<'a>),
|
ModulePathConcatenation(ModulePathConcatenation<'a>),
|
||||||
ModulePathMultipleConcatenation(ModulePathMultipleConcatenation<'a>),
|
ModulePathMultipleConcatenation(ModulePathMultipleConcatenation<'a>),
|
||||||
FunctionSubroutineCall(SubroutineCall<'a>),
|
FunctionSubroutineCall(FunctionSubroutineCall<'a>),
|
||||||
ModulePathMintypmaxExpression(ModulePathMintypmaxExpression<'a>),
|
Mintypmax(ModulePathPrimaryMintypmax<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ModulePathPrimaryMintypmax<'a> {
|
||||||
|
pub nodes: (Symbol<'a>, ModulePathMintypmaxExpression<'a>, Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Primary<'a> {
|
pub enum Primary<'a> {
|
||||||
PrimaryLiteral(PrimaryLiteral<'a>),
|
PrimaryLiteral(PrimaryLiteral<'a>),
|
||||||
Hierarchical(PrimaryHierarchical<'a>),
|
Hierarchical(PrimaryHierarchical<'a>),
|
||||||
EmptyUnpackedArrayConcatenation,
|
EmptyUnpackedArrayConcatenation(EmptyUnpackedArrayConcatenation<'a>),
|
||||||
Concatenation(PrimaryConcatenation<'a>),
|
Concatenation(PrimaryConcatenation<'a>),
|
||||||
MultipleConcatenation(PrimaryMultipleConcatenation<'a>),
|
MultipleConcatenation(PrimaryMultipleConcatenation<'a>),
|
||||||
FunctionSubroutineCall(SubroutineCall<'a>),
|
FunctionSubroutineCall(FunctionSubroutineCall<'a>),
|
||||||
LetExpression(LetExpression<'a>),
|
LetExpression(LetExpression<'a>),
|
||||||
MintypmaxExpression(MintypmaxExpression<'a>),
|
MintypmaxExpression(PrimaryMintypmaxExpression<'a>),
|
||||||
Cast(Cast<'a>),
|
Cast(Cast<'a>),
|
||||||
AssignmentPatternExpression(AssignmentPatternExpression<'a>),
|
AssignmentPatternExpression(AssignmentPatternExpression<'a>),
|
||||||
StreamingConcatenation(StreamingConcatenation<'a>),
|
StreamingConcatenation(StreamingConcatenation<'a>),
|
||||||
SequenceMethodCall(SequenceMethodCall<'a>),
|
SequenceMethodCall(SequenceMethodCall<'a>),
|
||||||
This(This<'a>),
|
This(Symbol<'a>),
|
||||||
Dollar(Dollar<'a>),
|
Dollar(Symbol<'a>),
|
||||||
Null(Null<'a>),
|
Null(Symbol<'a>),
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct This<'a> {
|
|
||||||
pub nodes: (Symbol<'a>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Dollar<'a> {
|
|
||||||
pub nodes: (Symbol<'a>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Null<'a> {
|
|
||||||
pub nodes: (Symbol<'a>,),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PrimaryHierarchical<'a> {
|
pub struct PrimaryHierarchical<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
Option<PrimaryHierarchicalQualifier<'a>>,
|
Option<ClassQualifierOrPackageScope<'a>>,
|
||||||
HierarchicalIdentifier<'a>,
|
HierarchicalIdentifier<'a>,
|
||||||
Select<'a>,
|
Select<'a>,
|
||||||
),
|
),
|
||||||
@ -117,27 +114,43 @@ pub struct PrimaryHierarchical<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PrimaryConcatenation<'a> {
|
pub struct PrimaryConcatenation<'a> {
|
||||||
pub nodes: (Concatenation<'a>, Option<RangeExpression<'a>>),
|
pub nodes: (
|
||||||
|
Concatenation<'a>,
|
||||||
|
Option<(Symbol<'a>, RangeExpression<'a>, Symbol<'a>)>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PrimaryMultipleConcatenation<'a> {
|
pub struct PrimaryMultipleConcatenation<'a> {
|
||||||
pub nodes: (MultipleConcatenation<'a>, Option<RangeExpression<'a>>),
|
pub nodes: (
|
||||||
|
MultipleConcatenation<'a>,
|
||||||
|
Option<(Symbol<'a>, RangeExpression<'a>, Symbol<'a>)>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum PrimaryHierarchicalQualifier<'a> {
|
pub struct PrimaryMintypmaxExpression<'a> {
|
||||||
|
pub nodes: (Symbol<'a>, MintypmaxExpression<'a>, Symbol<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum ClassQualifierOrPackageScope<'a> {
|
||||||
ClassQualifier(ClassQualifier<'a>),
|
ClassQualifier(ClassQualifier<'a>),
|
||||||
PackageScope(PackageScope<'a>),
|
PackageScope(PackageScope<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ClassQualifier<'a> {
|
pub struct ClassQualifier<'a> {
|
||||||
pub nodes: (Option<Local>, Option<ImplicitClassHandleOrClassScope<'a>>),
|
pub nodes: (
|
||||||
|
Option<Local<'a>>,
|
||||||
|
Option<ImplicitClassHandleOrClassScope<'a>>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Local {}
|
pub struct Local<'a> {
|
||||||
|
pub nodes: (Symbol<'a>,),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum RangeExpression<'a> {
|
pub enum RangeExpression<'a> {
|
||||||
@ -155,8 +168,18 @@ pub enum PrimaryLiteral<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum TimeLiteral<'a> {
|
pub enum TimeLiteral<'a> {
|
||||||
UnsignedTimeLiteral(UnsignedTimeLiteral<'a>),
|
Unsigned(TimeLiteralUnsigned<'a>),
|
||||||
FixedPointTimeLiteral(FixedPointTimeLiteral<'a>),
|
FixedPoint(TimeLiteralFixedPoint<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct TimeLiteralUnsigned<'a> {
|
||||||
|
pub nodes: (UnsignedNumber<'a>, TimeUnit<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct TimeLiteralFixedPoint<'a> {
|
||||||
|
pub nodes: (FixedPointNumber<'a>, TimeUnit<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -170,155 +193,177 @@ pub enum TimeUnit<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ImplicitClassHandle {
|
pub enum ImplicitClassHandle<'a> {
|
||||||
This,
|
This(Symbol<'a>),
|
||||||
Super,
|
Super(Symbol<'a>),
|
||||||
ThisSuper,
|
ThisSuper((Symbol<'a>, Symbol<'a>, Symbol<'a>)),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BitSelect<'a> {
|
pub struct BitSelect<'a> {
|
||||||
nodes: (Vec<Expression<'a>>,),
|
nodes: (Vec<(Symbol<'a>, Expression<'a>, Symbol<'a>)>,),
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct UnsignedTimeLiteral<'a> {
|
|
||||||
pub nodes: (UnsignedNumber<'a>, TimeUnit<'a>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct FixedPointTimeLiteral<'a> {
|
|
||||||
pub nodes: (FixedPointNumber<'a>, TimeUnit<'a>),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Select<'a> {
|
pub struct Select<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
Option<SelectMember<'a>>,
|
Option<(
|
||||||
|
Vec<(Symbol<'a>, MemberIdentifier<'a>, BitSelect<'a>)>,
|
||||||
|
Symbol<'a>,
|
||||||
|
MemberIdentifier<'a>,
|
||||||
|
)>,
|
||||||
|
BitSelect<'a>,
|
||||||
|
Option<(Symbol<'a>, PartSelectRange<'a>, Symbol<'a>)>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct NonrangeSelect<'a> {
|
||||||
|
pub nodes: (
|
||||||
|
Option<(
|
||||||
|
Vec<(Symbol<'a>, MemberIdentifier<'a>, BitSelect<'a>)>,
|
||||||
|
Symbol<'a>,
|
||||||
|
MemberIdentifier<'a>,
|
||||||
|
)>,
|
||||||
BitSelect<'a>,
|
BitSelect<'a>,
|
||||||
Option<PartSelectRange<'a>>,
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ConstantBitSelect<'a> {
|
pub struct ConstantBitSelect<'a> {
|
||||||
nodes: (Vec<ConstantExpression<'a>>,),
|
nodes: (Vec<(Symbol<'a>, ConstantExpression<'a>, Symbol<'a>)>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ConstantSelect<'a> {
|
pub struct ConstantSelect<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
Option<SelectMember<'a>>,
|
Option<(
|
||||||
|
Vec<(Symbol<'a>, MemberIdentifier<'a>, ConstantBitSelect<'a>)>,
|
||||||
|
Symbol<'a>,
|
||||||
|
MemberIdentifier<'a>,
|
||||||
|
)>,
|
||||||
ConstantBitSelect<'a>,
|
ConstantBitSelect<'a>,
|
||||||
Option<ConstantPartSelectRange<'a>>,
|
Option<(Symbol<'a>, ConstantPartSelectRange<'a>, Symbol<'a>)>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct SelectMember<'a> {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<(MemberIdentifier<'a>, BitSelect<'a>)>,
|
|
||||||
MemberIdentifier<'a>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Cast<'a> {
|
|
||||||
pub nodes: (CastingType<'a>, Expression<'a>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ConstantCast<'a> {
|
pub struct ConstantCast<'a> {
|
||||||
pub nodes: (CastingType<'a>, ConstantExpression<'a>),
|
pub nodes: (
|
||||||
|
CastingType<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
ConstantExpression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ConstantLetExpression<'a> {
|
||||||
|
pub nodes: (LetExpression<'a>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Cast<'a> {
|
||||||
|
pub nodes: (
|
||||||
|
CastingType<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Expression<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn constant_primary(s: Span) -> IResult<Span, ConstantPrimary> {
|
pub fn constant_primary(s: Span) -> IResult<Span, ConstantPrimary> {
|
||||||
alt((
|
alt((
|
||||||
map(symbol("null"), |_| ConstantPrimary::Null),
|
|
||||||
map(primary_literal, |x| ConstantPrimary::PrimaryLiteral(x)),
|
map(primary_literal, |x| ConstantPrimary::PrimaryLiteral(x)),
|
||||||
constant_primary_ps_parameter,
|
constant_primary_ps_parameter,
|
||||||
constant_primary_specparam,
|
constant_primary_specparam,
|
||||||
map(genvar_identifier, |x| ConstantPrimary::Genvar(x)),
|
map(genvar_identifier, |x| ConstantPrimary::GenvarIdentifier(x)),
|
||||||
constant_primary_formal_port,
|
constant_primary_formal_port,
|
||||||
constant_primary_enum,
|
constant_primary_enum,
|
||||||
constant_primary_concatenation,
|
constant_primary_concatenation,
|
||||||
constant_primary_multiple_concatenation,
|
constant_primary_multiple_concatenation,
|
||||||
map(constant_function_call, |x| ConstantPrimary::FunctionCall(x)),
|
map(constant_function_call, |x| {
|
||||||
|
ConstantPrimary::ConstantFunctionCall(x)
|
||||||
|
}),
|
||||||
map(constant_let_expression, |x| {
|
map(constant_let_expression, |x| {
|
||||||
ConstantPrimary::LetExpression(x)
|
ConstantPrimary::ConstantLetExpression(x)
|
||||||
}),
|
}),
|
||||||
map(paren(constant_mintypmax_expression), |x| {
|
constant_primary_mintypmax_expression,
|
||||||
ConstantPrimary::MintypmaxExpression(x)
|
map(constant_cast, |x| ConstantPrimary::ConstantCast(x)),
|
||||||
}),
|
|
||||||
map(constant_cast, |x| ConstantPrimary::Cast(x)),
|
|
||||||
map(constant_assignment_pattern_expression, |x| {
|
map(constant_assignment_pattern_expression, |x| {
|
||||||
ConstantPrimary::AssignmentPatternExpression(x)
|
ConstantPrimary::ConstantAssignmentPatternExpression(x)
|
||||||
}),
|
}),
|
||||||
map(type_reference, |x| ConstantPrimary::TypeReference(x)),
|
map(type_reference, |x| ConstantPrimary::TypeReference(x)),
|
||||||
|
map(symbol("null"), |x| ConstantPrimary::Null(x)),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_primary_ps_parameter(s: Span) -> IResult<Span, ConstantPrimary> {
|
pub fn constant_primary_ps_parameter(s: Span) -> IResult<Span, ConstantPrimary> {
|
||||||
let (s, x) = ps_parameter_identifier(s)?;
|
let (s, a) = ps_parameter_identifier(s)?;
|
||||||
let (s, y) = constant_select(s)?;
|
let (s, b) = constant_select(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ConstantPrimary::PsParameter(ConstantPrimaryPsParameter { nodes: (x, y) }),
|
ConstantPrimary::PsParameter(ConstantPrimaryPsParameter { nodes: (a, b) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_primary_specparam(s: Span) -> IResult<Span, ConstantPrimary> {
|
pub fn constant_primary_specparam(s: Span) -> IResult<Span, ConstantPrimary> {
|
||||||
let (s, x) = specparam_identifier(s)?;
|
let (s, a) = specparam_identifier(s)?;
|
||||||
let (s, y) = opt(bracket(constant_range_expression))(s)?;
|
let (s, b) = opt(bracket2(constant_range_expression))(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ConstantPrimary::Specparam(ConstantPrimarySpecparam { nodes: (x, y) }),
|
ConstantPrimary::Specparam(ConstantPrimarySpecparam { nodes: (a, b) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_primary_formal_port(s: Span) -> IResult<Span, ConstantPrimary> {
|
pub fn constant_primary_formal_port(s: Span) -> IResult<Span, ConstantPrimary> {
|
||||||
let (s, x) = formal_port_identifier(s)?;
|
let (s, a) = formal_port_identifier(s)?;
|
||||||
let (s, y) = constant_select(s)?;
|
let (s, b) = constant_select(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ConstantPrimary::FormalPort(ConstantPrimaryFormalPort { nodes: (x, y) }),
|
ConstantPrimary::FormalPort(ConstantPrimaryFormalPort { nodes: (a, b) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_primary_enum(s: Span) -> IResult<Span, ConstantPrimary> {
|
pub fn constant_primary_enum(s: Span) -> IResult<Span, ConstantPrimary> {
|
||||||
let (s, x) = package_scope_or_class_scope(s)?;
|
let (s, a) = package_scope_or_class_scope(s)?;
|
||||||
let (s, y) = enum_identifier(s)?;
|
let (s, b) = enum_identifier(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ConstantPrimary::Enum(ConstantPrimaryEnum { nodes: (x, y) }),
|
ConstantPrimary::Enum(ConstantPrimaryEnum { nodes: (a, b) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_primary_concatenation(s: Span) -> IResult<Span, ConstantPrimary> {
|
pub fn constant_primary_concatenation(s: Span) -> IResult<Span, ConstantPrimary> {
|
||||||
let (s, x) = constant_concatenation(s)?;
|
let (s, a) = constant_concatenation(s)?;
|
||||||
let (s, y) = opt(bracket(constant_range_expression))(s)?;
|
let (s, b) = opt(bracket2(constant_range_expression))(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ConstantPrimary::Concatenation(ConstantPrimaryConcatenation { nodes: (x, y) }),
|
ConstantPrimary::Concatenation(ConstantPrimaryConcatenation { nodes: (a, b) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_primary_multiple_concatenation(s: Span) -> IResult<Span, ConstantPrimary> {
|
pub fn constant_primary_multiple_concatenation(s: Span) -> IResult<Span, ConstantPrimary> {
|
||||||
let (s, x) = constant_multiple_concatenation(s)?;
|
let (s, a) = constant_multiple_concatenation(s)?;
|
||||||
let (s, y) = opt(bracket(constant_range_expression))(s)?;
|
let (s, b) = opt(bracket2(constant_range_expression))(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ConstantPrimary::MultipleConcatenation(ConstantPrimaryMultipleConcatenation {
|
ConstantPrimary::MultipleConcatenation(ConstantPrimaryMultipleConcatenation {
|
||||||
nodes: (x, y),
|
nodes: (a, b),
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_primary_mintypmax_expression(s: Span) -> IResult<Span, ConstantPrimary> {
|
pub fn constant_primary_mintypmax_expression(s: Span) -> IResult<Span, ConstantPrimary> {
|
||||||
let (s, x) = paren(constant_mintypmax_expression)(s)?;
|
let (s, a) = paren2(constant_mintypmax_expression)(s)?;
|
||||||
Ok((s, ConstantPrimary::MintypmaxExpression(x)))
|
Ok((
|
||||||
|
s,
|
||||||
|
ConstantPrimary::MintypmaxExpression(ConstantPrimaryMintypmaxExpression { nodes: a }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn module_path_primary(s: Span) -> IResult<Span, ModulePathPrimary> {
|
pub fn module_path_primary(s: Span) -> IResult<Span, ModulePathPrimary> {
|
||||||
@ -334,27 +379,31 @@ pub fn module_path_primary(s: Span) -> IResult<Span, ModulePathPrimary> {
|
|||||||
map(function_subroutine_call, |x| {
|
map(function_subroutine_call, |x| {
|
||||||
ModulePathPrimary::FunctionSubroutineCall(x)
|
ModulePathPrimary::FunctionSubroutineCall(x)
|
||||||
}),
|
}),
|
||||||
map(paren(module_path_mintypmax_expression), |x| {
|
module_path_primary_mintypmax_expression,
|
||||||
ModulePathPrimary::ModulePathMintypmaxExpression(x)
|
|
||||||
}),
|
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn module_path_primary_mintypmax_expression(s: Span) -> IResult<Span, ModulePathPrimary> {
|
||||||
|
let (s, a) = paren2(module_path_mintypmax_expression)(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ModulePathPrimary::Mintypmax(ModulePathPrimaryMintypmax { nodes: a }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn primary(s: Span) -> IResult<Span, Primary> {
|
pub fn primary(s: Span) -> IResult<Span, Primary> {
|
||||||
alt((
|
alt((
|
||||||
map(primary_literal, |x| Primary::PrimaryLiteral(x)),
|
map(primary_literal, |x| Primary::PrimaryLiteral(x)),
|
||||||
primary_hierarchical,
|
primary_hierarchical,
|
||||||
map(empty_unpacked_array_concatenation, |_| {
|
map(empty_unpacked_array_concatenation, |x| {
|
||||||
Primary::EmptyUnpackedArrayConcatenation
|
Primary::EmptyUnpackedArrayConcatenation(x)
|
||||||
}),
|
}),
|
||||||
primary_concatenation,
|
primary_concatenation,
|
||||||
map(rec(function_subroutine_call, REC_PRIMARY), |x| {
|
map(rec(function_subroutine_call, REC_PRIMARY), |x| {
|
||||||
Primary::FunctionSubroutineCall(x)
|
Primary::FunctionSubroutineCall(x)
|
||||||
}),
|
}),
|
||||||
map(let_expression, |x| Primary::LetExpression(x)),
|
map(let_expression, |x| Primary::LetExpression(x)),
|
||||||
map(paren(mintypmax_expression), |x| {
|
primary_mintypmax_expression,
|
||||||
Primary::MintypmaxExpression(x)
|
|
||||||
}),
|
|
||||||
map(cast, |x| Primary::Cast(x)),
|
map(cast, |x| Primary::Cast(x)),
|
||||||
map(assignment_pattern_expression, |x| {
|
map(assignment_pattern_expression, |x| {
|
||||||
Primary::AssignmentPatternExpression(x)
|
Primary::AssignmentPatternExpression(x)
|
||||||
@ -363,58 +412,66 @@ pub fn primary(s: Span) -> IResult<Span, Primary> {
|
|||||||
Primary::StreamingConcatenation(x)
|
Primary::StreamingConcatenation(x)
|
||||||
}),
|
}),
|
||||||
map(sequence_method_call, |x| Primary::SequenceMethodCall(x)),
|
map(sequence_method_call, |x| Primary::SequenceMethodCall(x)),
|
||||||
map(symbol("this"), |x| Primary::This(This { nodes: (x,) })),
|
map(symbol("this"), |x| Primary::This(x)),
|
||||||
map(symbol("$"), |x| Primary::Dollar(Dollar { nodes: (x,) })),
|
map(symbol("$"), |x| Primary::Dollar(x)),
|
||||||
map(symbol("null"), |x| Primary::Null(Null { nodes: (x,) })),
|
map(symbol("null"), |x| Primary::Null(x)),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn primary_hierarchical(s: Span) -> IResult<Span, Primary> {
|
pub fn primary_hierarchical(s: Span) -> IResult<Span, Primary> {
|
||||||
let (s, x) = opt(primary_hierarchical_qualifier)(s)?;
|
let (s, a) = opt(class_qualifier_or_package_scope)(s)?;
|
||||||
let (s, y) = hierarchical_identifier(s)?;
|
let (s, b) = hierarchical_identifier(s)?;
|
||||||
let (s, z) = select(s)?;
|
let (s, c) = select(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
Primary::Hierarchical(PrimaryHierarchical { nodes: (x, y, z) }),
|
Primary::Hierarchical(PrimaryHierarchical { nodes: (a, b, c) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn primary_concatenation(s: Span) -> IResult<Span, Primary> {
|
pub fn primary_concatenation(s: Span) -> IResult<Span, Primary> {
|
||||||
let (s, x) = concatenation(s)?;
|
let (s, a) = concatenation(s)?;
|
||||||
let (s, y) = opt(range_expression)(s)?;
|
let (s, b) = opt(bracket2(range_expression))(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
Primary::Concatenation(PrimaryConcatenation { nodes: (x, y) }),
|
Primary::Concatenation(PrimaryConcatenation { nodes: (a, b) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn primary_multiple_concatenation(s: Span) -> IResult<Span, Primary> {
|
pub fn primary_multiple_concatenation(s: Span) -> IResult<Span, Primary> {
|
||||||
let (s, x) = multiple_concatenation(s)?;
|
let (s, a) = multiple_concatenation(s)?;
|
||||||
let (s, y) = opt(range_expression)(s)?;
|
let (s, b) = opt(bracket2(range_expression))(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
Primary::MultipleConcatenation(PrimaryMultipleConcatenation { nodes: (x, y) }),
|
Primary::MultipleConcatenation(PrimaryMultipleConcatenation { nodes: (a, b) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn primary_hierarchical_qualifier(s: Span) -> IResult<Span, PrimaryHierarchicalQualifier> {
|
pub fn primary_mintypmax_expression(s: Span) -> IResult<Span, Primary> {
|
||||||
|
let (s, a) = paren2(mintypmax_expression)(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
Primary::MintypmaxExpression(PrimaryMintypmaxExpression { nodes: a }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_qualifier_or_package_scope(s: Span) -> IResult<Span, ClassQualifierOrPackageScope> {
|
||||||
alt((
|
alt((
|
||||||
map(class_qualifier, |x| {
|
map(class_qualifier, |x| {
|
||||||
PrimaryHierarchicalQualifier::ClassQualifier(x)
|
ClassQualifierOrPackageScope::ClassQualifier(x)
|
||||||
}),
|
}),
|
||||||
map(package_scope, |x| {
|
map(package_scope, |x| {
|
||||||
PrimaryHierarchicalQualifier::PackageScope(x)
|
ClassQualifierOrPackageScope::PackageScope(x)
|
||||||
}),
|
}),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn class_qualifier(s: Span) -> IResult<Span, ClassQualifier> {
|
pub fn class_qualifier(s: Span) -> IResult<Span, ClassQualifier> {
|
||||||
let (s, x) = opt(symbol("local::"))(s)?;
|
let (s, a) = opt(symbol("local::"))(s)?;
|
||||||
let (s, y) = opt(implicit_class_handle_or_class_scope)(s)?;
|
let (s, b) = opt(implicit_class_handle_or_class_scope)(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ClassQualifier {
|
ClassQualifier {
|
||||||
nodes: (x.map(|_| Local {}), y),
|
nodes: (a.map(|x| Local { nodes: (x,) }), b),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -438,24 +495,24 @@ pub fn primary_literal(s: Span) -> IResult<Span, PrimaryLiteral> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn time_literal(s: Span) -> IResult<Span, TimeLiteral> {
|
pub fn time_literal(s: Span) -> IResult<Span, TimeLiteral> {
|
||||||
alt((unsigned_time_literal, fixed_point_time_literal))(s)
|
alt((time_literal_unsigned, time_literal_fixed_point))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unsigned_time_literal(s: Span) -> IResult<Span, TimeLiteral> {
|
pub fn time_literal_unsigned(s: Span) -> IResult<Span, TimeLiteral> {
|
||||||
let (s, x) = unsigned_number(s)?;
|
let (s, a) = unsigned_number(s)?;
|
||||||
let (s, y) = time_unit(s)?;
|
let (s, b) = time_unit(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
TimeLiteral::UnsignedTimeLiteral(UnsignedTimeLiteral { nodes: (x, y) }),
|
TimeLiteral::Unsigned(TimeLiteralUnsigned { nodes: (a, b) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fixed_point_time_literal(s: Span) -> IResult<Span, TimeLiteral> {
|
pub fn time_literal_fixed_point(s: Span) -> IResult<Span, TimeLiteral> {
|
||||||
let (s, x) = fixed_point_number(s)?;
|
let (s, a) = fixed_point_number(s)?;
|
||||||
let (s, y) = time_unit(s)?;
|
let (s, b) = time_unit(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
TimeLiteral::FixedPointTimeLiteral(FixedPointTimeLiteral { nodes: (x, y) }),
|
TimeLiteral::FixedPoint(TimeLiteralFixedPoint { nodes: (a, b) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,95 +530,83 @@ pub fn time_unit(s: Span) -> IResult<Span, TimeUnit> {
|
|||||||
pub fn implicit_class_handle(s: Span) -> IResult<Span, ImplicitClassHandle> {
|
pub fn implicit_class_handle(s: Span) -> IResult<Span, ImplicitClassHandle> {
|
||||||
alt((
|
alt((
|
||||||
map(
|
map(
|
||||||
tuple((symbol("this"), symbol("."), symbol("super"))),
|
triple(symbol("this"), symbol("."), symbol("super")),
|
||||||
|_| ImplicitClassHandle::ThisSuper,
|
|(x, y, z)| ImplicitClassHandle::ThisSuper((x, y, z)),
|
||||||
),
|
),
|
||||||
map(symbol("this"), |_| ImplicitClassHandle::This),
|
map(symbol("this"), |x| ImplicitClassHandle::This(x)),
|
||||||
map(symbol("super"), |_| ImplicitClassHandle::Super),
|
map(symbol("super"), |x| ImplicitClassHandle::Super(x)),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bit_select(s: Span) -> IResult<Span, BitSelect> {
|
pub fn bit_select(s: Span) -> IResult<Span, BitSelect> {
|
||||||
let (s, x) = many0(bracket(expression))(s)?;
|
let (s, a) = many0(bracket2(expression))(s)?;
|
||||||
Ok((s, BitSelect { nodes: (x,) }))
|
Ok((s, BitSelect { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn select(s: Span) -> IResult<Span, Select> {
|
pub fn select(s: Span) -> IResult<Span, Select> {
|
||||||
let (s, x) = opt(pair(
|
let (s, a) = opt(triple(
|
||||||
many0(preceded(symbol("."), pair(member_identifier, bit_select))),
|
many0(triple(symbol("."), member_identifier, bit_select)),
|
||||||
preceded(symbol("."), member_identifier),
|
symbol("."),
|
||||||
|
member_identifier,
|
||||||
))(s)?;
|
))(s)?;
|
||||||
let (s, y) = bit_select(s)?;
|
let (s, b) = bit_select(s)?;
|
||||||
let (s, z) = opt(bracket(part_select_range))(s)?;
|
let (s, c) = opt(bracket2(part_select_range))(s)?;
|
||||||
|
Ok((s, Select { nodes: (a, b, c) }))
|
||||||
let x = if let Some((x, y)) = x {
|
|
||||||
Some(SelectMember { nodes: (x, y) })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok((s, Select { nodes: (x, y, z) }))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn nonrange_select(s: Span) -> IResult<Span, Select> {
|
pub fn nonrange_select(s: Span) -> IResult<Span, NonrangeSelect> {
|
||||||
let (s, x) = opt(pair(
|
let (s, a) = opt(triple(
|
||||||
many0(preceded(symbol("."), pair(member_identifier, bit_select))),
|
many0(triple(symbol("."), member_identifier, bit_select)),
|
||||||
preceded(symbol("."), member_identifier),
|
symbol("."),
|
||||||
|
member_identifier,
|
||||||
))(s)?;
|
))(s)?;
|
||||||
let (s, y) = bit_select(s)?;
|
let (s, b) = bit_select(s)?;
|
||||||
|
Ok((s, NonrangeSelect { nodes: (a, b) }))
|
||||||
|
}
|
||||||
|
|
||||||
let x = if let Some((x, y)) = x {
|
pub fn constant_bit_select(s: Span) -> IResult<Span, ConstantBitSelect> {
|
||||||
Some(SelectMember { nodes: (x, y) })
|
let (s, a) = many0(bracket2(constant_expression))(s)?;
|
||||||
} else {
|
Ok((s, ConstantBitSelect { nodes: (a,) }))
|
||||||
None
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
pub fn constant_select(s: Span) -> IResult<Span, ConstantSelect> {
|
||||||
|
let (s, a) = opt(triple(
|
||||||
|
many0(triple(symbol("."), member_identifier, constant_bit_select)),
|
||||||
|
symbol("."),
|
||||||
|
member_identifier,
|
||||||
|
))(s)?;
|
||||||
|
let (s, b) = constant_bit_select(s)?;
|
||||||
|
let (s, c) = opt(bracket2(constant_part_select_range))(s)?;
|
||||||
|
Ok((s, ConstantSelect { nodes: (a, b, c) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn constant_cast(s: Span) -> IResult<Span, ConstantCast> {
|
||||||
|
let (s, a) = casting_type(s)?;
|
||||||
|
let (s, b) = symbol("'")(s)?;
|
||||||
|
let (s, (c, d, e)) = paren2(constant_expression)(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
Select {
|
ConstantCast {
|
||||||
nodes: (x, y, None),
|
nodes: (a, b, c, d, e),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_bit_select(s: Span) -> IResult<Span, ConstantBitSelect> {
|
pub fn constant_let_expression(s: Span) -> IResult<Span, ConstantLetExpression> {
|
||||||
let (s, x) = many0(bracket(constant_expression))(s)?;
|
let (s, a) = let_expression(s)?;
|
||||||
Ok((s, ConstantBitSelect { nodes: (x,) }))
|
Ok((s, ConstantLetExpression { nodes: (a,) }))
|
||||||
}
|
|
||||||
|
|
||||||
pub fn constant_select(s: Span) -> IResult<Span, ConstantSelect> {
|
|
||||||
let (s, x) = opt(pair(
|
|
||||||
many0(preceded(symbol("."), pair(member_identifier, bit_select))),
|
|
||||||
preceded(symbol("."), member_identifier),
|
|
||||||
))(s)?;
|
|
||||||
let (s, y) = constant_bit_select(s)?;
|
|
||||||
let (s, z) = opt(bracket(constant_part_select_range))(s)?;
|
|
||||||
|
|
||||||
let x = if let Some((x, y)) = x {
|
|
||||||
Some(SelectMember { nodes: (x, y) })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok((s, ConstantSelect { nodes: (x, y, z) }))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn constant_cast(s: Span) -> IResult<Span, ConstantCast> {
|
|
||||||
let (s, x) = casting_type(s)?;
|
|
||||||
let (s, _) = symbol("'")(s)?;
|
|
||||||
let (s, y) = paren(constant_expression)(s)?;
|
|
||||||
Ok((s, ConstantCast { nodes: (x, y) }))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn constant_let_expression(s: Span) -> IResult<Span, LetExpression> {
|
|
||||||
let_expression(s)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cast(s: Span) -> IResult<Span, Cast> {
|
pub fn cast(s: Span) -> IResult<Span, Cast> {
|
||||||
let (s, x) = casting_type(s)?;
|
let (s, a) = casting_type(s)?;
|
||||||
let (s, _) = symbol("'")(s)?;
|
let (s, b) = symbol("'")(s)?;
|
||||||
let (s, y) = paren(expression)(s)?;
|
let (s, (c, d, e)) = paren2(expression)(s)?;
|
||||||
Ok((s, Cast { nodes: (x, y) }))
|
Ok((
|
||||||
|
s,
|
||||||
|
Cast {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -20,12 +20,12 @@ pub fn string_literal(s: Span) -> IResult<Span, StringLiteral> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn string_literal_impl(s: Span) -> IResult<Span, Span> {
|
pub fn string_literal_impl(s: Span) -> IResult<Span, Span> {
|
||||||
let (s, _) = tag("\"")(s)?;
|
let (s, a) = tag("\"")(s)?;
|
||||||
let (s, x) = many1(pair(is_not("\\\""), opt(pair(tag("\\"), take(1usize)))))(s)?;
|
let (s, b) = many1(pair(is_not("\\\""), opt(pair(tag("\\"), take(1usize)))))(s)?;
|
||||||
let (s, _) = tag("\"")(s)?;
|
let (s, c) = tag("\"")(s)?;
|
||||||
|
|
||||||
let mut ret = None;
|
let mut ret = None;
|
||||||
for (x, y) in x {
|
for (x, y) in b {
|
||||||
ret = if let Some(ret) = ret {
|
ret = if let Some(ret) = ret {
|
||||||
Some(concat(ret, x).unwrap())
|
Some(concat(ret, x).unwrap())
|
||||||
} else {
|
} else {
|
||||||
@ -45,9 +45,11 @@ pub fn string_literal_impl(s: Span) -> IResult<Span, Span> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let ret = ret.unwrap();
|
let b = ret.unwrap();
|
||||||
|
let a = concat(a, b).unwrap();
|
||||||
|
let a = concat(a, c).unwrap();
|
||||||
|
|
||||||
Ok((s, ret))
|
Ok((s, a))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -7,6 +7,11 @@ use nom::IResult;
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ConstantFunctionCall<'a> {
|
||||||
|
pub nodes: (FunctionSubroutineCall<'a>,),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TfCall<'a> {
|
pub struct TfCall<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
@ -36,6 +41,11 @@ pub enum SubroutineCall<'a> {
|
|||||||
StdRandomize(Box<RandomizeCall<'a>>),
|
StdRandomize(Box<RandomizeCall<'a>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct FunctionSubroutineCall<'a> {
|
||||||
|
pub nodes: (SubroutineCall<'a>,),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ListOfArguments<'a> {
|
pub struct ListOfArguments<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
@ -49,17 +59,10 @@ pub struct MethodCall<'a> {
|
|||||||
pub nodes: (MethodCallRoot<'a>, MethodCallBody<'a>),
|
pub nodes: (MethodCallRoot<'a>, MethodCallBody<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum MethodCallRoot<'a> {
|
|
||||||
Primary(Primary<'a>),
|
|
||||||
ImplicitClassHandle(ImplicitClassHandle),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum MethodCallBody<'a> {
|
pub enum MethodCallBody<'a> {
|
||||||
User(MethodCallBodyUser<'a>),
|
User(MethodCallBodyUser<'a>),
|
||||||
Array(ArrayManipulationCall<'a>),
|
BuiltInMethodCall(BuiltInMethodCall<'a>),
|
||||||
Randomize(RandomizeCall<'a>),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -71,6 +74,12 @@ pub struct MethodCallBodyUser<'a> {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum BuiltInMethodCall<'a> {
|
||||||
|
ArrayManipulationCall(ArrayManipulationCall<'a>),
|
||||||
|
RandomizeCall(RandomizeCall<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ArrayManipulationCall<'a> {
|
pub struct ArrayManipulationCall<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
@ -91,6 +100,12 @@ pub struct RandomizeCall<'a> {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum MethodCallRoot<'a> {
|
||||||
|
Primary(Primary<'a>),
|
||||||
|
ImplicitClassHandle(ImplicitClassHandle<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ArrayMethodName<'a> {
|
pub enum ArrayMethodName<'a> {
|
||||||
MethodIdentifier(MethodIdentifier<'a>),
|
MethodIdentifier(MethodIdentifier<'a>),
|
||||||
@ -102,8 +117,9 @@ pub enum ArrayMethodName<'a> {
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn constant_function_call(s: Span) -> IResult<Span, SubroutineCall> {
|
pub fn constant_function_call(s: Span) -> IResult<Span, ConstantFunctionCall> {
|
||||||
function_subroutine_call(s)
|
let (s, a) = function_subroutine_call(s)?;
|
||||||
|
Ok((s, ConstantFunctionCall { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tf_call(s: Span) -> IResult<Span, TfCall> {
|
pub fn tf_call(s: Span) -> IResult<Span, TfCall> {
|
||||||
@ -167,15 +183,15 @@ pub fn subroutine_call(s: Span) -> IResult<Span, SubroutineCall> {
|
|||||||
map(system_tf_call, |x| SubroutineCall::SystemTf(Box::new(x))),
|
map(system_tf_call, |x| SubroutineCall::SystemTf(Box::new(x))),
|
||||||
map(method_call, |x| SubroutineCall::Method(Box::new(x))),
|
map(method_call, |x| SubroutineCall::Method(Box::new(x))),
|
||||||
map(
|
map(
|
||||||
tuple((symbol("std"), symbol("::"), randomize_call)),
|
triple(symbol("std"), symbol("::"), randomize_call),
|
||||||
|(_, _, x)| SubroutineCall::StdRandomize(Box::new(x)),
|
|(_, _, x)| SubroutineCall::StdRandomize(Box::new(x)),
|
||||||
),
|
),
|
||||||
map(randomize_call, |x| SubroutineCall::Randomize(Box::new(x))),
|
map(randomize_call, |x| SubroutineCall::Randomize(Box::new(x))),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn function_subroutine_call(s: Span) -> IResult<Span, SubroutineCall> {
|
pub fn function_subroutine_call(s: Span) -> IResult<Span, FunctionSubroutineCall> {
|
||||||
subroutine_call(s)
|
map(subroutine_call, |x| FunctionSubroutineCall { nodes: (x,) })(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_arguments(s: Span) -> IResult<Span, ListOfArguments> {
|
pub fn list_of_arguments(s: Span) -> IResult<Span, ListOfArguments> {
|
||||||
@ -196,7 +212,12 @@ pub fn method_call(s: Span) -> IResult<Span, MethodCall> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn method_call_body(s: Span) -> IResult<Span, MethodCallBody> {
|
pub fn method_call_body(s: Span) -> IResult<Span, MethodCallBody> {
|
||||||
alt((method_call_body_user, built_in_method_call))(s)
|
alt((
|
||||||
|
method_call_body_user,
|
||||||
|
map(built_in_method_call, |x| {
|
||||||
|
MethodCallBody::BuiltInMethodCall(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn method_call_body_user(s: Span) -> IResult<Span, MethodCallBody> {
|
pub fn method_call_body_user(s: Span) -> IResult<Span, MethodCallBody> {
|
||||||
@ -209,10 +230,12 @@ pub fn method_call_body_user(s: Span) -> IResult<Span, MethodCallBody> {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn built_in_method_call(s: Span) -> IResult<Span, MethodCallBody> {
|
pub fn built_in_method_call(s: Span) -> IResult<Span, BuiltInMethodCall> {
|
||||||
alt((
|
alt((
|
||||||
map(array_manipulation_call, |x| MethodCallBody::Array(x)),
|
map(array_manipulation_call, |x| {
|
||||||
map(randomize_call, |x| MethodCallBody::Randomize(x)),
|
BuiltInMethodCall::ArrayManipulationCall(x)
|
||||||
|
}),
|
||||||
|
map(randomize_call, |x| BuiltInMethodCall::RandomizeCall(x)),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,11 +261,11 @@ pub fn randomize_call(s: Span) -> IResult<Span, RandomizeCall> {
|
|||||||
nodes: (vec![],),
|
nodes: (vec![],),
|
||||||
}),
|
}),
|
||||||
)))))(s)?;
|
)))))(s)?;
|
||||||
let (s, z) = opt(tuple((
|
let (s, z) = opt(triple(
|
||||||
symbol("with"),
|
symbol("with"),
|
||||||
opt(paren(opt(identifier_list))),
|
opt(paren(opt(identifier_list))),
|
||||||
constraint_block,
|
constraint_block,
|
||||||
)))(s)?;
|
))(s)?;
|
||||||
let y = if let Some(Some(y)) = y {
|
let y = if let Some(Some(y)) = y {
|
||||||
y
|
y
|
||||||
} else {
|
} else {
|
||||||
|
@ -8,27 +8,38 @@ use nom::IResult;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AttributeInstance<'a> {
|
pub struct AttributeInstance<'a> {
|
||||||
pub nodes: (Vec<AttrSpec<'a>>,),
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
AttrSpec<'a>,
|
||||||
|
Vec<(Symbol<'a>, AttrSpec<'a>)>,
|
||||||
|
Symbol<'a>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AttrSpec<'a> {
|
pub struct AttrSpec<'a> {
|
||||||
pub nodes: (Identifier<'a>, Option<ConstantExpression<'a>>),
|
pub nodes: (Identifier<'a>, Option<(Symbol<'a>, ConstantExpression<'a>)>),
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn attribute_instance(s: Span) -> IResult<Span, AttributeInstance> {
|
pub fn attribute_instance(s: Span) -> IResult<Span, AttributeInstance> {
|
||||||
let (s, _) = symbol("(*")(s)?;
|
let (s, a) = symbol("(*")(s)?;
|
||||||
let (s, x) = separated_nonempty_list(symbol(","), attr_spec)(s)?;
|
let (s, b) = attr_spec(s)?;
|
||||||
let (s, _) = symbol("*)")(s)?;
|
let (s, c) = many0(pair(symbol(","), attr_spec))(s)?;
|
||||||
Ok((s, AttributeInstance { nodes: (x,) }))
|
let (s, d) = symbol("*)")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
AttributeInstance {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn attr_spec(s: Span) -> IResult<Span, AttrSpec> {
|
pub fn attr_spec(s: Span) -> IResult<Span, AttrSpec> {
|
||||||
let (s, x) = identifier(s)?;
|
let (s, a) = identifier(s)?;
|
||||||
let (s, y) = opt(preceded(symbol("="), constant_expression))(s)?;
|
let (s, b) = opt(pair(symbol("="), constant_expression))(s)?;
|
||||||
Ok((s, AttrSpec { nodes: (x, y) }))
|
Ok((s, AttrSpec { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -17,19 +17,19 @@ pub fn comment(s: Span) -> IResult<Span, Comment> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn one_line_comment(s: Span) -> IResult<Span, Comment> {
|
pub fn one_line_comment(s: Span) -> IResult<Span, Comment> {
|
||||||
let (s, x) = tag("//")(s)?;
|
let (s, a) = tag("//")(s)?;
|
||||||
let (s, y) = is_not("\n")(s)?;
|
let (s, b) = is_not("\n")(s)?;
|
||||||
let x = concat(x, y).unwrap();
|
let a = concat(a, b).unwrap();
|
||||||
Ok((s, Comment { nodes: (x,) }))
|
Ok((s, Comment { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn block_comment(s: Span) -> IResult<Span, Comment> {
|
pub fn block_comment(s: Span) -> IResult<Span, Comment> {
|
||||||
let (s, x) = tag("/*")(s)?;
|
let (s, a) = tag("/*")(s)?;
|
||||||
let (s, y) = is_not("*/")(s)?;
|
let (s, b) = is_not("*/")(s)?;
|
||||||
let (s, z) = tag("*/")(s)?;
|
let (s, c) = tag("*/")(s)?;
|
||||||
let x = concat(x, y).unwrap();
|
let a = concat(a, b).unwrap();
|
||||||
let x = concat(x, z).unwrap();
|
let a = concat(a, c).unwrap();
|
||||||
Ok((s, Comment { nodes: (x,) }))
|
Ok((s, Comment { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -497,20 +497,20 @@ pub struct VariableIdentifier<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ImplicitClassHandleOrClassScopeOrPackageScope<'a> {
|
pub enum ImplicitClassHandleOrClassScopeOrPackageScope<'a> {
|
||||||
ImplicitClassHandle(ImplicitClassHandle),
|
ImplicitClassHandle(ImplicitClassHandle<'a>),
|
||||||
ClassScope(ClassScope<'a>),
|
ClassScope(ClassScope<'a>),
|
||||||
PackageScope(PackageScope<'a>),
|
PackageScope(PackageScope<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ImplicitClassHandleOrPackageScope<'a> {
|
pub enum ImplicitClassHandleOrPackageScope<'a> {
|
||||||
ImplicitClassHandle(ImplicitClassHandle),
|
ImplicitClassHandle(ImplicitClassHandle<'a>),
|
||||||
PackageScope(PackageScope<'a>),
|
PackageScope(PackageScope<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ImplicitClassHandleOrClassScope<'a> {
|
pub enum ImplicitClassHandleOrClassScope<'a> {
|
||||||
ImplicitClassHandle(ImplicitClassHandle),
|
ImplicitClassHandle(ImplicitClassHandle<'a>),
|
||||||
ClassScope(ClassScope<'a>),
|
ClassScope(ClassScope<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ use crate::parser::*;
|
|||||||
use nom::branch::*;
|
use nom::branch::*;
|
||||||
use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::multi::*;
|
use nom::multi::*;
|
||||||
|
use nom::sequence::*;
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -11,14 +12,33 @@ pub struct CheckerInstantiation<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
PsCheckerIdentifier<'a>,
|
PsCheckerIdentifier<'a>,
|
||||||
NameOfInstance<'a>,
|
NameOfInstance<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
Option<ListOfCheckerPortConnections<'a>>,
|
Option<ListOfCheckerPortConnections<'a>>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ListOfCheckerPortConnections<'a> {
|
pub enum ListOfCheckerPortConnections<'a> {
|
||||||
Ordered(Vec<OrderedCheckerPortConnection<'a>>),
|
Ordered(ListOfCheckerPortConnectionsOrdered<'a>),
|
||||||
Named(Vec<NamedCheckerPortConnection<'a>>),
|
Named(ListOfCheckerPortConnectionsNamed<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ListOfCheckerPortConnectionsOrdered<'a> {
|
||||||
|
pub nodes: (
|
||||||
|
OrderedCheckerPortConnection<'a>,
|
||||||
|
Vec<(Symbol<'a>, OrderedCheckerPortConnection<'a>)>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ListOfCheckerPortConnectionsNamed<'a> {
|
||||||
|
pub nodes: (
|
||||||
|
NamedCheckerPortConnection<'a>,
|
||||||
|
Vec<(Symbol<'a>, NamedCheckerPortConnection<'a>)>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -36,39 +56,63 @@ pub enum NamedCheckerPortConnection<'a> {
|
|||||||
pub struct NamedCheckerPortConnectionIdentifier<'a> {
|
pub struct NamedCheckerPortConnectionIdentifier<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
Vec<AttributeInstance<'a>>,
|
Vec<AttributeInstance<'a>>,
|
||||||
|
Symbol<'a>,
|
||||||
FormalPortIdentifier<'a>,
|
FormalPortIdentifier<'a>,
|
||||||
Option<PropertyActualArg<'a>>,
|
Option<(Symbol<'a>, Option<PropertyActualArg<'a>>, Symbol<'a>)>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NamedCheckerPortConnectionAsterisk<'a> {
|
pub struct NamedCheckerPortConnectionAsterisk<'a> {
|
||||||
pub nodes: (Vec<AttributeInstance<'a>>,),
|
pub nodes: (Vec<AttributeInstance<'a>>, Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn checker_instantiation(s: Span) -> IResult<Span, CheckerInstantiation> {
|
pub fn checker_instantiation(s: Span) -> IResult<Span, CheckerInstantiation> {
|
||||||
let (s, x) = ps_checker_identifier(s)?;
|
let (s, a) = ps_checker_identifier(s)?;
|
||||||
let (s, y) = name_of_instance(s)?;
|
let (s, b) = name_of_instance(s)?;
|
||||||
let (s, z) = paren(opt(list_of_checker_port_connections))(s)?;
|
let (s, (c, d, e)) = paren2(opt(list_of_checker_port_connections))(s)?;
|
||||||
let (s, _) = symbol(";")(s)?;
|
let (s, f) = symbol(";")(s)?;
|
||||||
Ok((s, CheckerInstantiation { nodes: (x, y, z) }))
|
Ok((
|
||||||
|
s,
|
||||||
|
CheckerInstantiation {
|
||||||
|
nodes: (a, b, c, d, e, f),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_checker_port_connections(s: Span) -> IResult<Span, ListOfCheckerPortConnections> {
|
pub fn list_of_checker_port_connections(s: Span) -> IResult<Span, ListOfCheckerPortConnections> {
|
||||||
alt((
|
alt((
|
||||||
map(
|
list_of_checker_port_connections_ordered,
|
||||||
separated_nonempty_list(symbol(","), ordered_checker_port_connection),
|
list_of_checker_port_connections_named,
|
||||||
|x| ListOfCheckerPortConnections::Ordered(x),
|
|
||||||
),
|
|
||||||
map(
|
|
||||||
separated_nonempty_list(symbol(","), named_checker_port_connection),
|
|
||||||
|x| ListOfCheckerPortConnections::Named(x),
|
|
||||||
),
|
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn list_of_checker_port_connections_ordered(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ListOfCheckerPortConnections> {
|
||||||
|
let (s, a) = ordered_checker_port_connection(s)?;
|
||||||
|
let (s, b) = many0(pair(symbol(","), ordered_checker_port_connection))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ListOfCheckerPortConnections::Ordered(ListOfCheckerPortConnectionsOrdered {
|
||||||
|
nodes: (a, b),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn list_of_checker_port_connections_named(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ListOfCheckerPortConnections> {
|
||||||
|
let (s, a) = named_checker_port_connection(s)?;
|
||||||
|
let (s, b) = many0(pair(symbol(","), named_checker_port_connection))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ListOfCheckerPortConnections::Named(ListOfCheckerPortConnectionsNamed { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn ordered_checker_port_connection(s: Span) -> IResult<Span, OrderedCheckerPortConnection> {
|
pub fn ordered_checker_port_connection(s: Span) -> IResult<Span, OrderedCheckerPortConnection> {
|
||||||
let (s, x) = many0(attribute_instance)(s)?;
|
let (s, x) = many0(attribute_instance)(s)?;
|
||||||
let (s, y) = opt(property_actual_arg)(s)?;
|
let (s, y) = opt(property_actual_arg)(s)?;
|
||||||
@ -85,15 +129,14 @@ pub fn named_checker_port_connection(s: Span) -> IResult<Span, NamedCheckerPortC
|
|||||||
pub fn named_checker_port_connection_identifier(
|
pub fn named_checker_port_connection_identifier(
|
||||||
s: Span,
|
s: Span,
|
||||||
) -> IResult<Span, NamedCheckerPortConnection> {
|
) -> IResult<Span, NamedCheckerPortConnection> {
|
||||||
let (s, x) = many0(attribute_instance)(s)?;
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
let (s, _) = symbol(".")(s)?;
|
let (s, b) = symbol(".")(s)?;
|
||||||
let (s, y) = formal_port_identifier(s)?;
|
let (s, c) = formal_port_identifier(s)?;
|
||||||
let (s, z) = opt(paren(opt(property_actual_arg)))(s)?;
|
let (s, d) = opt(paren2(opt(property_actual_arg)))(s)?;
|
||||||
let z = if let Some(Some(z)) = z { Some(z) } else { None };
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
NamedCheckerPortConnection::Identifier(NamedCheckerPortConnectionIdentifier {
|
NamedCheckerPortConnection::Identifier(NamedCheckerPortConnectionIdentifier {
|
||||||
nodes: (x, y, z),
|
nodes: (a, b, c, d),
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -101,12 +144,11 @@ pub fn named_checker_port_connection_identifier(
|
|||||||
pub fn named_checker_port_connection_asterisk(
|
pub fn named_checker_port_connection_asterisk(
|
||||||
s: Span,
|
s: Span,
|
||||||
) -> IResult<Span, NamedCheckerPortConnection> {
|
) -> IResult<Span, NamedCheckerPortConnection> {
|
||||||
let (s, x) = many0(attribute_instance)(s)?;
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
let (s, _) = symbol(".")(s)?;
|
let (s, b) = symbol(".*")(s)?;
|
||||||
let (s, _) = symbol("*")(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
NamedCheckerPortConnection::Asterisk(NamedCheckerPortConnectionAsterisk { nodes: (x,) }),
|
NamedCheckerPortConnection::Asterisk(NamedCheckerPortConnectionAsterisk { nodes: (a, b) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ pub struct GenerateRegion<'a> {
|
|||||||
pub struct LoopGenerateConstruct<'a> {
|
pub struct LoopGenerateConstruct<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
GenvarInitialization<'a>,
|
GenvarInitialization<'a>,
|
||||||
ConstantExpression<'a>,
|
GenvarExpression<'a>,
|
||||||
GenvarIteration<'a>,
|
GenvarIteration<'a>,
|
||||||
GenerateBlock<'a>,
|
GenerateBlock<'a>,
|
||||||
),
|
),
|
||||||
@ -42,7 +42,7 @@ pub struct GenvarIterationAssignment<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
GenvarIdentifier<'a>,
|
GenvarIdentifier<'a>,
|
||||||
AssignmentOperator<'a>,
|
AssignmentOperator<'a>,
|
||||||
ConstantExpression<'a>,
|
GenvarExpression<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::multi::*;
|
use nom::multi::*;
|
||||||
|
use nom::sequence::*;
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -10,18 +11,26 @@ pub struct InterfaceInstantiation<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
InterfaceIdentifier<'a>,
|
InterfaceIdentifier<'a>,
|
||||||
Option<ParameterValueAssignment<'a>>,
|
Option<ParameterValueAssignment<'a>>,
|
||||||
Vec<HierarchicalInstance<'a>>,
|
HierarchicalInstance<'a>,
|
||||||
|
Vec<(Symbol<'a>, HierarchicalInstance<'a>)>,
|
||||||
|
Symbol<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn interface_instantiation(s: Span) -> IResult<Span, InterfaceInstantiation> {
|
pub fn interface_instantiation(s: Span) -> IResult<Span, InterfaceInstantiation> {
|
||||||
let (s, x) = interface_identifier(s)?;
|
let (s, a) = interface_identifier(s)?;
|
||||||
let (s, y) = opt(parameter_value_assignment)(s)?;
|
let (s, b) = opt(parameter_value_assignment)(s)?;
|
||||||
let (s, z) = separated_nonempty_list(symbol(","), hierarchical_instance)(s)?;
|
let (s, c) = hierarchical_instance(s)?;
|
||||||
let (s, _) = symbol(";")(s)?;
|
let (s, d) = many0(pair(symbol(","), hierarchical_instance))(s)?;
|
||||||
Ok((s, InterfaceInstantiation { nodes: (x, y, z) }))
|
let (s, e) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
InterfaceInstantiation {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::multi::*;
|
use nom::multi::*;
|
||||||
|
use nom::sequence::*;
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -10,18 +11,26 @@ pub struct ProgramInstantiation<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
ProgramIdentifier<'a>,
|
ProgramIdentifier<'a>,
|
||||||
Option<ParameterValueAssignment<'a>>,
|
Option<ParameterValueAssignment<'a>>,
|
||||||
Vec<HierarchicalInstance<'a>>,
|
HierarchicalInstance<'a>,
|
||||||
|
Vec<(Symbol<'a>, HierarchicalInstance<'a>)>,
|
||||||
|
Symbol<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn program_instantiation(s: Span) -> IResult<Span, ProgramInstantiation> {
|
pub fn program_instantiation(s: Span) -> IResult<Span, ProgramInstantiation> {
|
||||||
let (s, x) = program_identifier(s)?;
|
let (s, a) = program_identifier(s)?;
|
||||||
let (s, y) = opt(parameter_value_assignment)(s)?;
|
let (s, b) = opt(parameter_value_assignment)(s)?;
|
||||||
let (s, z) = separated_nonempty_list(symbol(","), hierarchical_instance)(s)?;
|
let (s, c) = hierarchical_instance(s)?;
|
||||||
let (s, _) = symbol(";")(s)?;
|
let (s, d) = many0(pair(symbol(","), hierarchical_instance))(s)?;
|
||||||
Ok((s, ProgramInstantiation { nodes: (x, y, z) }))
|
let (s, e) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ProgramInstantiation {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -200,6 +200,10 @@ pub fn method_qualifier(s: Span) -> IResult<Span, MethodQualifier> {
|
|||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn method_prototype(s: Span) -> IResult<Span, MethodPrototype> {
|
||||||
|
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn class_constructor_declaration(s: Span) -> IResult<Span, ClassConstructorDeclaration> {
|
pub fn class_constructor_declaration(s: Span) -> IResult<Span, ClassConstructorDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
||||||
}
|
}
|
||||||
|
@ -73,11 +73,11 @@ pub fn library_declaration(s: Span) -> IResult<Span, LibraryDeclaration> {
|
|||||||
let (s, b) = library_identifier(s)?;
|
let (s, b) = library_identifier(s)?;
|
||||||
let (s, c) = file_path_spec(s)?;
|
let (s, c) = file_path_spec(s)?;
|
||||||
let (s, d) = many0(pair(symbol(","), file_path_spec))(s)?;
|
let (s, d) = many0(pair(symbol(","), file_path_spec))(s)?;
|
||||||
let (s, e) = opt(tuple((
|
let (s, e) = opt(triple(
|
||||||
symbol("-incdir"),
|
symbol("-incdir"),
|
||||||
file_path_spec,
|
file_path_spec,
|
||||||
many0(pair(symbol(","), file_path_spec)),
|
many0(pair(symbol(","), file_path_spec)),
|
||||||
)))(s)?;
|
))(s)?;
|
||||||
let (s, f) = symbol(";")(s)?;
|
let (s, f) = symbol(";")(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
@ -94,6 +94,7 @@ pub fn include_statement(s: Span) -> IResult<Span, IncludeStatement> {
|
|||||||
Ok((s, IncludeStatement { nodes: (a, b, c) }))
|
Ok((s, IncludeStatement { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO support non literal path
|
||||||
pub fn file_path_spec(s: Span) -> IResult<Span, FilePathSpec> {
|
pub fn file_path_spec(s: Span) -> IResult<Span, FilePathSpec> {
|
||||||
let (s, a) = string_literal(s)?;
|
let (s, a) = string_literal(s)?;
|
||||||
Ok((s, FilePathSpec { nodes: (a,) }))
|
Ok((s, FilePathSpec { nodes: (a,) }))
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -37,15 +37,41 @@ pub fn symbol<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult<Span<'a>, Symbol<'
|
|||||||
move |s: Span<'a>| map(ws(tag(t.clone())), |x| Symbol { nodes: x })(s)
|
move |s: Span<'a>| map(ws(tag(t.clone())), |x| Symbol { nodes: x })(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn paren2<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, (Symbol<'a>, O, Symbol<'a>)>
|
||||||
|
where
|
||||||
|
F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
|
||||||
|
{
|
||||||
|
move |s: Span<'a>| {
|
||||||
|
let (s, a) = symbol("(")(s)?;
|
||||||
|
let (s, b) = f(s)?;
|
||||||
|
let (s, c) = symbol(")")(s)?;
|
||||||
|
Ok((s, (a, b, c)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn bracket2<'a, O, F>(
|
||||||
|
f: F,
|
||||||
|
) -> impl Fn(Span<'a>) -> IResult<Span<'a>, (Symbol<'a>, O, Symbol<'a>)>
|
||||||
|
where
|
||||||
|
F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
|
||||||
|
{
|
||||||
|
move |s: Span<'a>| {
|
||||||
|
let (s, a) = symbol("[")(s)?;
|
||||||
|
let (s, b) = f(s)?;
|
||||||
|
let (s, c) = symbol("]")(s)?;
|
||||||
|
Ok((s, (a, b, c)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn paren<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, O>
|
pub fn paren<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, O>
|
||||||
where
|
where
|
||||||
F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
|
F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
|
||||||
{
|
{
|
||||||
move |s: Span<'a>| {
|
move |s: Span<'a>| {
|
||||||
let (s, _) = symbol("(")(s)?;
|
let (s, _) = symbol("(")(s)?;
|
||||||
let (s, x) = f(s)?;
|
let (s, b) = f(s)?;
|
||||||
let (s, _) = symbol(")")(s)?;
|
let (s, _) = symbol(")")(s)?;
|
||||||
Ok((s, x))
|
Ok((s, b))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,9 +81,9 @@ where
|
|||||||
{
|
{
|
||||||
move |s: Span<'a>| {
|
move |s: Span<'a>| {
|
||||||
let (s, _) = symbol("[")(s)?;
|
let (s, _) = symbol("[")(s)?;
|
||||||
let (s, x) = f(s)?;
|
let (s, b) = f(s)?;
|
||||||
let (s, _) = symbol("]")(s)?;
|
let (s, _) = symbol("]")(s)?;
|
||||||
Ok((s, x))
|
Ok((s, b))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +126,24 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn triple<'a, O1, O2, O3, F, G, H>(
|
||||||
|
f: F,
|
||||||
|
g: G,
|
||||||
|
h: H,
|
||||||
|
) -> impl Fn(Span<'a>) -> IResult<Span<'a>, (O1, O2, O3)>
|
||||||
|
where
|
||||||
|
F: Fn(Span<'a>) -> IResult<Span<'a>, O1>,
|
||||||
|
G: Fn(Span<'a>) -> IResult<Span<'a>, O2>,
|
||||||
|
H: Fn(Span<'a>) -> IResult<Span<'a>, O3>,
|
||||||
|
{
|
||||||
|
move |s: Span<'a>| {
|
||||||
|
let (s, x) = f(s)?;
|
||||||
|
let (s, y) = g(s)?;
|
||||||
|
let (s, z) = h(s)?;
|
||||||
|
Ok((s, (x, y, z)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn white_space(s: Span) -> IResult<Span, WhiteSpace> {
|
pub fn white_space(s: Span) -> IResult<Span, WhiteSpace> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user