Add Paren/Brace/Barcket/List
This commit is contained in:
parent
26cb4e6818
commit
9983826bdf
@ -1,7 +1,6 @@
|
|||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
use nom::branch::*;
|
use nom::branch::*;
|
||||||
use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
use nom::sequence::*;
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
@ -9,67 +8,45 @@ use nom::IResult;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Concatenation<'a> {
|
pub struct Concatenation<'a> {
|
||||||
pub nodes: (
|
pub nodes: (Brace<'a, List<Symbol<'a>, Expression<'a>>>,),
|
||||||
Symbol<'a>,
|
|
||||||
Expression<'a>,
|
|
||||||
Vec<(Symbol<'a>, Expression<'a>)>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ConstantConcatenation<'a> {
|
pub struct ConstantConcatenation<'a> {
|
||||||
pub nodes: (
|
pub nodes: (Brace<'a, List<Symbol<'a>, ConstantExpression<'a>>>,),
|
||||||
Symbol<'a>,
|
|
||||||
ConstantExpression<'a>,
|
|
||||||
Vec<(Symbol<'a>, ConstantExpression<'a>)>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ConstantMultipleConcatenation<'a> {
|
pub struct ConstantMultipleConcatenation<'a> {
|
||||||
pub nodes: (
|
pub nodes: (Brace<'a, (ConstantExpression<'a>, ConstantConcatenation<'a>)>,),
|
||||||
Symbol<'a>,
|
|
||||||
ConstantExpression<'a>,
|
|
||||||
ConstantConcatenation<'a>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ModulePathConcatenation<'a> {
|
pub struct ModulePathConcatenation<'a> {
|
||||||
pub nodes: (
|
pub nodes: (Brace<'a, List<Symbol<'a>, ModulePathExpression<'a>>>,),
|
||||||
Symbol<'a>,
|
|
||||||
ModulePathExpression<'a>,
|
|
||||||
Vec<(Symbol<'a>, ModulePathExpression<'a>)>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ModulePathMultipleConcatenation<'a> {
|
pub struct ModulePathMultipleConcatenation<'a> {
|
||||||
pub nodes: (
|
pub nodes: (Brace<'a, (ConstantExpression<'a>, ModulePathConcatenation<'a>)>,),
|
||||||
Symbol<'a>,
|
|
||||||
ConstantExpression<'a>,
|
|
||||||
ModulePathConcatenation<'a>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MultipleConcatenation<'a> {
|
pub struct MultipleConcatenation<'a> {
|
||||||
pub nodes: (Symbol<'a>, Expression<'a>, Concatenation<'a>, Symbol<'a>),
|
pub nodes: (Brace<'a, (Expression<'a>, Concatenation<'a>)>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct StreamingConcatenation<'a> {
|
pub struct StreamingConcatenation<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
Symbol<'a>,
|
Brace<
|
||||||
StreamOperator<'a>,
|
'a,
|
||||||
Option<SliceSize<'a>>,
|
(
|
||||||
StreamConcatenation<'a>,
|
StreamOperator<'a>,
|
||||||
Symbol<'a>,
|
Option<SliceSize<'a>>,
|
||||||
|
StreamConcatenation<'a>,
|
||||||
|
),
|
||||||
|
>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,22 +63,14 @@ pub enum SliceSize<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct StreamConcatenation<'a> {
|
pub struct StreamConcatenation<'a> {
|
||||||
pub nodes: (
|
pub nodes: (Brace<'a, List<Symbol<'a>, StreamExpression<'a>>>,),
|
||||||
Symbol<'a>,
|
|
||||||
StreamExpression<'a>,
|
|
||||||
Vec<(Symbol<'a>, StreamExpression<'a>)>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct StreamExpression<'a> {
|
pub struct StreamExpression<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
Expression<'a>,
|
Expression<'a>,
|
||||||
Option<(
|
Option<(Symbol<'a>, Bracket<'a, ArrayRangeExpression<'a>>)>,
|
||||||
Symbol<'a>,
|
|
||||||
(Symbol<'a>, ArrayRangeExpression<'a>, Symbol<'a>),
|
|
||||||
)>,
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,97 +105,44 @@ pub struct EmptyUnpackedArrayConcatenation<'a> {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn concatenation(s: Span) -> IResult<Span, Concatenation> {
|
pub fn concatenation(s: Span) -> IResult<Span, Concatenation> {
|
||||||
let (s, a) = symbol("{")(s)?;
|
let (s, a) = brace2(list(symbol(","), expression))(s)?;
|
||||||
let (s, b) = expression(s)?;
|
Ok((s, Concatenation { nodes: (a,) }))
|
||||||
let (s, c) = many0(pair(symbol(","), expression))(s)?;
|
|
||||||
let (s, d) = symbol("}")(s)?;
|
|
||||||
Ok((
|
|
||||||
s,
|
|
||||||
Concatenation {
|
|
||||||
nodes: (a, b, c, d),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_concatenation(s: Span) -> IResult<Span, ConstantConcatenation> {
|
pub fn constant_concatenation(s: Span) -> IResult<Span, ConstantConcatenation> {
|
||||||
let (s, a) = symbol("{")(s)?;
|
let (s, a) = brace2(list(symbol(","), constant_expression))(s)?;
|
||||||
let (s, b) = constant_expression(s)?;
|
Ok((s, ConstantConcatenation { nodes: (a,) }))
|
||||||
let (s, c) = many0(pair(symbol(","), constant_expression))(s)?;
|
|
||||||
let (s, d) = symbol("}")(s)?;
|
|
||||||
Ok((
|
|
||||||
s,
|
|
||||||
ConstantConcatenation {
|
|
||||||
nodes: (a, b, c, d),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_multiple_concatenation(s: Span) -> IResult<Span, ConstantMultipleConcatenation> {
|
pub fn constant_multiple_concatenation(s: Span) -> IResult<Span, ConstantMultipleConcatenation> {
|
||||||
let (s, a) = symbol("{")(s)?;
|
let (s, a) = brace2(pair(constant_expression, constant_concatenation))(s)?;
|
||||||
let (s, b) = constant_expression(s)?;
|
Ok((s, ConstantMultipleConcatenation { nodes: (a,) }))
|
||||||
let (s, c) = constant_concatenation(s)?;
|
|
||||||
let (s, d) = symbol("}")(s)?;
|
|
||||||
Ok((
|
|
||||||
s,
|
|
||||||
ConstantMultipleConcatenation {
|
|
||||||
nodes: (a, b, c, d),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn module_path_concatenation(s: Span) -> IResult<Span, ModulePathConcatenation> {
|
pub fn module_path_concatenation(s: Span) -> IResult<Span, ModulePathConcatenation> {
|
||||||
let (s, a) = symbol("{")(s)?;
|
let (s, a) = brace2(list(symbol(","), module_path_expression))(s)?;
|
||||||
let (s, b) = module_path_expression(s)?;
|
Ok((s, ModulePathConcatenation { nodes: (a,) }))
|
||||||
let (s, c) = many0(pair(symbol(","), module_path_expression))(s)?;
|
|
||||||
let (s, d) = symbol("}")(s)?;
|
|
||||||
Ok((
|
|
||||||
s,
|
|
||||||
ModulePathConcatenation {
|
|
||||||
nodes: (a, b, c, d),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn module_path_multiple_concatenation(
|
pub fn module_path_multiple_concatenation(
|
||||||
s: Span,
|
s: Span,
|
||||||
) -> IResult<Span, ModulePathMultipleConcatenation> {
|
) -> IResult<Span, ModulePathMultipleConcatenation> {
|
||||||
let (s, a) = symbol("{")(s)?;
|
let (s, a) = brace2(pair(constant_expression, module_path_concatenation))(s)?;
|
||||||
let (s, b) = constant_expression(s)?;
|
Ok((s, ModulePathMultipleConcatenation { nodes: (a,) }))
|
||||||
let (s, c) = module_path_concatenation(s)?;
|
|
||||||
let (s, d) = symbol("}")(s)?;
|
|
||||||
Ok((
|
|
||||||
s,
|
|
||||||
ModulePathMultipleConcatenation {
|
|
||||||
nodes: (a, b, c, d),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn multiple_concatenation(s: Span) -> IResult<Span, MultipleConcatenation> {
|
pub fn multiple_concatenation(s: Span) -> IResult<Span, MultipleConcatenation> {
|
||||||
let (s, a) = symbol("{")(s)?;
|
let (s, a) = brace2(pair(expression, concatenation))(s)?;
|
||||||
let (s, b) = expression(s)?;
|
Ok((s, MultipleConcatenation { nodes: (a,) }))
|
||||||
let (s, c) = concatenation(s)?;
|
|
||||||
let (s, d) = symbol("}")(s)?;
|
|
||||||
Ok((
|
|
||||||
s,
|
|
||||||
MultipleConcatenation {
|
|
||||||
nodes: (a, b, c, d),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn streaming_concatenation(s: Span) -> IResult<Span, StreamingConcatenation> {
|
pub fn streaming_concatenation(s: Span) -> IResult<Span, StreamingConcatenation> {
|
||||||
let (s, a) = symbol("{")(s)?;
|
let (s, a) = brace2(triple(
|
||||||
let (s, b) = stream_operator(s)?;
|
stream_operator,
|
||||||
let (s, c) = opt(slice_size)(s)?;
|
opt(slice_size),
|
||||||
let (s, d) = stream_concatenation(s)?;
|
stream_concatenation,
|
||||||
let (s, e) = symbol("}")(s)?;
|
))(s)?;
|
||||||
Ok((
|
Ok((s, StreamingConcatenation { nodes: (a,) }))
|
||||||
s,
|
|
||||||
StreamingConcatenation {
|
|
||||||
nodes: (a, b, c, d, e),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stream_operator(s: Span) -> IResult<Span, StreamOperator> {
|
pub fn stream_operator(s: Span) -> IResult<Span, StreamOperator> {
|
||||||
@ -244,16 +160,8 @@ pub fn slice_size(s: Span) -> IResult<Span, SliceSize> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn stream_concatenation(s: Span) -> IResult<Span, StreamConcatenation> {
|
pub fn stream_concatenation(s: Span) -> IResult<Span, StreamConcatenation> {
|
||||||
let (s, a) = symbol("{")(s)?;
|
let (s, a) = brace2(list(symbol(","), stream_expression))(s)?;
|
||||||
let (s, b) = stream_expression(s)?;
|
Ok((s, StreamConcatenation { nodes: (a,) }))
|
||||||
let (s, c) = many0(pair(symbol(","), stream_expression))(s)?;
|
|
||||||
let (s, d) = symbol("}")(s)?;
|
|
||||||
Ok((
|
|
||||||
s,
|
|
||||||
StreamConcatenation {
|
|
||||||
nodes: (a, b, c, d),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stream_expression(s: Span) -> IResult<Span, StreamExpression> {
|
pub fn stream_expression(s: Span) -> IResult<Span, StreamExpression> {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
use nom::branch::*;
|
use nom::branch::*;
|
||||||
use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -21,12 +19,7 @@ pub struct NetLvalueIdentifier<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NetLvalueLvalue<'a> {
|
pub struct NetLvalueLvalue<'a> {
|
||||||
pub nodes: (
|
pub nodes: (Brace<'a, List<Symbol<'a>, NetLvalue<'a>>>,),
|
||||||
Symbol<'a>,
|
|
||||||
NetLvalue<'a>,
|
|
||||||
Vec<(Symbol<'a>, NetLvalue<'a>)>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -56,12 +49,7 @@ pub struct VariableLvalueIdentifier<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct VariableLvalueLvalue<'a> {
|
pub struct VariableLvalueLvalue<'a> {
|
||||||
pub nodes: (
|
pub nodes: (Brace<'a, List<Symbol<'a>, VariableLvalue<'a>>>,),
|
||||||
Symbol<'a>,
|
|
||||||
VariableLvalue<'a>,
|
|
||||||
Vec<(Symbol<'a>, VariableLvalue<'a>)>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -103,15 +91,10 @@ pub fn net_lvalue_pattern(s: Span) -> IResult<Span, NetLvalue> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn net_lvalue_lvalue(s: Span) -> IResult<Span, NetLvalue> {
|
pub fn net_lvalue_lvalue(s: Span) -> IResult<Span, NetLvalue> {
|
||||||
let (s, a) = symbol("{")(s)?;
|
let (s, a) = brace2(list(symbol(","), net_lvalue))(s)?;
|
||||||
let (s, b) = net_lvalue(s)?;
|
|
||||||
let (s, c) = many0(pair(symbol(","), net_lvalue))(s)?;
|
|
||||||
let (s, d) = symbol("}")(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
NetLvalue::Lvalue(Box::new(NetLvalueLvalue {
|
NetLvalue::Lvalue(Box::new(NetLvalueLvalue { nodes: (a,) })),
|
||||||
nodes: (a, b, c, d),
|
|
||||||
})),
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,15 +129,10 @@ pub fn variable_lvalue_pattern(s: Span) -> IResult<Span, VariableLvalue> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn variable_lvalue_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
|
pub fn variable_lvalue_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
|
||||||
let (s, a) = symbol("{")(s)?;
|
let (s, a) = brace2(list(symbol(","), variable_lvalue))(s)?;
|
||||||
let (s, b) = variable_lvalue(s)?;
|
|
||||||
let (s, c) = many0(pair(symbol(","), variable_lvalue))(s)?;
|
|
||||||
let (s, d) = symbol("}")(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
VariableLvalue::Lvalue(Box::new(VariableLvalueLvalue {
|
VariableLvalue::Lvalue(Box::new(VariableLvalueLvalue { nodes: (a,) })),
|
||||||
nodes: (a, b, c, d),
|
|
||||||
})),
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ pub struct ExpressionUnary<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ExpressionOperatorAssignment<'a> {
|
pub struct ExpressionOperatorAssignment<'a> {
|
||||||
pub nodes: (Symbol<'a>, OperatorAssignment<'a>, Symbol<'a>),
|
pub nodes: (Paren<'a, OperatorAssignment<'a>>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -173,13 +173,7 @@ pub struct TaggedUnionExpression<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct InsideExpression<'a> {
|
pub struct InsideExpression<'a> {
|
||||||
pub nodes: (
|
pub nodes: (Expression<'a>, Symbol<'a>, Brace<'a, Vec<ValueRange<'a>>>),
|
||||||
Expression<'a>,
|
|
||||||
Symbol<'a>,
|
|
||||||
Symbol<'a>,
|
|
||||||
Vec<ValueRange<'a>>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -190,13 +184,7 @@ pub enum ValueRange<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ValueRangeBinary<'a> {
|
pub struct ValueRangeBinary<'a> {
|
||||||
pub nodes: (
|
pub nodes: (Bracket<'a, (Expression<'a>, Symbol<'a>, Expression<'a>)>,),
|
||||||
Symbol<'a>,
|
|
||||||
Expression<'a>,
|
|
||||||
Symbol<'a>,
|
|
||||||
Expression<'a>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -494,7 +482,7 @@ pub fn expression_operator_assignment(s: Span) -> IResult<Span, Expression> {
|
|||||||
let (s, a) = paren2(operator_assignment)(s)?;
|
let (s, a) = paren2(operator_assignment)(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
Expression::OperatorAssignment(Box::new(ExpressionOperatorAssignment { nodes: a })),
|
Expression::OperatorAssignment(Box::new(ExpressionOperatorAssignment { nodes: (a,) })),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,15 +509,8 @@ pub fn tagged_union_expression(s: Span) -> IResult<Span, TaggedUnionExpression>
|
|||||||
pub fn inside_expression(s: Span) -> IResult<Span, InsideExpression> {
|
pub fn inside_expression(s: Span) -> IResult<Span, InsideExpression> {
|
||||||
let (s, a) = expression(s)?;
|
let (s, a) = expression(s)?;
|
||||||
let (s, b) = symbol("inside")(s)?;
|
let (s, b) = symbol("inside")(s)?;
|
||||||
let (s, c) = symbol("{")(s)?;
|
let (s, c) = brace2(open_range_list)(s)?;
|
||||||
let (s, d) = brace(open_range_list)(s)?;
|
Ok((s, InsideExpression { nodes: (a, b, c) }))
|
||||||
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> {
|
||||||
@ -540,17 +521,8 @@ pub fn value_range(s: Span) -> IResult<Span, ValueRange> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn value_range_binary(s: Span) -> IResult<Span, ValueRange> {
|
pub fn value_range_binary(s: Span) -> IResult<Span, ValueRange> {
|
||||||
let (s, a) = symbol("[")(s)?;
|
let (s, a) = bracket2(triple(expression, symbol(":"), expression))(s)?;
|
||||||
let (s, b) = expression(s)?;
|
Ok((s, ValueRange::Binary(ValueRangeBinary { nodes: (a,) })))
|
||||||
let (s, c) = symbol(":")(s)?;
|
|
||||||
let (s, d) = expression(s)?;
|
|
||||||
let (s, e) = symbol("]")(s)?;
|
|
||||||
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> {
|
||||||
|
@ -34,7 +34,7 @@ pub struct ConstantPrimaryPsParameter<'a> {
|
|||||||
pub struct ConstantPrimarySpecparam<'a> {
|
pub struct ConstantPrimarySpecparam<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
SpecparamIdentifier<'a>,
|
SpecparamIdentifier<'a>,
|
||||||
Option<(Symbol<'a>, ConstantRangeExpression<'a>, Symbol<'a>)>,
|
Option<Bracket<'a, ConstantRangeExpression<'a>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ pub struct ConstantPrimaryEnum<'a> {
|
|||||||
pub struct ConstantPrimaryConcatenation<'a> {
|
pub struct ConstantPrimaryConcatenation<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
ConstantConcatenation<'a>,
|
ConstantConcatenation<'a>,
|
||||||
Option<(Symbol<'a>, ConstantRangeExpression<'a>, Symbol<'a>)>,
|
Option<Bracket<'a, ConstantRangeExpression<'a>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,13 +60,13 @@ pub struct ConstantPrimaryConcatenation<'a> {
|
|||||||
pub struct ConstantPrimaryMultipleConcatenation<'a> {
|
pub struct ConstantPrimaryMultipleConcatenation<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
ConstantMultipleConcatenation<'a>,
|
ConstantMultipleConcatenation<'a>,
|
||||||
Option<(Symbol<'a>, ConstantRangeExpression<'a>, Symbol<'a>)>,
|
Option<Bracket<'a, ConstantRangeExpression<'a>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ConstantPrimaryMintypmaxExpression<'a> {
|
pub struct ConstantPrimaryMintypmaxExpression<'a> {
|
||||||
pub nodes: (Symbol<'a>, ConstantMintypmaxExpression<'a>, Symbol<'a>),
|
pub nodes: (Paren<'a, ConstantMintypmaxExpression<'a>>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -81,7 +81,7 @@ pub enum ModulePathPrimary<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ModulePathPrimaryMintypmax<'a> {
|
pub struct ModulePathPrimaryMintypmax<'a> {
|
||||||
pub nodes: (Symbol<'a>, ModulePathMintypmaxExpression<'a>, Symbol<'a>),
|
pub nodes: (Paren<'a, ModulePathMintypmaxExpression<'a>>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -114,23 +114,20 @@ pub struct PrimaryHierarchical<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PrimaryConcatenation<'a> {
|
pub struct PrimaryConcatenation<'a> {
|
||||||
pub nodes: (
|
pub nodes: (Concatenation<'a>, Option<Bracket<'a, RangeExpression<'a>>>),
|
||||||
Concatenation<'a>,
|
|
||||||
Option<(Symbol<'a>, RangeExpression<'a>, Symbol<'a>)>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PrimaryMultipleConcatenation<'a> {
|
pub struct PrimaryMultipleConcatenation<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
MultipleConcatenation<'a>,
|
MultipleConcatenation<'a>,
|
||||||
Option<(Symbol<'a>, RangeExpression<'a>, Symbol<'a>)>,
|
Option<Bracket<'a, RangeExpression<'a>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PrimaryMintypmaxExpression<'a> {
|
pub struct PrimaryMintypmaxExpression<'a> {
|
||||||
pub nodes: (Symbol<'a>, MintypmaxExpression<'a>, Symbol<'a>),
|
pub nodes: (Paren<'a, MintypmaxExpression<'a>>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -201,7 +198,7 @@ pub enum ImplicitClassHandle<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BitSelect<'a> {
|
pub struct BitSelect<'a> {
|
||||||
nodes: (Vec<(Symbol<'a>, Expression<'a>, Symbol<'a>)>,),
|
nodes: (Vec<Bracket<'a, Expression<'a>>>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -213,7 +210,7 @@ pub struct Select<'a> {
|
|||||||
MemberIdentifier<'a>,
|
MemberIdentifier<'a>,
|
||||||
)>,
|
)>,
|
||||||
BitSelect<'a>,
|
BitSelect<'a>,
|
||||||
Option<(Symbol<'a>, PartSelectRange<'a>, Symbol<'a>)>,
|
Option<Bracket<'a, PartSelectRange<'a>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +228,7 @@ pub struct NonrangeSelect<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ConstantBitSelect<'a> {
|
pub struct ConstantBitSelect<'a> {
|
||||||
nodes: (Vec<(Symbol<'a>, ConstantExpression<'a>, Symbol<'a>)>,),
|
nodes: (Vec<Bracket<'a, ConstantExpression<'a>>>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -243,7 +240,7 @@ pub struct ConstantSelect<'a> {
|
|||||||
MemberIdentifier<'a>,
|
MemberIdentifier<'a>,
|
||||||
)>,
|
)>,
|
||||||
ConstantBitSelect<'a>,
|
ConstantBitSelect<'a>,
|
||||||
Option<(Symbol<'a>, ConstantPartSelectRange<'a>, Symbol<'a>)>,
|
Option<Bracket<'a, ConstantPartSelectRange<'a>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,9 +249,7 @@ pub struct ConstantCast<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
CastingType<'a>,
|
CastingType<'a>,
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Symbol<'a>,
|
Paren<'a, ConstantExpression<'a>>,
|
||||||
ConstantExpression<'a>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,13 +260,7 @@ pub struct ConstantLetExpression<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Cast<'a> {
|
pub struct Cast<'a> {
|
||||||
pub nodes: (
|
pub nodes: (CastingType<'a>, Symbol<'a>, Paren<'a, Expression<'a>>),
|
||||||
CastingType<'a>,
|
|
||||||
Symbol<'a>,
|
|
||||||
Symbol<'a>,
|
|
||||||
Expression<'a>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -362,7 +351,7 @@ pub fn constant_primary_mintypmax_expression(s: Span) -> IResult<Span, ConstantP
|
|||||||
let (s, a) = paren2(constant_mintypmax_expression)(s)?;
|
let (s, a) = paren2(constant_mintypmax_expression)(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ConstantPrimary::MintypmaxExpression(ConstantPrimaryMintypmaxExpression { nodes: a }),
|
ConstantPrimary::MintypmaxExpression(ConstantPrimaryMintypmaxExpression { nodes: (a,) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +376,7 @@ pub fn module_path_primary_mintypmax_expression(s: Span) -> IResult<Span, Module
|
|||||||
let (s, a) = paren2(module_path_mintypmax_expression)(s)?;
|
let (s, a) = paren2(module_path_mintypmax_expression)(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ModulePathPrimary::Mintypmax(ModulePathPrimaryMintypmax { nodes: a }),
|
ModulePathPrimary::Mintypmax(ModulePathPrimaryMintypmax { nodes: (a,) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,7 +439,7 @@ pub fn primary_mintypmax_expression(s: Span) -> IResult<Span, Primary> {
|
|||||||
let (s, a) = paren2(mintypmax_expression)(s)?;
|
let (s, a) = paren2(mintypmax_expression)(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
Primary::MintypmaxExpression(PrimaryMintypmaxExpression { nodes: a }),
|
Primary::MintypmaxExpression(PrimaryMintypmaxExpression { nodes: (a,) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,13 +572,8 @@ pub fn constant_select(s: Span) -> IResult<Span, ConstantSelect> {
|
|||||||
pub fn constant_cast(s: Span) -> IResult<Span, ConstantCast> {
|
pub fn constant_cast(s: Span) -> IResult<Span, ConstantCast> {
|
||||||
let (s, a) = casting_type(s)?;
|
let (s, a) = casting_type(s)?;
|
||||||
let (s, b) = symbol("'")(s)?;
|
let (s, b) = symbol("'")(s)?;
|
||||||
let (s, (c, d, e)) = paren2(constant_expression)(s)?;
|
let (s, c) = paren2(constant_expression)(s)?;
|
||||||
Ok((
|
Ok((s, ConstantCast { nodes: (a, b, c) }))
|
||||||
s,
|
|
||||||
ConstantCast {
|
|
||||||
nodes: (a, b, c, d, e),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constant_let_expression(s: Span) -> IResult<Span, ConstantLetExpression> {
|
pub fn constant_let_expression(s: Span) -> IResult<Span, ConstantLetExpression> {
|
||||||
@ -600,13 +584,8 @@ pub fn constant_let_expression(s: Span) -> IResult<Span, ConstantLetExpression>
|
|||||||
pub fn cast(s: Span) -> IResult<Span, Cast> {
|
pub fn cast(s: Span) -> IResult<Span, Cast> {
|
||||||
let (s, a) = casting_type(s)?;
|
let (s, a) = casting_type(s)?;
|
||||||
let (s, b) = symbol("'")(s)?;
|
let (s, b) = symbol("'")(s)?;
|
||||||
let (s, (c, d, e)) = paren2(expression)(s)?;
|
let (s, c) = paren2(expression)(s)?;
|
||||||
Ok((
|
Ok((s, Cast { nodes: (a, b, c) }))
|
||||||
s,
|
|
||||||
Cast {
|
|
||||||
nodes: (a, b, c, d, e),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -17,7 +17,7 @@ pub struct TfCall<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
PsOrHierarchicalTfIdentifier<'a>,
|
PsOrHierarchicalTfIdentifier<'a>,
|
||||||
Vec<AttributeInstance<'a>>,
|
Vec<AttributeInstance<'a>>,
|
||||||
Option<(Symbol<'a>, ListOfArguments<'a>, Symbol<'a>)>,
|
Option<Paren<'a, ListOfArguments<'a>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ pub enum SystemTfCall<'a> {
|
|||||||
pub struct SystemTfCallArgOptional<'a> {
|
pub struct SystemTfCallArgOptional<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
SystemTfIdentifier<'a>,
|
SystemTfIdentifier<'a>,
|
||||||
Option<(Symbol<'a>, ListOfArguments<'a>, Symbol<'a>)>,
|
Option<Paren<'a, ListOfArguments<'a>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,10 +40,7 @@ pub struct SystemTfCallArgOptional<'a> {
|
|||||||
pub struct SystemTfCallArgDataType<'a> {
|
pub struct SystemTfCallArgDataType<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
SystemTfIdentifier<'a>,
|
SystemTfIdentifier<'a>,
|
||||||
Symbol<'a>,
|
Paren<'a, (DataType<'a>, Option<(Symbol<'a>, Expression<'a>)>)>,
|
||||||
DataType<'a>,
|
|
||||||
Option<(Symbol<'a>, Expression<'a>)>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,11 +48,13 @@ pub struct SystemTfCallArgDataType<'a> {
|
|||||||
pub struct SystemTfCallArgExpression<'a> {
|
pub struct SystemTfCallArgExpression<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
SystemTfIdentifier<'a>,
|
SystemTfIdentifier<'a>,
|
||||||
Symbol<'a>,
|
Paren<
|
||||||
Expression<'a>,
|
'a,
|
||||||
Vec<(Symbol<'a>, Option<Expression<'a>>)>,
|
(
|
||||||
Option<(Symbol<'a>, Option<ClockingEvent<'a>>)>,
|
List<Symbol<'a>, Option<Expression<'a>>>,
|
||||||
Symbol<'a>,
|
Option<(Symbol<'a>, Option<ClockingEvent<'a>>)>,
|
||||||
|
),
|
||||||
|
>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,15 +85,12 @@ pub enum ListOfArguments<'a> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ListOfArgumentsOrdered<'a> {
|
pub struct ListOfArgumentsOrdered<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
Option<Expression<'a>>,
|
List<Symbol<'a>, Option<Expression<'a>>>,
|
||||||
Vec<(Symbol<'a>, Option<Expression<'a>>)>,
|
|
||||||
Vec<(
|
Vec<(
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Identifier<'a>,
|
Identifier<'a>,
|
||||||
Symbol<'a>,
|
Paren<'a, Option<Expression<'a>>>,
|
||||||
Option<Expression<'a>>,
|
|
||||||
Symbol<'a>,
|
|
||||||
)>,
|
)>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@ -104,16 +100,12 @@ pub struct ListOfArgumentsNamed<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Identifier<'a>,
|
Identifier<'a>,
|
||||||
Symbol<'a>,
|
Paren<'a, Option<Expression<'a>>>,
|
||||||
Option<Expression<'a>>,
|
|
||||||
Symbol<'a>,
|
|
||||||
Vec<(
|
Vec<(
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Identifier<'a>,
|
Identifier<'a>,
|
||||||
Symbol<'a>,
|
Paren<'a, Option<Expression<'a>>>,
|
||||||
Option<Expression<'a>>,
|
|
||||||
Symbol<'a>,
|
|
||||||
)>,
|
)>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@ -134,7 +126,7 @@ pub struct MethodCallBodyUser<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
MethodIdentifier<'a>,
|
MethodIdentifier<'a>,
|
||||||
Vec<AttributeInstance<'a>>,
|
Vec<AttributeInstance<'a>>,
|
||||||
Option<(Symbol<'a>, ListOfArguments<'a>, Symbol<'a>)>,
|
Option<Paren<'a, ListOfArguments<'a>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,8 +141,8 @@ pub struct ArrayManipulationCall<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
ArrayMethodName<'a>,
|
ArrayMethodName<'a>,
|
||||||
Vec<AttributeInstance<'a>>,
|
Vec<AttributeInstance<'a>>,
|
||||||
Option<(Symbol<'a>, ListOfArguments<'a>, Symbol<'a>)>,
|
Option<Paren<'a, ListOfArguments<'a>>>,
|
||||||
Option<(Symbol<'a>, (Symbol<'a>, Expression<'a>, Symbol<'a>))>,
|
Option<(Symbol<'a>, Paren<'a, Expression<'a>>)>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,14 +151,10 @@ pub struct RandomizeCall<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Vec<AttributeInstance<'a>>,
|
Vec<AttributeInstance<'a>>,
|
||||||
|
Option<Paren<'a, Option<VariableIdentifierListOrNull<'a>>>>,
|
||||||
Option<(
|
Option<(
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Option<VariableIdentifierListOrNull<'a>>,
|
Option<Paren<'a, Option<IdentifierList<'a>>>>,
|
||||||
Symbol<'a>,
|
|
||||||
)>,
|
|
||||||
Option<(
|
|
||||||
Symbol<'a>,
|
|
||||||
Option<(Symbol<'a>, Option<IdentifierList<'a>>, Symbol<'a>)>,
|
|
||||||
ConstraintBlock<'a>,
|
ConstraintBlock<'a>,
|
||||||
)>,
|
)>,
|
||||||
),
|
),
|
||||||
@ -226,30 +214,22 @@ pub fn system_tf_call_arg_optional(s: Span) -> IResult<Span, SystemTfCall> {
|
|||||||
|
|
||||||
pub fn system_tf_call_arg_data_type(s: Span) -> IResult<Span, SystemTfCall> {
|
pub fn system_tf_call_arg_data_type(s: Span) -> IResult<Span, SystemTfCall> {
|
||||||
let (s, a) = system_tf_identifier(s)?;
|
let (s, a) = system_tf_identifier(s)?;
|
||||||
let (s, b) = symbol("(")(s)?;
|
let (s, b) = paren2(pair(data_type, opt(pair(symbol(","), expression))))(s)?;
|
||||||
let (s, c) = data_type(s)?;
|
|
||||||
let (s, d) = opt(pair(symbol(","), expression))(s)?;
|
|
||||||
let (s, e) = symbol(")")(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
SystemTfCall::ArgDataType(SystemTfCallArgDataType {
|
SystemTfCall::ArgDataType(SystemTfCallArgDataType { nodes: (a, b) }),
|
||||||
nodes: (a, b, c, d, e),
|
|
||||||
}),
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn system_tf_call_arg_expression(s: Span) -> IResult<Span, SystemTfCall> {
|
pub fn system_tf_call_arg_expression(s: Span) -> IResult<Span, SystemTfCall> {
|
||||||
let (s, a) = system_tf_identifier(s)?;
|
let (s, a) = system_tf_identifier(s)?;
|
||||||
let (s, b) = symbol("(")(s)?;
|
let (s, b) = paren2(pair(
|
||||||
let (s, c) = expression(s)?;
|
list(symbol(","), opt(expression)),
|
||||||
let (s, d) = many0(pair(symbol(","), opt(expression)))(s)?;
|
opt(pair(symbol(","), opt(clocking_event))),
|
||||||
let (s, e) = opt(pair(symbol(","), opt(clocking_event)))(s)?;
|
))(s)?;
|
||||||
let (s, f) = symbol(")")(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
SystemTfCall::ArgExpression(SystemTfCallArgExpression {
|
SystemTfCall::ArgExpression(SystemTfCallArgExpression { nodes: (a, b) }),
|
||||||
nodes: (a, b, c, d, e, f),
|
|
||||||
}),
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,40 +262,33 @@ pub fn list_of_arguments(s: Span) -> IResult<Span, ListOfArguments> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_arguments_ordered(s: Span) -> IResult<Span, ListOfArguments> {
|
pub fn list_of_arguments_ordered(s: Span) -> IResult<Span, ListOfArguments> {
|
||||||
let (s, a) = opt(expression)(s)?;
|
let (s, a) = list(symbol(","), opt(expression))(s)?;
|
||||||
let (s, b) = many0(pair(symbol(","), opt(expression)))(s)?;
|
let (s, b) = many0(tuple((
|
||||||
let (s, c) = many0(tuple((
|
|
||||||
symbol(","),
|
symbol(","),
|
||||||
symbol("."),
|
symbol("."),
|
||||||
identifier,
|
identifier,
|
||||||
symbol("("),
|
paren2(opt(expression)),
|
||||||
opt(expression),
|
|
||||||
symbol(")"),
|
|
||||||
)))(s)?;
|
)))(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ListOfArguments::Ordered(ListOfArgumentsOrdered { nodes: (a, b, c) }),
|
ListOfArguments::Ordered(ListOfArgumentsOrdered { nodes: (a, b) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_arguments_named(s: Span) -> IResult<Span, ListOfArguments> {
|
pub fn list_of_arguments_named(s: Span) -> IResult<Span, ListOfArguments> {
|
||||||
let (s, a) = symbol(".")(s)?;
|
let (s, a) = symbol(".")(s)?;
|
||||||
let (s, b) = identifier(s)?;
|
let (s, b) = identifier(s)?;
|
||||||
let (s, c) = symbol("(")(s)?;
|
let (s, c) = paren2(opt(expression))(s)?;
|
||||||
let (s, d) = opt(expression)(s)?;
|
let (s, d) = many0(tuple((
|
||||||
let (s, e) = symbol(")")(s)?;
|
|
||||||
let (s, f) = many0(tuple((
|
|
||||||
symbol(","),
|
symbol(","),
|
||||||
symbol("."),
|
symbol("."),
|
||||||
identifier,
|
identifier,
|
||||||
symbol("("),
|
paren2(opt(expression)),
|
||||||
opt(expression),
|
|
||||||
symbol(")"),
|
|
||||||
)))(s)?;
|
)))(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ListOfArguments::Named(ListOfArgumentsNamed {
|
ListOfArguments::Named(ListOfArgumentsNamed {
|
||||||
nodes: (a, b, c, d, e, f),
|
nodes: (a, b, c, d),
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
use nom::sequence::*;
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
@ -8,12 +7,7 @@ use nom::IResult;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AttributeInstance<'a> {
|
pub struct AttributeInstance<'a> {
|
||||||
pub nodes: (
|
pub nodes: (Symbol<'a>, List<Symbol<'a>, AttrSpec<'a>>, Symbol<'a>),
|
||||||
Symbol<'a>,
|
|
||||||
AttrSpec<'a>,
|
|
||||||
Vec<(Symbol<'a>, AttrSpec<'a>)>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -25,15 +19,9 @@ pub struct AttrSpec<'a> {
|
|||||||
|
|
||||||
pub fn attribute_instance(s: Span) -> IResult<Span, AttributeInstance> {
|
pub fn attribute_instance(s: Span) -> IResult<Span, AttributeInstance> {
|
||||||
let (s, a) = symbol("(*")(s)?;
|
let (s, a) = symbol("(*")(s)?;
|
||||||
let (s, b) = attr_spec(s)?;
|
let (s, b) = list(symbol(","), attr_spec)(s)?;
|
||||||
let (s, c) = many0(pair(symbol(","), attr_spec))(s)?;
|
let (s, c) = symbol("*)")(s)?;
|
||||||
let (s, d) = symbol("*)")(s)?;
|
Ok((s, AttributeInstance { nodes: (a, b, c) }))
|
||||||
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> {
|
||||||
|
@ -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,9 +11,7 @@ pub struct CheckerInstantiation<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
PsCheckerIdentifier<'a>,
|
PsCheckerIdentifier<'a>,
|
||||||
NameOfInstance<'a>,
|
NameOfInstance<'a>,
|
||||||
Symbol<'a>,
|
Paren<'a, Option<ListOfCheckerPortConnections<'a>>>,
|
||||||
Option<ListOfCheckerPortConnections<'a>>,
|
|
||||||
Symbol<'a>,
|
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@ -27,18 +24,12 @@ pub enum ListOfCheckerPortConnections<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ListOfCheckerPortConnectionsOrdered<'a> {
|
pub struct ListOfCheckerPortConnectionsOrdered<'a> {
|
||||||
pub nodes: (
|
pub nodes: (List<Symbol<'a>, OrderedCheckerPortConnection<'a>>,),
|
||||||
OrderedCheckerPortConnection<'a>,
|
|
||||||
Vec<(Symbol<'a>, OrderedCheckerPortConnection<'a>)>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ListOfCheckerPortConnectionsNamed<'a> {
|
pub struct ListOfCheckerPortConnectionsNamed<'a> {
|
||||||
pub nodes: (
|
pub nodes: (List<Symbol<'a>, NamedCheckerPortConnection<'a>>,),
|
||||||
NamedCheckerPortConnection<'a>,
|
|
||||||
Vec<(Symbol<'a>, NamedCheckerPortConnection<'a>)>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -58,7 +49,7 @@ pub struct NamedCheckerPortConnectionIdentifier<'a> {
|
|||||||
Vec<AttributeInstance<'a>>,
|
Vec<AttributeInstance<'a>>,
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
FormalPortIdentifier<'a>,
|
FormalPortIdentifier<'a>,
|
||||||
Option<(Symbol<'a>, Option<PropertyActualArg<'a>>, Symbol<'a>)>,
|
Option<Paren<'a, Option<PropertyActualArg<'a>>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,12 +63,12 @@ pub struct NamedCheckerPortConnectionAsterisk<'a> {
|
|||||||
pub fn checker_instantiation(s: Span) -> IResult<Span, CheckerInstantiation> {
|
pub fn checker_instantiation(s: Span) -> IResult<Span, CheckerInstantiation> {
|
||||||
let (s, a) = ps_checker_identifier(s)?;
|
let (s, a) = ps_checker_identifier(s)?;
|
||||||
let (s, b) = name_of_instance(s)?;
|
let (s, b) = name_of_instance(s)?;
|
||||||
let (s, (c, d, e)) = paren2(opt(list_of_checker_port_connections))(s)?;
|
let (s, c) = paren2(opt(list_of_checker_port_connections))(s)?;
|
||||||
let (s, f) = symbol(";")(s)?;
|
let (s, d) = symbol(";")(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
CheckerInstantiation {
|
CheckerInstantiation {
|
||||||
nodes: (a, b, c, d, e, f),
|
nodes: (a, b, c, d),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -92,24 +83,20 @@ pub fn list_of_checker_port_connections(s: Span) -> IResult<Span, ListOfCheckerP
|
|||||||
pub fn list_of_checker_port_connections_ordered(
|
pub fn list_of_checker_port_connections_ordered(
|
||||||
s: Span,
|
s: Span,
|
||||||
) -> IResult<Span, ListOfCheckerPortConnections> {
|
) -> IResult<Span, ListOfCheckerPortConnections> {
|
||||||
let (s, a) = ordered_checker_port_connection(s)?;
|
let (s, a) = list(symbol(","), ordered_checker_port_connection)(s)?;
|
||||||
let (s, b) = many0(pair(symbol(","), ordered_checker_port_connection))(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ListOfCheckerPortConnections::Ordered(ListOfCheckerPortConnectionsOrdered {
|
ListOfCheckerPortConnections::Ordered(ListOfCheckerPortConnectionsOrdered { nodes: (a,) }),
|
||||||
nodes: (a, b),
|
|
||||||
}),
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_checker_port_connections_named(
|
pub fn list_of_checker_port_connections_named(
|
||||||
s: Span,
|
s: Span,
|
||||||
) -> IResult<Span, ListOfCheckerPortConnections> {
|
) -> IResult<Span, ListOfCheckerPortConnections> {
|
||||||
let (s, a) = named_checker_port_connection(s)?;
|
let (s, a) = list(symbol(","), named_checker_port_connection)(s)?;
|
||||||
let (s, b) = many0(pair(symbol(","), named_checker_port_connection))(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ListOfCheckerPortConnections::Named(ListOfCheckerPortConnectionsNamed { nodes: (a, b) }),
|
ListOfCheckerPortConnections::Named(ListOfCheckerPortConnectionsNamed { nodes: (a,) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -11,8 +9,7 @@ pub struct InterfaceInstantiation<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
InterfaceIdentifier<'a>,
|
InterfaceIdentifier<'a>,
|
||||||
Option<ParameterValueAssignment<'a>>,
|
Option<ParameterValueAssignment<'a>>,
|
||||||
HierarchicalInstance<'a>,
|
List<Symbol<'a>, HierarchicalInstance<'a>>,
|
||||||
Vec<(Symbol<'a>, HierarchicalInstance<'a>)>,
|
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@ -22,13 +19,12 @@ pub struct InterfaceInstantiation<'a> {
|
|||||||
pub fn interface_instantiation(s: Span) -> IResult<Span, InterfaceInstantiation> {
|
pub fn interface_instantiation(s: Span) -> IResult<Span, InterfaceInstantiation> {
|
||||||
let (s, a) = interface_identifier(s)?;
|
let (s, a) = interface_identifier(s)?;
|
||||||
let (s, b) = opt(parameter_value_assignment)(s)?;
|
let (s, b) = opt(parameter_value_assignment)(s)?;
|
||||||
let (s, c) = hierarchical_instance(s)?;
|
let (s, c) = list(symbol(","), hierarchical_instance)(s)?;
|
||||||
let (s, d) = many0(pair(symbol(","), hierarchical_instance))(s)?;
|
let (s, d) = symbol(";")(s)?;
|
||||||
let (s, e) = symbol(";")(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
InterfaceInstantiation {
|
InterfaceInstantiation {
|
||||||
nodes: (a, b, c, d, e),
|
nodes: (a, b, c, d),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -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,8 +11,7 @@ pub struct ModuleInstantiation<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
ModuleIdentifier<'a>,
|
ModuleIdentifier<'a>,
|
||||||
Option<ParameterValueAssignment<'a>>,
|
Option<ParameterValueAssignment<'a>>,
|
||||||
HierarchicalInstance<'a>,
|
List<Symbol<'a>, HierarchicalInstance<'a>>,
|
||||||
Vec<(Symbol<'a>, HierarchicalInstance<'a>)>,
|
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@ -22,11 +20,7 @@ pub struct ModuleInstantiation<'a> {
|
|||||||
pub struct ParameterValueAssignment<'a> {
|
pub struct ParameterValueAssignment<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
(
|
Paren<'a, Option<ListOfParameterAssignments<'a>>>,
|
||||||
Symbol<'a>,
|
|
||||||
Option<ListOfParameterAssignments<'a>>,
|
|
||||||
Symbol<'a>,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,18 +32,12 @@ pub enum ListOfParameterAssignments<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ListOfParameterAssignmentsOrdered<'a> {
|
pub struct ListOfParameterAssignmentsOrdered<'a> {
|
||||||
pub nodes: (
|
pub nodes: (List<Symbol<'a>, OrderedParameterAssignment<'a>>,),
|
||||||
OrderedParameterAssignment<'a>,
|
|
||||||
Vec<(Symbol<'a>, OrderedParameterAssignment<'a>)>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ListOfParameterAssignmentsNamed<'a> {
|
pub struct ListOfParameterAssignmentsNamed<'a> {
|
||||||
pub nodes: (
|
pub nodes: (List<Symbol<'a>, NamedParameterAssignment<'a>>,),
|
||||||
NamedParameterAssignment<'a>,
|
|
||||||
Vec<(Symbol<'a>, NamedParameterAssignment<'a>)>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -62,7 +50,7 @@ pub struct NamedParameterAssignment<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
ParameterIdentifier<'a>,
|
ParameterIdentifier<'a>,
|
||||||
(Symbol<'a>, Option<ParamExpression<'a>>, Symbol<'a>),
|
Paren<'a, Option<ParamExpression<'a>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +58,7 @@ pub struct NamedParameterAssignment<'a> {
|
|||||||
pub struct HierarchicalInstance<'a> {
|
pub struct HierarchicalInstance<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
NameOfInstance<'a>,
|
NameOfInstance<'a>,
|
||||||
(Symbol<'a>, Option<ListOfPortConnections<'a>>, Symbol<'a>),
|
Paren<'a, Option<ListOfPortConnections<'a>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,18 +75,12 @@ pub enum ListOfPortConnections<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ListOfPortConnectionsOrdered<'a> {
|
pub struct ListOfPortConnectionsOrdered<'a> {
|
||||||
pub nodes: (
|
pub nodes: (List<Symbol<'a>, OrderedPortConnection<'a>>,),
|
||||||
OrderedPortConnection<'a>,
|
|
||||||
Vec<(Symbol<'a>, OrderedPortConnection<'a>)>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ListOfPortConnectionsNamed<'a> {
|
pub struct ListOfPortConnectionsNamed<'a> {
|
||||||
pub nodes: (
|
pub nodes: (List<Symbol<'a>, NamedPortConnection<'a>>,),
|
||||||
NamedPortConnection<'a>,
|
|
||||||
Vec<(Symbol<'a>, NamedPortConnection<'a>)>,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -118,7 +100,7 @@ pub struct NamedPortConnectionIdentifier<'a> {
|
|||||||
Vec<AttributeInstance<'a>>,
|
Vec<AttributeInstance<'a>>,
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
PortIdentifier<'a>,
|
PortIdentifier<'a>,
|
||||||
Option<(Symbol<'a>, Option<Expression<'a>>, Symbol<'a>)>,
|
Option<Paren<'a, Option<Expression<'a>>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,13 +114,12 @@ pub struct NamedPortConnectionAsterisk<'a> {
|
|||||||
pub fn module_instantiation(s: Span) -> IResult<Span, ModuleInstantiation> {
|
pub fn module_instantiation(s: Span) -> IResult<Span, ModuleInstantiation> {
|
||||||
let (s, a) = module_identifier(s)?;
|
let (s, a) = module_identifier(s)?;
|
||||||
let (s, b) = opt(parameter_value_assignment)(s)?;
|
let (s, b) = opt(parameter_value_assignment)(s)?;
|
||||||
let (s, c) = hierarchical_instance(s)?;
|
let (s, c) = list(symbol(","), hierarchical_instance)(s)?;
|
||||||
let (s, d) = many0(pair(symbol(","), hierarchical_instance))(s)?;
|
let (s, d) = symbol(";")(s)?;
|
||||||
let (s, e) = symbol(";")(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ModuleInstantiation {
|
ModuleInstantiation {
|
||||||
nodes: (a, b, c, d, e),
|
nodes: (a, b, c, d),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -157,20 +138,18 @@ pub fn list_of_parameter_assignments(s: Span) -> IResult<Span, ListOfParameterAs
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_parameter_assignments_ordered(s: Span) -> IResult<Span, ListOfParameterAssignments> {
|
pub fn list_of_parameter_assignments_ordered(s: Span) -> IResult<Span, ListOfParameterAssignments> {
|
||||||
let (s, a) = ordered_parameter_assignment(s)?;
|
let (s, a) = list(symbol(","), ordered_parameter_assignment)(s)?;
|
||||||
let (s, b) = many0(pair(symbol(","), ordered_parameter_assignment))(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ListOfParameterAssignments::Ordered(ListOfParameterAssignmentsOrdered { nodes: (a, b) }),
|
ListOfParameterAssignments::Ordered(ListOfParameterAssignmentsOrdered { nodes: (a,) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_parameter_assignments_named(s: Span) -> IResult<Span, ListOfParameterAssignments> {
|
pub fn list_of_parameter_assignments_named(s: Span) -> IResult<Span, ListOfParameterAssignments> {
|
||||||
let (s, a) = named_parameter_assignment(s)?;
|
let (s, a) = list(symbol(","), named_parameter_assignment)(s)?;
|
||||||
let (s, b) = many0(pair(symbol(","), named_parameter_assignment))(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ListOfParameterAssignments::Named(ListOfParameterAssignmentsNamed { nodes: (a, b) }),
|
ListOfParameterAssignments::Named(ListOfParameterAssignmentsNamed { nodes: (a,) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,20 +185,18 @@ pub fn list_of_port_connections(s: Span) -> IResult<Span, ListOfPortConnections>
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_port_connections_ordered(s: Span) -> IResult<Span, ListOfPortConnections> {
|
pub fn list_of_port_connections_ordered(s: Span) -> IResult<Span, ListOfPortConnections> {
|
||||||
let (s, a) = ordered_port_connection(s)?;
|
let (s, a) = list(symbol(","), ordered_port_connection)(s)?;
|
||||||
let (s, b) = many0(pair(symbol(","), ordered_port_connection))(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ListOfPortConnections::Ordered(ListOfPortConnectionsOrdered { nodes: (a, b) }),
|
ListOfPortConnections::Ordered(ListOfPortConnectionsOrdered { nodes: (a,) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_port_connections_named(s: Span) -> IResult<Span, ListOfPortConnections> {
|
pub fn list_of_port_connections_named(s: Span) -> IResult<Span, ListOfPortConnections> {
|
||||||
let (s, a) = named_port_connection(s)?;
|
let (s, a) = list(symbol(","), named_port_connection)(s)?;
|
||||||
let (s, b) = many0(pair(symbol(","), named_port_connection))(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ListOfPortConnections::Named(ListOfPortConnectionsNamed { nodes: (a, b) }),
|
ListOfPortConnections::Named(ListOfPortConnectionsNamed { nodes: (a,) }),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -11,8 +9,7 @@ pub struct ProgramInstantiation<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
ProgramIdentifier<'a>,
|
ProgramIdentifier<'a>,
|
||||||
Option<ParameterValueAssignment<'a>>,
|
Option<ParameterValueAssignment<'a>>,
|
||||||
HierarchicalInstance<'a>,
|
List<Symbol<'a>, HierarchicalInstance<'a>>,
|
||||||
Vec<(Symbol<'a>, HierarchicalInstance<'a>)>,
|
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@ -22,13 +19,12 @@ pub struct ProgramInstantiation<'a> {
|
|||||||
pub fn program_instantiation(s: Span) -> IResult<Span, ProgramInstantiation> {
|
pub fn program_instantiation(s: Span) -> IResult<Span, ProgramInstantiation> {
|
||||||
let (s, a) = program_identifier(s)?;
|
let (s, a) = program_identifier(s)?;
|
||||||
let (s, b) = opt(parameter_value_assignment)(s)?;
|
let (s, b) = opt(parameter_value_assignment)(s)?;
|
||||||
let (s, c) = hierarchical_instance(s)?;
|
let (s, c) = list(symbol(","), hierarchical_instance)(s)?;
|
||||||
let (s, d) = many0(pair(symbol(","), hierarchical_instance))(s)?;
|
let (s, d) = symbol(";")(s)?;
|
||||||
let (s, e) = symbol(";")(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ProgramInstantiation {
|
ProgramInstantiation {
|
||||||
nodes: (a, b, c, d, e),
|
nodes: (a, b, c, d),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,8 @@ pub struct LibraryDeclaration<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
LibraryIdentifier<'a>,
|
LibraryIdentifier<'a>,
|
||||||
FilePathSpec<'a>,
|
List<Symbol<'a>, FilePathSpec<'a>>,
|
||||||
Vec<(Symbol<'a>, FilePathSpec<'a>)>,
|
Option<(Symbol<'a>, List<Symbol<'a>, FilePathSpec<'a>>)>,
|
||||||
Option<(
|
|
||||||
Symbol<'a>,
|
|
||||||
FilePathSpec<'a>,
|
|
||||||
Vec<(Symbol<'a>, FilePathSpec<'a>)>,
|
|
||||||
)>,
|
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@ -71,18 +66,13 @@ pub fn library_description(s: Span) -> IResult<Span, LibraryDescription> {
|
|||||||
pub fn library_declaration(s: Span) -> IResult<Span, LibraryDeclaration> {
|
pub fn library_declaration(s: Span) -> IResult<Span, LibraryDeclaration> {
|
||||||
let (s, a) = symbol("library")(s)?;
|
let (s, a) = symbol("library")(s)?;
|
||||||
let (s, b) = library_identifier(s)?;
|
let (s, b) = library_identifier(s)?;
|
||||||
let (s, c) = file_path_spec(s)?;
|
let (s, c) = list(symbol(","), file_path_spec)(s)?;
|
||||||
let (s, d) = many0(pair(symbol(","), file_path_spec))(s)?;
|
let (s, d) = opt(pair(symbol("-incdir"), list(symbol(","), file_path_spec)))(s)?;
|
||||||
let (s, e) = opt(triple(
|
let (s, e) = symbol(";")(s)?;
|
||||||
symbol("-incdir"),
|
|
||||||
file_path_spec,
|
|
||||||
many0(pair(symbol(","), file_path_spec)),
|
|
||||||
))(s)?;
|
|
||||||
let (s, f) = symbol(";")(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
LibraryDeclaration {
|
LibraryDeclaration {
|
||||||
nodes: (a, b, c, d, e, f),
|
nodes: (a, b, c, d, e),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -100,9 +100,7 @@ pub struct ModuleDeclarationWildcard<'a> {
|
|||||||
ModuleKeyword<'a>,
|
ModuleKeyword<'a>,
|
||||||
Option<Lifetime<'a>>,
|
Option<Lifetime<'a>>,
|
||||||
ModuleIdentifier<'a>,
|
ModuleIdentifier<'a>,
|
||||||
Symbol<'a>,
|
Paren<'a, Symbol<'a>>,
|
||||||
Symbol<'a>,
|
|
||||||
Symbol<'a>,
|
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Option<TimeunitsDeclaration<'a>>,
|
Option<TimeunitsDeclaration<'a>>,
|
||||||
Vec<ModuleItem<'a>>,
|
Vec<ModuleItem<'a>>,
|
||||||
@ -165,9 +163,7 @@ pub struct InterfaceDeclarationWildcard<'a> {
|
|||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Option<Lifetime<'a>>,
|
Option<Lifetime<'a>>,
|
||||||
InterfaceIdentifier<'a>,
|
InterfaceIdentifier<'a>,
|
||||||
Symbol<'a>,
|
Paren<'a, Symbol<'a>>,
|
||||||
Symbol<'a>,
|
|
||||||
Symbol<'a>,
|
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Option<TimeunitsDeclaration<'a>>,
|
Option<TimeunitsDeclaration<'a>>,
|
||||||
Vec<InterfaceItem<'a>>,
|
Vec<InterfaceItem<'a>>,
|
||||||
@ -251,9 +247,7 @@ pub struct ProgramDeclarationWildcard<'a> {
|
|||||||
Vec<AttributeInstance<'a>>,
|
Vec<AttributeInstance<'a>>,
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
ProgramIdentifier<'a>,
|
ProgramIdentifier<'a>,
|
||||||
Symbol<'a>,
|
Paren<'a, Symbol<'a>>,
|
||||||
Symbol<'a>,
|
|
||||||
Symbol<'a>,
|
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Option<TimeunitsDeclaration<'a>>,
|
Option<TimeunitsDeclaration<'a>>,
|
||||||
Vec<ProgramItem<'a>>,
|
Vec<ProgramItem<'a>>,
|
||||||
@ -305,7 +299,7 @@ pub struct CheckerDeclaration<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
CheckerIdentifier<'a>,
|
CheckerIdentifier<'a>,
|
||||||
Option<(Symbol<'a>, Option<CheckerPortList<'a>>, Symbol<'a>)>,
|
Option<Paren<'a, Option<CheckerPortList<'a>>>>,
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Vec<(Vec<AttributeInstance<'a>>, CheckerOrGenerateItem<'a>)>,
|
Vec<(Vec<AttributeInstance<'a>>, CheckerOrGenerateItem<'a>)>,
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
@ -324,13 +318,9 @@ pub struct ClassDeclaration<'a> {
|
|||||||
Option<(
|
Option<(
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
ClassType<'a>,
|
ClassType<'a>,
|
||||||
Option<(Symbol<'a>, ListOfArguments<'a>, Symbol<'a>)>,
|
Option<Paren<'a, ListOfArguments<'a>>>,
|
||||||
)>,
|
|
||||||
Option<(
|
|
||||||
Symbol<'a>,
|
|
||||||
InterfaceClassType<'a>,
|
|
||||||
Vec<(Symbol<'a>, InterfaceClassType<'a>)>,
|
|
||||||
)>,
|
)>,
|
||||||
|
Option<(Symbol<'a>, List<Symbol<'a>, InterfaceClassType<'a>>)>,
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Vec<ClassItem<'a>>,
|
Vec<ClassItem<'a>>,
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
@ -355,11 +345,7 @@ pub struct InterfaceClassDeclaration<'a> {
|
|||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
ClassIdentifier<'a>,
|
ClassIdentifier<'a>,
|
||||||
Option<ParameterPortList<'a>>,
|
Option<ParameterPortList<'a>>,
|
||||||
Option<(
|
Option<(Symbol<'a>, List<Symbol<'a>, InterfaceClassType<'a>>)>,
|
||||||
Symbol<'a>,
|
|
||||||
InterfaceClassType<'a>,
|
|
||||||
Vec<(Symbol<'a>, InterfaceClassType<'a>)>,
|
|
||||||
)>,
|
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Vec<InterfaceClassItem<'a>>,
|
Vec<InterfaceClassItem<'a>>,
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
@ -566,18 +552,16 @@ pub fn module_declaration_wildcard(s: Span) -> IResult<Span, ModuleDeclaration>
|
|||||||
let (s, b) = module_keyword(s)?;
|
let (s, b) = module_keyword(s)?;
|
||||||
let (s, c) = opt(lifetime)(s)?;
|
let (s, c) = opt(lifetime)(s)?;
|
||||||
let (s, d) = module_identifier(s)?;
|
let (s, d) = module_identifier(s)?;
|
||||||
let (s, e) = symbol("(")(s)?;
|
let (s, e) = paren2(symbol(".*"))(s)?;
|
||||||
let (s, f) = symbol(".*")(s)?;
|
let (s, f) = symbol(";")(s)?;
|
||||||
let (s, g) = symbol(")")(s)?;
|
let (s, g) = opt(timeunits_declaration)(s)?;
|
||||||
let (s, h) = symbol(";")(s)?;
|
let (s, h) = many0(module_item)(s)?;
|
||||||
let (s, i) = opt(timeunits_declaration)(s)?;
|
let (s, i) = symbol("endmodule")(s)?;
|
||||||
let (s, j) = many0(module_item)(s)?;
|
let (s, j) = opt(pair(symbol(":"), module_identifier))(s)?;
|
||||||
let (s, k) = symbol("endmodule")(s)?;
|
|
||||||
let (s, l) = opt(pair(symbol(":"), module_identifier))(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ModuleDeclaration::Wildcard(ModuleDeclarationWildcard {
|
ModuleDeclaration::Wildcard(ModuleDeclarationWildcard {
|
||||||
nodes: (a, b, c, d, e, f, g, h, i, j, k, l),
|
nodes: (a, b, c, d, e, f, g, h, i, j),
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -650,18 +634,16 @@ pub fn interface_declaration_wildcard(s: Span) -> IResult<Span, InterfaceDeclara
|
|||||||
let (s, b) = symbol("interface")(s)?;
|
let (s, b) = symbol("interface")(s)?;
|
||||||
let (s, c) = opt(lifetime)(s)?;
|
let (s, c) = opt(lifetime)(s)?;
|
||||||
let (s, d) = interface_identifier(s)?;
|
let (s, d) = interface_identifier(s)?;
|
||||||
let (s, e) = symbol("(")(s)?;
|
let (s, e) = paren2(symbol(".*"))(s)?;
|
||||||
let (s, f) = symbol(".*")(s)?;
|
let (s, f) = symbol(";")(s)?;
|
||||||
let (s, g) = symbol(")")(s)?;
|
let (s, g) = opt(timeunits_declaration)(s)?;
|
||||||
let (s, h) = symbol(";")(s)?;
|
let (s, h) = many0(interface_item)(s)?;
|
||||||
let (s, i) = opt(timeunits_declaration)(s)?;
|
let (s, i) = symbol("endinterface")(s)?;
|
||||||
let (s, j) = many0(interface_item)(s)?;
|
let (s, j) = opt(pair(symbol(":"), interface_identifier))(s)?;
|
||||||
let (s, k) = symbol("endinterface")(s)?;
|
|
||||||
let (s, l) = opt(pair(symbol(":"), interface_identifier))(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
InterfaceDeclaration::Wildcard(InterfaceDeclarationWildcard {
|
InterfaceDeclaration::Wildcard(InterfaceDeclarationWildcard {
|
||||||
nodes: (a, b, c, d, e, f, g, h, i, j, k, l),
|
nodes: (a, b, c, d, e, f, g, h, i, j),
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -760,18 +742,16 @@ pub fn program_declaration_wildcard(s: Span) -> IResult<Span, ProgramDeclaration
|
|||||||
let (s, a) = many0(attribute_instance)(s)?;
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
let (s, b) = symbol("program")(s)?;
|
let (s, b) = symbol("program")(s)?;
|
||||||
let (s, c) = program_identifier(s)?;
|
let (s, c) = program_identifier(s)?;
|
||||||
let (s, d) = symbol("(")(s)?;
|
let (s, d) = paren2(symbol(".*"))(s)?;
|
||||||
let (s, e) = symbol(".*")(s)?;
|
let (s, e) = symbol(";")(s)?;
|
||||||
let (s, f) = symbol(")")(s)?;
|
let (s, f) = opt(timeunits_declaration)(s)?;
|
||||||
let (s, g) = symbol(";")(s)?;
|
let (s, g) = many0(program_item)(s)?;
|
||||||
let (s, h) = opt(timeunits_declaration)(s)?;
|
let (s, h) = symbol("endprogram")(s)?;
|
||||||
let (s, i) = many0(program_item)(s)?;
|
let (s, i) = opt(pair(symbol(":"), program_identifier))(s)?;
|
||||||
let (s, j) = symbol("endprogram")(s)?;
|
|
||||||
let (s, k) = opt(pair(symbol(":"), program_identifier))(s)?;
|
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
ProgramDeclaration::Wildcard(ProgramDeclarationWildcard {
|
ProgramDeclaration::Wildcard(ProgramDeclarationWildcard {
|
||||||
nodes: (a, b, c, d, e, f, g, h, i, j, k),
|
nodes: (a, b, c, d, e, f, g, h, i),
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -831,7 +811,7 @@ pub fn program_ansi_header(s: Span) -> IResult<Span, ProgramAnsiHeader> {
|
|||||||
pub fn checker_declaration(s: Span) -> IResult<Span, CheckerDeclaration> {
|
pub fn checker_declaration(s: Span) -> IResult<Span, CheckerDeclaration> {
|
||||||
let (s, a) = symbol("checker")(s)?;
|
let (s, a) = symbol("checker")(s)?;
|
||||||
let (s, b) = checker_identifier(s)?;
|
let (s, b) = checker_identifier(s)?;
|
||||||
let (s, c) = opt(triple(symbol("("), opt(checker_port_list), symbol(")")))(s)?;
|
let (s, c) = opt(paren2(opt(checker_port_list)))(s)?;
|
||||||
let (s, d) = symbol(";")(s)?;
|
let (s, d) = symbol(";")(s)?;
|
||||||
let (s, e) = many0(pair(many0(attribute_instance), checker_or_generate_item))(s)?;
|
let (s, e) = many0(pair(many0(attribute_instance), checker_or_generate_item))(s)?;
|
||||||
let (s, f) = symbol("endchecker")(s)?;
|
let (s, f) = symbol("endchecker")(s)?;
|
||||||
@ -853,12 +833,11 @@ pub fn class_declaration(s: Span) -> IResult<Span, ClassDeclaration> {
|
|||||||
let (s, f) = opt(triple(
|
let (s, f) = opt(triple(
|
||||||
symbol("extends"),
|
symbol("extends"),
|
||||||
class_type,
|
class_type,
|
||||||
opt(triple(symbol("("), list_of_arguments, symbol(")"))),
|
opt(paren2(list_of_arguments)),
|
||||||
))(s)?;
|
))(s)?;
|
||||||
let (s, g) = opt(triple(
|
let (s, g) = opt(pair(
|
||||||
symbol("implements"),
|
symbol("implements"),
|
||||||
interface_class_type,
|
list(symbol(","), interface_class_type),
|
||||||
many0(pair(symbol(","), interface_class_type)),
|
|
||||||
))(s)?;
|
))(s)?;
|
||||||
let (s, h) = symbol(";")(s)?;
|
let (s, h) = symbol(";")(s)?;
|
||||||
let (s, i) = many0(class_item)(s)?;
|
let (s, i) = many0(class_item)(s)?;
|
||||||
@ -883,10 +862,9 @@ pub fn interface_class_declaration(s: Span) -> IResult<Span, InterfaceClassDecla
|
|||||||
let (s, b) = symbol("class")(s)?;
|
let (s, b) = symbol("class")(s)?;
|
||||||
let (s, c) = class_identifier(s)?;
|
let (s, c) = class_identifier(s)?;
|
||||||
let (s, d) = opt(parameter_port_list)(s)?;
|
let (s, d) = opt(parameter_port_list)(s)?;
|
||||||
let (s, e) = opt(triple(
|
let (s, e) = opt(pair(
|
||||||
symbol("extends"),
|
symbol("extends"),
|
||||||
interface_class_type,
|
list(symbol(","), interface_class_type),
|
||||||
many0(pair(symbol(","), interface_class_type)),
|
|
||||||
))(s)?;
|
))(s)?;
|
||||||
let (s, f) = symbol(";")(s)?;
|
let (s, f) = symbol(";")(s)?;
|
||||||
let (s, g) = many0(interface_class_item)(s)?;
|
let (s, g) = many0(interface_class_item)(s)?;
|
||||||
|
@ -20,6 +20,31 @@ pub enum WhiteSpace<'a> {
|
|||||||
Comment(Comment<'a>),
|
Comment(Comment<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Paren<'a, T: 'a> {
|
||||||
|
pub nodes: (Symbol<'a>, T, Symbol<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Brace<'a, T: 'a> {
|
||||||
|
pub nodes: (Symbol<'a>, T, Symbol<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Bracket<'a, T: 'a> {
|
||||||
|
pub nodes: (Symbol<'a>, T, Symbol<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ApostropheBrace<'a, T: 'a> {
|
||||||
|
pub nodes: (Symbol<'a>, T, Symbol<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct List<U, T> {
|
||||||
|
pub nodes: (T, Vec<(U, T)>),
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn ws<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, (O, Vec<WhiteSpace<'a>>)>
|
pub fn ws<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, (O, Vec<WhiteSpace<'a>>)>
|
||||||
@ -37,7 +62,7 @@ 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>)>
|
pub fn paren2<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, Paren<O>>
|
||||||
where
|
where
|
||||||
F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
|
F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
|
||||||
{
|
{
|
||||||
@ -45,13 +70,11 @@ where
|
|||||||
let (s, a) = symbol("(")(s)?;
|
let (s, a) = symbol("(")(s)?;
|
||||||
let (s, b) = f(s)?;
|
let (s, b) = f(s)?;
|
||||||
let (s, c) = symbol(")")(s)?;
|
let (s, c) = symbol(")")(s)?;
|
||||||
Ok((s, (a, b, c)))
|
Ok((s, Paren { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bracket2<'a, O, F>(
|
pub fn bracket2<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, Bracket<O>>
|
||||||
f: F,
|
|
||||||
) -> impl Fn(Span<'a>) -> IResult<Span<'a>, (Symbol<'a>, O, Symbol<'a>)>
|
|
||||||
where
|
where
|
||||||
F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
|
F: Fn(Span<'a>) -> IResult<Span<'a>, O>,
|
||||||
{
|
{
|
||||||
@ -59,7 +82,55 @@ where
|
|||||||
let (s, a) = symbol("[")(s)?;
|
let (s, a) = symbol("[")(s)?;
|
||||||
let (s, b) = f(s)?;
|
let (s, b) = f(s)?;
|
||||||
let (s, c) = symbol("]")(s)?;
|
let (s, c) = symbol("]")(s)?;
|
||||||
Ok((s, (a, b, c)))
|
Ok((s, Bracket { nodes: (a, b, c) }))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn brace2<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, Brace<O>>
|
||||||
|
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, Brace { nodes: (a, b, c) }))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn apostrophe_brace2<'a, O, F>(
|
||||||
|
f: F,
|
||||||
|
) -> impl Fn(Span<'a>) -> IResult<Span<'a>, ApostropheBrace<O>>
|
||||||
|
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, ApostropheBrace { nodes: (a, b, c) }))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn list<'a, O1, O2, F, G>(f: F, g: G) -> impl Fn(Span<'a>) -> IResult<Span<'a>, List<O1, O2>>
|
||||||
|
where
|
||||||
|
F: Fn(Span<'a>) -> IResult<Span<'a>, O1>,
|
||||||
|
G: Fn(Span<'a>) -> IResult<Span<'a>, O2>,
|
||||||
|
{
|
||||||
|
move |s: Span<'a>| {
|
||||||
|
let (s, a) = g(s)?;
|
||||||
|
let mut s = s.clone();
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
loop {
|
||||||
|
if let Ok((t, b)) = f(s) {
|
||||||
|
let (u, c) = g(t)?;
|
||||||
|
s = u;
|
||||||
|
ret.push((b, c));
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok((s, List { nodes: (a, ret) }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user