Refactoring
This commit is contained in:
parent
164016ef80
commit
dfbd0718f9
26
README.md
26
README.md
@ -9,26 +9,26 @@ A parser library for System Verilog.
|
|||||||
| source_text | system_verilog_source_text | x | x | |
|
| source_text | system_verilog_source_text | x | x | |
|
||||||
| source_text | module_parameters_and_ports | x | x | |
|
| source_text | module_parameters_and_ports | x | x | |
|
||||||
| source_text | module_items | x | x | |
|
| source_text | module_items | x | x | |
|
||||||
| source_text | configuration_source_text | | | |
|
| source_text | configuration_source_text | x | x | |
|
||||||
| source_text | interface_items | | | |
|
| source_text | interface_items | x | x | |
|
||||||
| source_text | program_items | | | |
|
| source_text | program_items | x | x | |
|
||||||
| source_text | checker_items | | | |
|
| source_text | checker_items | x | x | |
|
||||||
| source_text | class_items | | | |
|
| source_text | class_items | x | x | |
|
||||||
| source_text | constraints | | | |
|
| source_text | constraints | x | x | |
|
||||||
| source_text | package_items | x | x | |
|
| source_text | package_items | x | x | |
|
||||||
| declaration | module_parameter_declarations | x | x | |
|
| declaration | module_parameter_declarations | x | x | |
|
||||||
| declaration | port_declarations | x | x | |
|
| declaration | port_declarations | x | x | |
|
||||||
| declaration | type_declarations | x | x | |
|
| declaration | type_declarations | x | x | |
|
||||||
| declaration | net_and_variable_types | x | | |
|
| declaration | net_and_variable_types | x | x | |
|
||||||
| declaration | strengths | x | x | x |
|
| declaration | strengths | x | x | x |
|
||||||
| declaration | delays | x | x | |
|
| declaration | delays | x | x | |
|
||||||
| declaration | declaration_lists | x | | |
|
| declaration | declaration_lists | x | x | |
|
||||||
| declaration | declaration_assignments | x | | |
|
| declaration | declaration_assignments | x | x | |
|
||||||
| declaration | declaration_ranges | x | | |
|
| declaration | declaration_ranges | x | x | |
|
||||||
| declaration | function_declarations | x | | |
|
| declaration | function_declarations | x | x | |
|
||||||
| declaration | task_declarations | x | | |
|
| declaration | task_declarations | x | x | |
|
||||||
| declaration | block_item_declarations | x | x | |
|
| declaration | block_item_declarations | x | x | |
|
||||||
| declaration | interface_declarations | x | | |
|
| declaration | interface_declarations | x | x | |
|
||||||
| declaration | assertion_declarations | x | | |
|
| declaration | assertion_declarations | x | | |
|
||||||
| declaration | covergroup_declarations | | | |
|
| declaration | covergroup_declarations | | | |
|
||||||
| declaration | let_declarations | | | |
|
| declaration | let_declarations | | | |
|
||||||
|
@ -35,30 +35,9 @@ fn impl_node(ast: &syn::DeriveInput) -> TokenStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
syn::Data::Struct(ref data) => {
|
syn::Data::Struct(_) => {
|
||||||
let mut items = quote! {};
|
|
||||||
if let syn::Fields::Named(f) = &data.fields {
|
|
||||||
for f in &f.named {
|
|
||||||
if let Some(ident) = &f.ident {
|
|
||||||
if ident.to_string() == "nodes" {
|
|
||||||
if let syn::Type::Tuple(t) = &f.ty {
|
|
||||||
for i in 0..t.elems.len() {
|
|
||||||
let i = syn::Index::from(i);
|
|
||||||
items = quote! {
|
|
||||||
#items
|
|
||||||
let mut nodes : AnyNodes = (&(self.nodes.#i)).into();
|
|
||||||
ret.append(&mut nodes.0);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
quote! {
|
quote! {
|
||||||
let mut ret = Vec::new();
|
(&(self.nodes)).into()
|
||||||
#items
|
|
||||||
ret.into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -67,6 +67,18 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a, T0: 'a> From<&'a (T0,)> for AnyNodes<'a>
|
||||||
|
where
|
||||||
|
&'a T0: Into<AnyNodes<'a>>,
|
||||||
|
{
|
||||||
|
fn from(x: &'a (T0,)) -> Self {
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
let (t0,) = x;
|
||||||
|
ret.append(&mut t0.into().0);
|
||||||
|
ret.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a, T0: 'a, T1: 'a> From<&'a (T0, T1)> for AnyNodes<'a>
|
impl<'a, T0: 'a, T1: 'a> From<&'a (T0, T1)> for AnyNodes<'a>
|
||||||
where
|
where
|
||||||
&'a T0: Into<AnyNodes<'a>>,
|
&'a T0: Into<AnyNodes<'a>>,
|
||||||
@ -183,6 +195,138 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a, T0: 'a, T1: 'a, T2: 'a, T3: 'a, T4: 'a, T5: 'a, T6: 'a, T7: 'a>
|
||||||
|
From<&'a (T0, T1, T2, T3, T4, T5, T6, T7)> for AnyNodes<'a>
|
||||||
|
where
|
||||||
|
&'a T0: Into<AnyNodes<'a>>,
|
||||||
|
&'a T1: Into<AnyNodes<'a>>,
|
||||||
|
&'a T2: Into<AnyNodes<'a>>,
|
||||||
|
&'a T3: Into<AnyNodes<'a>>,
|
||||||
|
&'a T4: Into<AnyNodes<'a>>,
|
||||||
|
&'a T5: Into<AnyNodes<'a>>,
|
||||||
|
&'a T6: Into<AnyNodes<'a>>,
|
||||||
|
&'a T7: Into<AnyNodes<'a>>,
|
||||||
|
{
|
||||||
|
fn from(x: &'a (T0, T1, T2, T3, T4, T5, T6, T7)) -> Self {
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
let (t0, t1, t2, t3, t4, t5, t6, t7) = x;
|
||||||
|
ret.append(&mut t0.into().0);
|
||||||
|
ret.append(&mut t1.into().0);
|
||||||
|
ret.append(&mut t2.into().0);
|
||||||
|
ret.append(&mut t3.into().0);
|
||||||
|
ret.append(&mut t4.into().0);
|
||||||
|
ret.append(&mut t5.into().0);
|
||||||
|
ret.append(&mut t6.into().0);
|
||||||
|
ret.append(&mut t7.into().0);
|
||||||
|
ret.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, T0: 'a, T1: 'a, T2: 'a, T3: 'a, T4: 'a, T5: 'a, T6: 'a, T7: 'a, T8: 'a>
|
||||||
|
From<&'a (T0, T1, T2, T3, T4, T5, T6, T7, T8)> for AnyNodes<'a>
|
||||||
|
where
|
||||||
|
&'a T0: Into<AnyNodes<'a>>,
|
||||||
|
&'a T1: Into<AnyNodes<'a>>,
|
||||||
|
&'a T2: Into<AnyNodes<'a>>,
|
||||||
|
&'a T3: Into<AnyNodes<'a>>,
|
||||||
|
&'a T4: Into<AnyNodes<'a>>,
|
||||||
|
&'a T5: Into<AnyNodes<'a>>,
|
||||||
|
&'a T6: Into<AnyNodes<'a>>,
|
||||||
|
&'a T7: Into<AnyNodes<'a>>,
|
||||||
|
&'a T8: Into<AnyNodes<'a>>,
|
||||||
|
{
|
||||||
|
fn from(x: &'a (T0, T1, T2, T3, T4, T5, T6, T7, T8)) -> Self {
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
let (t0, t1, t2, t3, t4, t5, t6, t7, t8) = x;
|
||||||
|
ret.append(&mut t0.into().0);
|
||||||
|
ret.append(&mut t1.into().0);
|
||||||
|
ret.append(&mut t2.into().0);
|
||||||
|
ret.append(&mut t3.into().0);
|
||||||
|
ret.append(&mut t4.into().0);
|
||||||
|
ret.append(&mut t5.into().0);
|
||||||
|
ret.append(&mut t6.into().0);
|
||||||
|
ret.append(&mut t7.into().0);
|
||||||
|
ret.append(&mut t8.into().0);
|
||||||
|
ret.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, T0: 'a, T1: 'a, T2: 'a, T3: 'a, T4: 'a, T5: 'a, T6: 'a, T7: 'a, T8: 'a, T9: 'a>
|
||||||
|
From<&'a (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> for AnyNodes<'a>
|
||||||
|
where
|
||||||
|
&'a T0: Into<AnyNodes<'a>>,
|
||||||
|
&'a T1: Into<AnyNodes<'a>>,
|
||||||
|
&'a T2: Into<AnyNodes<'a>>,
|
||||||
|
&'a T3: Into<AnyNodes<'a>>,
|
||||||
|
&'a T4: Into<AnyNodes<'a>>,
|
||||||
|
&'a T5: Into<AnyNodes<'a>>,
|
||||||
|
&'a T6: Into<AnyNodes<'a>>,
|
||||||
|
&'a T7: Into<AnyNodes<'a>>,
|
||||||
|
&'a T8: Into<AnyNodes<'a>>,
|
||||||
|
&'a T9: Into<AnyNodes<'a>>,
|
||||||
|
{
|
||||||
|
fn from(x: &'a (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)) -> Self {
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = x;
|
||||||
|
ret.append(&mut t0.into().0);
|
||||||
|
ret.append(&mut t1.into().0);
|
||||||
|
ret.append(&mut t2.into().0);
|
||||||
|
ret.append(&mut t3.into().0);
|
||||||
|
ret.append(&mut t4.into().0);
|
||||||
|
ret.append(&mut t5.into().0);
|
||||||
|
ret.append(&mut t6.into().0);
|
||||||
|
ret.append(&mut t7.into().0);
|
||||||
|
ret.append(&mut t8.into().0);
|
||||||
|
ret.append(&mut t9.into().0);
|
||||||
|
ret.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<
|
||||||
|
'a,
|
||||||
|
T0: 'a,
|
||||||
|
T1: 'a,
|
||||||
|
T2: 'a,
|
||||||
|
T3: 'a,
|
||||||
|
T4: 'a,
|
||||||
|
T5: 'a,
|
||||||
|
T6: 'a,
|
||||||
|
T7: 'a,
|
||||||
|
T8: 'a,
|
||||||
|
T9: 'a,
|
||||||
|
T10: 'a,
|
||||||
|
> From<&'a (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> for AnyNodes<'a>
|
||||||
|
where
|
||||||
|
&'a T0: Into<AnyNodes<'a>>,
|
||||||
|
&'a T1: Into<AnyNodes<'a>>,
|
||||||
|
&'a T2: Into<AnyNodes<'a>>,
|
||||||
|
&'a T3: Into<AnyNodes<'a>>,
|
||||||
|
&'a T4: Into<AnyNodes<'a>>,
|
||||||
|
&'a T5: Into<AnyNodes<'a>>,
|
||||||
|
&'a T6: Into<AnyNodes<'a>>,
|
||||||
|
&'a T7: Into<AnyNodes<'a>>,
|
||||||
|
&'a T8: Into<AnyNodes<'a>>,
|
||||||
|
&'a T9: Into<AnyNodes<'a>>,
|
||||||
|
&'a T10: Into<AnyNodes<'a>>,
|
||||||
|
{
|
||||||
|
fn from(x: &'a (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)) -> Self {
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) = x;
|
||||||
|
ret.append(&mut t0.into().0);
|
||||||
|
ret.append(&mut t1.into().0);
|
||||||
|
ret.append(&mut t2.into().0);
|
||||||
|
ret.append(&mut t3.into().0);
|
||||||
|
ret.append(&mut t4.into().0);
|
||||||
|
ret.append(&mut t5.into().0);
|
||||||
|
ret.append(&mut t6.into().0);
|
||||||
|
ret.append(&mut t7.into().0);
|
||||||
|
ret.append(&mut t8.into().0);
|
||||||
|
ret.append(&mut t9.into().0);
|
||||||
|
ret.append(&mut t10.into().0);
|
||||||
|
ret.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a, T> From<&'a Paren<'a, T>> for AnyNodes<'a>
|
impl<'a, T> From<&'a Paren<'a, T>> for AnyNodes<'a>
|
||||||
where
|
where
|
||||||
&'a T: Into<AnyNodes<'a>>,
|
&'a T: Into<AnyNodes<'a>>,
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
//use nom::branch::*;
|
use nom::branch::*;
|
||||||
//use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::error::*;
|
use nom::multi::*;
|
||||||
use nom::{Err, IResult};
|
use nom::sequence::*;
|
||||||
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ pub struct ParamAssignment<'a> {
|
|||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub enum SpecparamAssignment<'a> {
|
pub enum SpecparamAssignment<'a> {
|
||||||
Mintypmax(SpecparamAssignmentMintypmax<'a>),
|
Mintypmax(SpecparamAssignmentMintypmax<'a>),
|
||||||
PulseControl(PulseControlSpecparam<'a>),
|
PulseControlSpecparam(PulseControlSpecparam<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -167,56 +168,176 @@ pub struct DynamicArrayNew<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Bracket<'a, Expression<'a>>,
|
Bracket<'a, Expression<'a>>,
|
||||||
Option<Bracket<'a, Expression<'a>>>,
|
Option<Paren<'a, Expression<'a>>>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn defparam_assignment(s: Span) -> IResult<Span, DefparamAssignment> {
|
pub fn defparam_assignment(s: Span) -> IResult<Span, DefparamAssignment> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = hierarchical_parameter_identifier(s)?;
|
||||||
|
let (s, b) = symbol("=")(s)?;
|
||||||
|
let (s, c) = constant_mintypmax_expression(s)?;
|
||||||
|
Ok((s, DefparamAssignment { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn net_decl_assignment(s: Span) -> IResult<Span, NetDeclAssignment> {
|
pub fn net_decl_assignment(s: Span) -> IResult<Span, NetDeclAssignment> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = net_identifier(s)?;
|
||||||
|
let (s, b) = many0(unpacked_dimension)(s)?;
|
||||||
|
let (s, c) = opt(pair(symbol("="), expression))(s)?;
|
||||||
|
Ok((s, NetDeclAssignment { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn param_assignment(s: Span) -> IResult<Span, ParamAssignment> {
|
pub fn param_assignment(s: Span) -> IResult<Span, ParamAssignment> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = parameter_identifier(s)?;
|
||||||
|
let (s, b) = many0(unpacked_dimension)(s)?;
|
||||||
|
let (s, c) = opt(pair(symbol("="), constant_param_expression))(s)?;
|
||||||
|
Ok((s, ParamAssignment { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn specparam_assignment(s: Span) -> IResult<Span, SpecparamAssignment> {
|
pub fn specparam_assignment(s: Span) -> IResult<Span, SpecparamAssignment> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
specparam_assignment_mintypmax,
|
||||||
|
map(pulse_control_specparam, |x| {
|
||||||
|
SpecparamAssignment::PulseControlSpecparam(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn specparam_assignment_mintypmax(s: Span) -> IResult<Span, SpecparamAssignment> {
|
||||||
|
let (s, a) = specparam_identifier(s)?;
|
||||||
|
let (s, b) = symbol("=")(s)?;
|
||||||
|
let (s, c) = constant_mintypmax_expression(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
SpecparamAssignment::Mintypmax(SpecparamAssignmentMintypmax { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn type_assignment(s: Span) -> IResult<Span, TypeAssignment> {
|
pub fn type_assignment(s: Span) -> IResult<Span, TypeAssignment> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = type_identifier(s)?;
|
||||||
|
let (s, b) = opt(pair(symbol("="), data_type))(s)?;
|
||||||
|
Ok((s, TypeAssignment { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pulse_control_specparam(s: Span) -> IResult<Span, PulseControlSpecparam> {
|
pub fn pulse_control_specparam(s: Span) -> IResult<Span, PulseControlSpecparam> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
pulse_control_specparam_without_descriptor,
|
||||||
|
pulse_control_specparam_with_descriptor,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn pulse_control_specparam_without_descriptor(s: Span) -> IResult<Span, PulseControlSpecparam> {
|
||||||
|
let (s, a) = symbol("PATHPULSE$")(s)?;
|
||||||
|
let (s, b) = symbol("=")(s)?;
|
||||||
|
let (s, c) = paren(pair(
|
||||||
|
reject_limit_value,
|
||||||
|
opt(pair(symbol(","), error_limit_value)),
|
||||||
|
))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
PulseControlSpecparam::WithoutDescriptor(PulseControlSpecparamWithoutDescriptor {
|
||||||
|
nodes: (a, b, c),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn pulse_control_specparam_with_descriptor(s: Span) -> IResult<Span, PulseControlSpecparam> {
|
||||||
|
let (s, a) = symbol("PATHPULSE$")(s)?;
|
||||||
|
let (s, b) = specify_input_terminal_descriptor(s)?;
|
||||||
|
let (s, c) = symbol("$")(s)?;
|
||||||
|
let (s, d) = specify_output_terminal_descriptor(s)?;
|
||||||
|
let (s, e) = symbol("=")(s)?;
|
||||||
|
let (s, f) = paren(pair(
|
||||||
|
reject_limit_value,
|
||||||
|
opt(pair(symbol(","), error_limit_value)),
|
||||||
|
))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
PulseControlSpecparam::WithDescriptor(PulseControlSpecparamWithDescriptor {
|
||||||
|
nodes: (a, b, c, d, e, f),
|
||||||
|
}),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn error_limit_value(s: Span) -> IResult<Span, ErrorLimitValue> {
|
pub fn error_limit_value(s: Span) -> IResult<Span, ErrorLimitValue> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = limit_value(s)?;
|
||||||
|
Ok((s, ErrorLimitValue { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reject_limit_value(s: Span) -> IResult<Span, RejectLimitValue> {
|
pub fn reject_limit_value(s: Span) -> IResult<Span, RejectLimitValue> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = limit_value(s)?;
|
||||||
|
Ok((s, RejectLimitValue { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn limit_value(s: Span) -> IResult<Span, LimitValue> {
|
pub fn limit_value(s: Span) -> IResult<Span, LimitValue> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = constant_mintypmax_expression(s)?;
|
||||||
|
Ok((s, LimitValue { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn variable_decl_assignment(s: Span) -> IResult<Span, VariableDeclAssignment> {
|
pub fn variable_decl_assignment(s: Span) -> IResult<Span, VariableDeclAssignment> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
variable_decl_assignment_variable,
|
||||||
|
variable_decl_assignment_dynamic_array,
|
||||||
|
variable_decl_assignment_class,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn variable_decl_assignment_variable(s: Span) -> IResult<Span, VariableDeclAssignment> {
|
||||||
|
let (s, a) = variable_identifier(s)?;
|
||||||
|
let (s, b) = many0(variable_dimension)(s)?;
|
||||||
|
let (s, c) = opt(pair(symbol("="), expression))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
VariableDeclAssignment::Variable(VariableDeclAssignmentVariable { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn variable_decl_assignment_dynamic_array(s: Span) -> IResult<Span, VariableDeclAssignment> {
|
||||||
|
let (s, a) = dynamic_array_variable_identifier(s)?;
|
||||||
|
let (s, b) = unsized_dimension(s)?;
|
||||||
|
let (s, c) = many0(variable_dimension)(s)?;
|
||||||
|
let (s, d) = opt(pair(symbol("="), dynamic_array_new))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
VariableDeclAssignment::DynamicArray(VariableDeclAssignmentDynamicArray {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn variable_decl_assignment_class(s: Span) -> IResult<Span, VariableDeclAssignment> {
|
||||||
|
let (s, a) = class_variable_identifier(s)?;
|
||||||
|
let (s, b) = opt(pair(symbol("="), class_new))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
VariableDeclAssignment::Class(VariableDeclAssignmentClass { nodes: (a, b) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn class_new(s: Span) -> IResult<Span, ClassNew> {
|
pub fn class_new(s: Span) -> IResult<Span, ClassNew> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((class_new_argument, class_new_expression))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_new_argument(s: Span) -> IResult<Span, ClassNew> {
|
||||||
|
let (s, a) = opt(class_scope)(s)?;
|
||||||
|
let (s, b) = symbol("new")(s)?;
|
||||||
|
let (s, c) = opt(paren(list_of_arguments))(s)?;
|
||||||
|
Ok((s, ClassNew::Argument(ClassNewArgument { nodes: (a, b, c) })))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_new_expression(s: Span) -> IResult<Span, ClassNew> {
|
||||||
|
let (s, a) = symbol("new")(s)?;
|
||||||
|
let (s, b) = expression(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ClassNew::Expression(ClassNewExpression { nodes: (a, b) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dynamic_array_new(s: Span) -> IResult<Span, DynamicArrayNew> {
|
pub fn dynamic_array_new(s: Span) -> IResult<Span, DynamicArrayNew> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("new")(s)?;
|
||||||
|
let (s, b) = bracket(expression)(s)?;
|
||||||
|
let (s, c) = opt(paren(expression))(s)?;
|
||||||
|
Ok((s, DynamicArrayNew { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
//use nom::branch::*;
|
use nom::combinator::*;
|
||||||
//use nom::combinator::*;
|
use nom::multi::*;
|
||||||
use nom::error::*;
|
use nom::sequence::*;
|
||||||
use nom::{Err, IResult};
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -93,53 +93,89 @@ pub struct ListOfVariablePortIdentifiers<'a> {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn list_of_defparam_assignments(s: Span) -> IResult<Span, ListOfDefparamAssignments> {
|
pub fn list_of_defparam_assignments(s: Span) -> IResult<Span, ListOfDefparamAssignments> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(symbol(","), defparam_assignment)(s)?;
|
||||||
|
Ok((s, ListOfDefparamAssignments { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_genvar_identifiers(s: Span) -> IResult<Span, ListOfGenvarIdentifiers> {
|
pub fn list_of_genvar_identifiers(s: Span) -> IResult<Span, ListOfGenvarIdentifiers> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(symbol(","), genvar_identifier)(s)?;
|
||||||
|
Ok((s, ListOfGenvarIdentifiers { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_interface_identifiers(s: Span) -> IResult<Span, ListOfInterfaceIdentifiers> {
|
pub fn list_of_interface_identifiers(s: Span) -> IResult<Span, ListOfInterfaceIdentifiers> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(
|
||||||
|
symbol(","),
|
||||||
|
pair(interface_identifier, many0(unpacked_dimension)),
|
||||||
|
)(s)?;
|
||||||
|
Ok((s, ListOfInterfaceIdentifiers { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_net_decl_assignments(s: Span) -> IResult<Span, ListOfNetDeclAssignments> {
|
pub fn list_of_net_decl_assignments(s: Span) -> IResult<Span, ListOfNetDeclAssignments> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(symbol(","), net_decl_assignment)(s)?;
|
||||||
|
Ok((s, ListOfNetDeclAssignments { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_param_assignments(s: Span) -> IResult<Span, ListOfParamAssignments> {
|
pub fn list_of_param_assignments(s: Span) -> IResult<Span, ListOfParamAssignments> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(symbol(","), param_assignment)(s)?;
|
||||||
|
Ok((s, ListOfParamAssignments { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_port_identifiers(s: Span) -> IResult<Span, ListOfPortIdentifiers> {
|
pub fn list_of_port_identifiers(s: Span) -> IResult<Span, ListOfPortIdentifiers> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(
|
||||||
|
symbol(","),
|
||||||
|
pair(port_identifier, many0(unpacked_dimension)),
|
||||||
|
)(s)?;
|
||||||
|
Ok((s, ListOfPortIdentifiers { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_udp_port_identifiers(s: Span) -> IResult<Span, ListOfUdpPortIdentifiers> {
|
pub fn list_of_udp_port_identifiers(s: Span) -> IResult<Span, ListOfUdpPortIdentifiers> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(symbol(","), port_identifier)(s)?;
|
||||||
|
Ok((s, ListOfUdpPortIdentifiers { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_specparam_assignments(s: Span) -> IResult<Span, ListOfSpecparamAssignments> {
|
pub fn list_of_specparam_assignments(s: Span) -> IResult<Span, ListOfSpecparamAssignments> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(symbol(","), specparam_assignment)(s)?;
|
||||||
|
Ok((s, ListOfSpecparamAssignments { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_tf_variable_identifiers(s: Span) -> IResult<Span, ListOfTfVariableIdentifiers> {
|
pub fn list_of_tf_variable_identifiers(s: Span) -> IResult<Span, ListOfTfVariableIdentifiers> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(
|
||||||
|
symbol(","),
|
||||||
|
triple(
|
||||||
|
port_identifier,
|
||||||
|
many0(variable_dimension),
|
||||||
|
opt(pair(symbol("="), expression)),
|
||||||
|
),
|
||||||
|
)(s)?;
|
||||||
|
Ok((s, ListOfTfVariableIdentifiers { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_type_assignments(s: Span) -> IResult<Span, ListOfTypeAssignments> {
|
pub fn list_of_type_assignments(s: Span) -> IResult<Span, ListOfTypeAssignments> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(symbol(","), type_assignment)(s)?;
|
||||||
|
Ok((s, ListOfTypeAssignments { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_variable_decl_assignments(s: Span) -> IResult<Span, ListOfVariableDeclAssignments> {
|
pub fn list_of_variable_decl_assignments(s: Span) -> IResult<Span, ListOfVariableDeclAssignments> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(symbol(","), variable_decl_assignment)(s)?;
|
||||||
|
Ok((s, ListOfVariableDeclAssignments { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_variable_identifiers(s: Span) -> IResult<Span, ListOfVariableIdentifiers> {
|
pub fn list_of_variable_identifiers(s: Span) -> IResult<Span, ListOfVariableIdentifiers> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(
|
||||||
|
symbol(","),
|
||||||
|
pair(variable_identifier, many0(variable_dimension)),
|
||||||
|
)(s)?;
|
||||||
|
Ok((s, ListOfVariableIdentifiers { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_of_variable_port_identifiers(s: Span) -> IResult<Span, ListOfVariablePortIdentifiers> {
|
pub fn list_of_variable_port_identifiers(s: Span) -> IResult<Span, ListOfVariablePortIdentifiers> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(
|
||||||
|
symbol(","),
|
||||||
|
triple(
|
||||||
|
port_identifier,
|
||||||
|
many0(variable_dimension),
|
||||||
|
opt(pair(symbol("="), constant_expression)),
|
||||||
|
),
|
||||||
|
)(s)?;
|
||||||
|
Ok((s, ListOfVariablePortIdentifiers { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
//use nom::branch::*;
|
use nom::branch::*;
|
||||||
//use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::error::*;
|
use nom::sequence::*;
|
||||||
use nom::{Err, IResult};
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ pub struct UnpackedDimensionExpression<'a> {
|
|||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub enum PackedDimension<'a> {
|
pub enum PackedDimension<'a> {
|
||||||
Range(PackedDimensionRange<'a>),
|
Range(PackedDimensionRange<'a>),
|
||||||
Unsized(UnsizedDimension<'a>),
|
UnsizedDimension(UnsizedDimension<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -65,31 +65,94 @@ pub struct QueueDimension<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct UnsizedDimension<'a> {
|
pub struct UnsizedDimension<'a> {
|
||||||
pub nodes: ((Symbol<'a>, Symbol<'a>),),
|
pub nodes: (Symbol<'a>, Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn unpacked_dimension(s: Span) -> IResult<Span, UnpackedDimension> {
|
pub fn unpacked_dimension(s: Span) -> IResult<Span, UnpackedDimension> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((unpacked_dimension_range, unpacked_dimension_expression))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpacked_dimension_range(s: Span) -> IResult<Span, UnpackedDimension> {
|
||||||
|
let (s, a) = bracket(constant_range)(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
UnpackedDimension::Range(UnpackedDimensionRange { nodes: (a,) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unpacked_dimension_expression(s: Span) -> IResult<Span, UnpackedDimension> {
|
||||||
|
let (s, a) = bracket(constant_expression)(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
UnpackedDimension::Expression(UnpackedDimensionExpression { nodes: (a,) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn packed_dimension(s: Span) -> IResult<Span, PackedDimension> {
|
pub fn packed_dimension(s: Span) -> IResult<Span, PackedDimension> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
packed_dimension_range,
|
||||||
|
map(unsized_dimension, |x| PackedDimension::UnsizedDimension(x)),
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn packed_dimension_range(s: Span) -> IResult<Span, PackedDimension> {
|
||||||
|
let (s, a) = bracket(constant_range)(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
PackedDimension::Range(PackedDimensionRange { nodes: (a,) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn associative_dimension(s: Span) -> IResult<Span, AssociativeDimension> {
|
pub fn associative_dimension(s: Span) -> IResult<Span, AssociativeDimension> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
associative_dimension_data_type,
|
||||||
|
associative_dimension_asterisk,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn associative_dimension_data_type(s: Span) -> IResult<Span, AssociativeDimension> {
|
||||||
|
let (s, a) = bracket(data_type)(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
AssociativeDimension::DataType(AssociativeDimensionDataType { nodes: (a,) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn associative_dimension_asterisk(s: Span) -> IResult<Span, AssociativeDimension> {
|
||||||
|
let (s, a) = bracket(symbol("*"))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
AssociativeDimension::Asterisk(AssociativeDimensionAsterisk { nodes: (a,) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn variable_dimension(s: Span) -> IResult<Span, VariableDimension> {
|
pub fn variable_dimension(s: Span) -> IResult<Span, VariableDimension> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(unsized_dimension, |x| {
|
||||||
|
VariableDimension::UnsizedDimension(x)
|
||||||
|
}),
|
||||||
|
map(unpacked_dimension, |x| {
|
||||||
|
VariableDimension::UnpackedDimension(x)
|
||||||
|
}),
|
||||||
|
map(associative_dimension, |x| {
|
||||||
|
VariableDimension::AssociativeDimension(x)
|
||||||
|
}),
|
||||||
|
map(queue_dimension, |x| VariableDimension::QueueDimension(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn queue_dimension(s: Span) -> IResult<Span, QueueDimension> {
|
pub fn queue_dimension(s: Span) -> IResult<Span, QueueDimension> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = bracket(pair(
|
||||||
|
symbol("$"),
|
||||||
|
opt(pair(symbol(":"), constant_expression)),
|
||||||
|
))(s)?;
|
||||||
|
Ok((s, QueueDimension { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unsized_dimension(s: Span) -> IResult<Span, UnsizedDimension> {
|
pub fn unsized_dimension(s: Span) -> IResult<Span, UnsizedDimension> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("[")(s)?;
|
||||||
|
let (s, b) = symbol("]")(s)?;
|
||||||
|
Ok((s, UnsizedDimension { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
//use nom::branch::*;
|
use nom::branch::*;
|
||||||
//use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::error::*;
|
use nom::multi::*;
|
||||||
use nom::{Err, IResult};
|
use nom::sequence::*;
|
||||||
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -57,6 +58,12 @@ pub struct FunctionBodyDeclarationWithPort<'a> {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Node)]
|
||||||
|
pub enum InterfaceIdentifierOrClassScope<'a> {
|
||||||
|
InterfaceIdentifier((InterfaceIdentifier<'a>, Symbol<'a>)),
|
||||||
|
ClassScope(ClassScope<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct FunctionPrototype<'a> {
|
pub struct FunctionPrototype<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
@ -107,6 +114,7 @@ pub struct DpiImportExportExportFunction<'a> {
|
|||||||
Option<(CIdentifier<'a>, Symbol<'a>)>,
|
Option<(CIdentifier<'a>, Symbol<'a>)>,
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
FunctionIdentifier<'a>,
|
FunctionIdentifier<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,6 +126,7 @@ pub struct DpiImportExportExportTask<'a> {
|
|||||||
Option<(CIdentifier<'a>, Symbol<'a>)>,
|
Option<(CIdentifier<'a>, Symbol<'a>)>,
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
TaskIdentifier<'a>,
|
TaskIdentifier<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,41 +160,185 @@ pub struct DpiTaskProto<'a> {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn function_data_type_or_implicit(s: Span) -> IResult<Span, FunctionDataTypeOrImplicit> {
|
pub fn function_data_type_or_implicit(s: Span) -> IResult<Span, FunctionDataTypeOrImplicit> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(data_type_or_void, |x| {
|
||||||
|
FunctionDataTypeOrImplicit::DataTypeOrVoid(x)
|
||||||
|
}),
|
||||||
|
map(implicit_data_type, |x| {
|
||||||
|
FunctionDataTypeOrImplicit::ImplicitDataType(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn function_declaration(s: Span) -> IResult<Span, FunctionDeclaration> {
|
pub fn function_declaration(s: Span) -> IResult<Span, FunctionDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("function")(s)?;
|
||||||
|
let (s, b) = opt(lifetime)(s)?;
|
||||||
|
let (s, c) = function_body_declaration(s)?;
|
||||||
|
Ok((s, FunctionDeclaration { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn function_body_declaration(s: Span) -> IResult<Span, FunctionBodyDeclaration> {
|
pub fn function_body_declaration(s: Span) -> IResult<Span, FunctionBodyDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
function_body_declaration_without_port,
|
||||||
|
function_body_declaration_with_port,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn function_body_declaration_without_port(s: Span) -> IResult<Span, FunctionBodyDeclaration> {
|
||||||
|
let (s, a) = function_data_type_or_implicit(s)?;
|
||||||
|
let (s, b) = opt(interface_identifier_or_class_scope)(s)?;
|
||||||
|
let (s, c) = function_identifier(s)?;
|
||||||
|
let (s, d) = symbol(";")(s)?;
|
||||||
|
let (s, e) = many0(tf_item_declaration)(s)?;
|
||||||
|
let (s, f) = many0(function_statement_or_null)(s)?;
|
||||||
|
let (s, g) = symbol("endfunction")(s)?;
|
||||||
|
let (s, h) = opt(pair(symbol(":"), function_identifier))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
FunctionBodyDeclaration::WithoutPort(FunctionBodyDeclarationWithoutPort {
|
||||||
|
nodes: (a, b, c, d, e, f, g, h),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn function_body_declaration_with_port(s: Span) -> IResult<Span, FunctionBodyDeclaration> {
|
||||||
|
let (s, a) = function_data_type_or_implicit(s)?;
|
||||||
|
let (s, b) = opt(interface_identifier_or_class_scope)(s)?;
|
||||||
|
let (s, c) = function_identifier(s)?;
|
||||||
|
let (s, d) = paren(opt(tf_port_list))(s)?;
|
||||||
|
let (s, e) = symbol(";")(s)?;
|
||||||
|
let (s, f) = many0(block_item_declaration)(s)?;
|
||||||
|
let (s, g) = many0(function_statement_or_null)(s)?;
|
||||||
|
let (s, h) = symbol("endfunction")(s)?;
|
||||||
|
let (s, i) = opt(pair(symbol(":"), function_identifier))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
FunctionBodyDeclaration::WithPort(FunctionBodyDeclarationWithPort {
|
||||||
|
nodes: (a, b, c, d, e, f, g, h, i),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn interface_identifier_or_class_scope(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, InterfaceIdentifierOrClassScope> {
|
||||||
|
alt((
|
||||||
|
map(pair(interface_identifier, symbol(".")), |x| {
|
||||||
|
InterfaceIdentifierOrClassScope::InterfaceIdentifier(x)
|
||||||
|
}),
|
||||||
|
map(class_scope, |x| {
|
||||||
|
InterfaceIdentifierOrClassScope::ClassScope(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn function_prototype(s: Span) -> IResult<Span, FunctionPrototype> {
|
pub fn function_prototype(s: Span) -> IResult<Span, FunctionPrototype> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("function")(s)?;
|
||||||
|
let (s, b) = data_type_or_void(s)?;
|
||||||
|
let (s, c) = function_identifier(s)?;
|
||||||
|
let (s, d) = opt(paren(opt(tf_port_list)))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
FunctionPrototype {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dpi_import_export(s: Span) -> IResult<Span, DpiImportExport> {
|
pub fn dpi_import_export(s: Span) -> IResult<Span, DpiImportExport> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
dpi_import_export_import_function,
|
||||||
|
dpi_import_export_import_task,
|
||||||
|
dpi_import_export_export_function,
|
||||||
|
dpi_import_export_export_task,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dpi_import_export_import_function(s: Span) -> IResult<Span, DpiImportExport> {
|
||||||
|
let (s, a) = symbol("import")(s)?;
|
||||||
|
let (s, b) = dpi_spec_string(s)?;
|
||||||
|
let (s, c) = opt(dpi_function_import_property)(s)?;
|
||||||
|
let (s, d) = opt(pair(c_identifier, symbol("=")))(s)?;
|
||||||
|
let (s, e) = dpi_function_proto(s)?;
|
||||||
|
let (s, f) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
DpiImportExport::ImportFunction(DpiImportExportImportFunction {
|
||||||
|
nodes: (a, b, c, d, e, f),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dpi_import_export_import_task(s: Span) -> IResult<Span, DpiImportExport> {
|
||||||
|
let (s, a) = symbol("import")(s)?;
|
||||||
|
let (s, b) = dpi_spec_string(s)?;
|
||||||
|
let (s, c) = opt(dpi_task_import_property)(s)?;
|
||||||
|
let (s, d) = opt(pair(c_identifier, symbol("=")))(s)?;
|
||||||
|
let (s, e) = dpi_task_proto(s)?;
|
||||||
|
let (s, f) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
DpiImportExport::ImportTask(DpiImportExportImportTask {
|
||||||
|
nodes: (a, b, c, d, e, f),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dpi_import_export_export_function(s: Span) -> IResult<Span, DpiImportExport> {
|
||||||
|
let (s, a) = symbol("export")(s)?;
|
||||||
|
let (s, b) = dpi_spec_string(s)?;
|
||||||
|
let (s, c) = opt(pair(c_identifier, symbol("=")))(s)?;
|
||||||
|
let (s, d) = symbol("function")(s)?;
|
||||||
|
let (s, e) = function_identifier(s)?;
|
||||||
|
let (s, f) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
DpiImportExport::ExportFunction(DpiImportExportExportFunction {
|
||||||
|
nodes: (a, b, c, d, e, f),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dpi_import_export_export_task(s: Span) -> IResult<Span, DpiImportExport> {
|
||||||
|
let (s, a) = symbol("export")(s)?;
|
||||||
|
let (s, b) = dpi_spec_string(s)?;
|
||||||
|
let (s, c) = opt(pair(c_identifier, symbol("=")))(s)?;
|
||||||
|
let (s, d) = symbol("task")(s)?;
|
||||||
|
let (s, e) = task_identifier(s)?;
|
||||||
|
let (s, f) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
DpiImportExport::ExportTask(DpiImportExportExportTask {
|
||||||
|
nodes: (a, b, c, d, e, f),
|
||||||
|
}),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dpi_spec_string(s: Span) -> IResult<Span, DpiSpecString> {
|
pub fn dpi_spec_string(s: Span) -> IResult<Span, DpiSpecString> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(symbol("DPI-C"), |x| DpiSpecString::DpiC(x)),
|
||||||
|
map(symbol("DPI"), |x| DpiSpecString::Dpi(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dpi_function_import_property(s: Span) -> IResult<Span, DpiFunctionImportProperty> {
|
pub fn dpi_function_import_property(s: Span) -> IResult<Span, DpiFunctionImportProperty> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(symbol("context"), |x| DpiFunctionImportProperty::Context(x)),
|
||||||
|
map(symbol("pure"), |x| DpiFunctionImportProperty::Pure(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dpi_task_import_property(s: Span) -> IResult<Span, DpiTaskImportProperty> {
|
pub fn dpi_task_import_property(s: Span) -> IResult<Span, DpiTaskImportProperty> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("context")(s)?;
|
||||||
|
Ok((s, DpiTaskImportProperty::Context(a)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dpi_function_proto(s: Span) -> IResult<Span, DpiFunctionProto> {
|
pub fn dpi_function_proto(s: Span) -> IResult<Span, DpiFunctionProto> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = function_prototype(s)?;
|
||||||
|
Ok((s, DpiFunctionProto { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dpi_task_proto(s: Span) -> IResult<Span, DpiTaskProto> {
|
pub fn dpi_task_proto(s: Span) -> IResult<Span, DpiTaskProto> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = task_prototype(s)?;
|
||||||
|
Ok((s, DpiTaskProto { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
//use nom::branch::*;
|
use nom::branch::*;
|
||||||
//use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::error::*;
|
use nom::multi::*;
|
||||||
use nom::{Err, IResult};
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ pub struct ModportItem<'a> {
|
|||||||
pub enum ModportPortsDeclaraton<'a> {
|
pub enum ModportPortsDeclaraton<'a> {
|
||||||
Simple(ModportPortsDeclaratonSimple<'a>),
|
Simple(ModportPortsDeclaratonSimple<'a>),
|
||||||
Tf(ModportPortsDeclaratonTf<'a>),
|
Tf(ModportPortsDeclaratonTf<'a>),
|
||||||
Clocing(ModportPortsDeclaratonClocking<'a>),
|
Clocking(ModportPortsDeclaratonClocking<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -95,37 +95,103 @@ pub enum ImportExport<'a> {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn modport_declaration(s: Span) -> IResult<Span, ModportDeclaration> {
|
pub fn modport_declaration(s: Span) -> IResult<Span, ModportDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("modport")(s)?;
|
||||||
|
let (s, b) = list(symbol(","), modport_item)(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
Ok((s, ModportDeclaration { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn modport_item(s: Span) -> IResult<Span, ModportItem> {
|
pub fn modport_item(s: Span) -> IResult<Span, ModportItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = modport_identifier(s)?;
|
||||||
|
let (s, b) = paren(list(symbol(","), modport_ports_declaration))(s)?;
|
||||||
|
Ok((s, ModportItem { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn modport_ports_declaration(s: Span) -> IResult<Span, ModportPortsDeclaraton> {
|
pub fn modport_ports_declaration(s: Span) -> IResult<Span, ModportPortsDeclaraton> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
modport_ports_declaration_simple,
|
||||||
|
modport_ports_declaration_tf,
|
||||||
|
modport_ports_declaration_clocking,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn modport_ports_declaration_simple(s: Span) -> IResult<Span, ModportPortsDeclaraton> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = modport_simple_ports_declaration(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ModportPortsDeclaraton::Simple(ModportPortsDeclaratonSimple { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn modport_ports_declaration_tf(s: Span) -> IResult<Span, ModportPortsDeclaraton> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = modport_tf_ports_declaration(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ModportPortsDeclaraton::Tf(ModportPortsDeclaratonTf { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn modport_ports_declaration_clocking(s: Span) -> IResult<Span, ModportPortsDeclaraton> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = modport_clocking_declaration(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ModportPortsDeclaraton::Clocking(ModportPortsDeclaratonClocking { nodes: (a, b) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn modport_clocking_declaration(s: Span) -> IResult<Span, ModportClockingDeclaration> {
|
pub fn modport_clocking_declaration(s: Span) -> IResult<Span, ModportClockingDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("clocking")(s)?;
|
||||||
|
let (s, b) = clocking_identifier(s)?;
|
||||||
|
Ok((s, ModportClockingDeclaration { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn modport_simple_ports_declaration(s: Span) -> IResult<Span, ModportSimplePortsDeclaration> {
|
pub fn modport_simple_ports_declaration(s: Span) -> IResult<Span, ModportSimplePortsDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = port_direction(s)?;
|
||||||
|
let (s, b) = list(symbol(","), modport_simple_port)(s)?;
|
||||||
|
Ok((s, ModportSimplePortsDeclaration { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn modport_simple_port(s: Span) -> IResult<Span, ModportSimplePort> {
|
pub fn modport_simple_port(s: Span) -> IResult<Span, ModportSimplePort> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((modport_simple_port_ordered, modport_simple_port_named))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn modport_simple_port_ordered(s: Span) -> IResult<Span, ModportSimplePort> {
|
||||||
|
let (s, a) = port_identifier(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ModportSimplePort::Ordered(ModportSimplePortOrdered { nodes: (a,) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn modport_simple_port_named(s: Span) -> IResult<Span, ModportSimplePort> {
|
||||||
|
let (s, a) = symbol(".")(s)?;
|
||||||
|
let (s, b) = port_identifier(s)?;
|
||||||
|
let (s, c) = paren(opt(expression))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ModportSimplePort::Named(ModportSimplePortNamed { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn modport_tf_ports_declaration(s: Span) -> IResult<Span, ModportTfPortsDeclaration> {
|
pub fn modport_tf_ports_declaration(s: Span) -> IResult<Span, ModportTfPortsDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = import_export(s)?;
|
||||||
|
let (s, b) = list(symbol(","), modport_tf_port)(s)?;
|
||||||
|
Ok((s, ModportTfPortsDeclaration { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn modport_tf_port(s: Span) -> IResult<Span, ModportTfPort> {
|
pub fn modport_tf_port(s: Span) -> IResult<Span, ModportTfPort> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(method_prototype, |x| ModportTfPort::MethodPrototype(x)),
|
||||||
|
map(tf_identifier, |x| ModportTfPort::TfIdentifier(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn import_export(s: Span) -> IResult<Span, ImportExport> {
|
pub fn import_export(s: Span) -> IResult<Span, ImportExport> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(symbol("import"), |x| ImportExport::Import(x)),
|
||||||
|
map(symbol("export"), |x| ImportExport::Export(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
//use nom::branch::*;
|
use nom::branch::*;
|
||||||
//use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::error::*;
|
use nom::multi::*;
|
||||||
use nom::{Err, IResult};
|
use nom::sequence::*;
|
||||||
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -131,7 +132,7 @@ pub struct EnumBaseTypeVector<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct EnumBaseTypeType<'a> {
|
pub struct EnumBaseTypeType<'a> {
|
||||||
pub nodes: (Identifier<'a>, Option<PackedDimension<'a>>),
|
pub nodes: (TypeIdentifier<'a>, Option<PackedDimension<'a>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -155,7 +156,7 @@ pub struct ClassType<'a> {
|
|||||||
Option<ParameterValueAssignment<'a>>,
|
Option<ParameterValueAssignment<'a>>,
|
||||||
Vec<(
|
Vec<(
|
||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Identifier<'a>,
|
ClassIdentifier<'a>,
|
||||||
Option<ParameterValueAssignment<'a>>,
|
Option<ParameterValueAssignment<'a>>,
|
||||||
)>,
|
)>,
|
||||||
),
|
),
|
||||||
@ -249,7 +250,7 @@ pub enum Signing<'a> {
|
|||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub enum SimpleType<'a> {
|
pub enum SimpleType<'a> {
|
||||||
IntegerType(IntegerType<'a>),
|
IntegerType(IntegerType<'a>),
|
||||||
NonNonIntegerType(IntegerType<'a>),
|
NonIntegerType(NonIntegerType<'a>),
|
||||||
PsTypeIdentifier(PsTypeIdentifier<'a>),
|
PsTypeIdentifier(PsTypeIdentifier<'a>),
|
||||||
PsParameterIdentifier(PsParameterIdentifier<'a>),
|
PsParameterIdentifier(PsParameterIdentifier<'a>),
|
||||||
}
|
}
|
||||||
@ -297,89 +298,341 @@ pub struct TypeReferenceDataType<'a> {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn casting_type(s: Span) -> IResult<Span, CastingType> {
|
pub fn casting_type(s: Span) -> IResult<Span, CastingType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(simple_type, |x| CastingType::SimpleType(Box::new(x))),
|
||||||
|
map(constant_primary, |x| {
|
||||||
|
CastingType::ConstantPrimary(Box::new(x))
|
||||||
|
}),
|
||||||
|
map(signing, |x| CastingType::Signing(Box::new(x))),
|
||||||
|
map(symbol("string"), |x| CastingType::String(x)),
|
||||||
|
map(symbol("const"), |x| CastingType::Const(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn data_type(s: Span) -> IResult<Span, DataType> {
|
pub fn data_type(s: Span) -> IResult<Span, DataType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
data_type_vector,
|
||||||
|
data_type_atom,
|
||||||
|
map(non_integer_type, |x| DataType::NonIntegerType(x)),
|
||||||
|
data_type_union,
|
||||||
|
data_type_enum,
|
||||||
|
map(symbol("string"), |x| DataType::String(x)),
|
||||||
|
map(symbol("chandle"), |x| DataType::Chandle(x)),
|
||||||
|
data_type_virtual,
|
||||||
|
data_type_type,
|
||||||
|
map(class_type, |x| DataType::ClassType(x)),
|
||||||
|
map(symbol("event"), |x| DataType::Chandle(x)),
|
||||||
|
map(ps_covergroup_identifier, |x| {
|
||||||
|
DataType::PsCovergroupIdentifier(x)
|
||||||
|
}),
|
||||||
|
map(type_reference, |x| DataType::TypeReference(Box::new(x))),
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn data_type_vector(s: Span) -> IResult<Span, DataType> {
|
||||||
|
let (s, a) = integer_vector_type(s)?;
|
||||||
|
let (s, b) = opt(signing)(s)?;
|
||||||
|
let (s, c) = many0(packed_dimension)(s)?;
|
||||||
|
Ok((s, DataType::Vector(DataTypeVector { nodes: (a, b, c) })))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn data_type_atom(s: Span) -> IResult<Span, DataType> {
|
||||||
|
let (s, a) = integer_atom_type(s)?;
|
||||||
|
let (s, b) = opt(signing)(s)?;
|
||||||
|
Ok((s, DataType::Atom(DataTypeAtom { nodes: (a, b) })))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn data_type_union(s: Span) -> IResult<Span, DataType> {
|
||||||
|
let (s, a) = struct_union(s)?;
|
||||||
|
let (s, b) = opt(pair(packed, opt(signing)))(s)?;
|
||||||
|
let (s, c) = brace(pair(struct_union_member, many0(struct_union_member)))(s)?;
|
||||||
|
let (s, d) = many0(packed_dimension)(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
DataType::Union(Box::new(DataTypeUnion {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn packed(s: Span) -> IResult<Span, Packed> {
|
||||||
|
let (s, a) = symbol("packed")(s)?;
|
||||||
|
Ok((s, Packed { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn data_type_enum(s: Span) -> IResult<Span, DataType> {
|
||||||
|
let (s, a) = symbol("enum")(s)?;
|
||||||
|
let (s, b) = opt(enum_base_type)(s)?;
|
||||||
|
let (s, c) = brace(list(symbol(","), enum_name_declaration))(s)?;
|
||||||
|
let (s, d) = many0(packed_dimension)(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
DataType::Enum(DataTypeEnum {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn data_type_virtual(s: Span) -> IResult<Span, DataType> {
|
||||||
|
let (s, a) = symbol("virtual")(s)?;
|
||||||
|
let (s, b) = opt(interface)(s)?;
|
||||||
|
let (s, c) = interface_identifier(s)?;
|
||||||
|
let (s, d) = opt(parameter_value_assignment)(s)?;
|
||||||
|
let (s, e) = opt(pair(symbol("."), modport_identifier))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
DataType::Virtual(DataTypeVirtual {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn interface(s: Span) -> IResult<Span, Interface> {
|
||||||
|
let (s, a) = symbol("interface")(s)?;
|
||||||
|
Ok((s, Interface { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn data_type_type(s: Span) -> IResult<Span, DataType> {
|
||||||
|
let (s, a) = opt(package_scope_or_class_scope)(s)?;
|
||||||
|
let (s, b) = type_identifier(s)?;
|
||||||
|
let (s, c) = many0(packed_dimension)(s)?;
|
||||||
|
Ok((s, DataType::Type(DataTypeType { nodes: (a, b, c) })))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn data_type_or_implicit(s: Span) -> IResult<Span, DataTypeOrImplicit> {
|
pub fn data_type_or_implicit(s: Span) -> IResult<Span, DataTypeOrImplicit> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(data_type, |x| DataTypeOrImplicit::DataType(x)),
|
||||||
|
map(implicit_data_type, |x| {
|
||||||
|
DataTypeOrImplicit::ImplicitDataType(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn implicit_data_type(s: Span) -> IResult<Span, ImplicitDataType> {
|
pub fn implicit_data_type(s: Span) -> IResult<Span, ImplicitDataType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = opt(signing)(s)?;
|
||||||
|
let (s, b) = many0(packed_dimension)(s)?;
|
||||||
|
Ok((s, ImplicitDataType { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn enum_base_type(s: Span) -> IResult<Span, EnumBaseType> {
|
pub fn enum_base_type(s: Span) -> IResult<Span, EnumBaseType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
enum_base_type_atom,
|
||||||
|
enum_base_type_vector,
|
||||||
|
enum_base_type_type,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn enum_base_type_atom(s: Span) -> IResult<Span, EnumBaseType> {
|
||||||
|
let (s, a) = integer_atom_type(s)?;
|
||||||
|
let (s, b) = opt(signing)(s)?;
|
||||||
|
Ok((s, EnumBaseType::Atom(EnumBaseTypeAtom { nodes: (a, b) })))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn enum_base_type_vector(s: Span) -> IResult<Span, EnumBaseType> {
|
||||||
|
let (s, a) = integer_vector_type(s)?;
|
||||||
|
let (s, b) = opt(signing)(s)?;
|
||||||
|
let (s, c) = opt(packed_dimension)(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
EnumBaseType::Vector(EnumBaseTypeVector { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn enum_base_type_type(s: Span) -> IResult<Span, EnumBaseType> {
|
||||||
|
let (s, a) = type_identifier(s)?;
|
||||||
|
let (s, b) = opt(packed_dimension)(s)?;
|
||||||
|
Ok((s, EnumBaseType::Type(EnumBaseTypeType { nodes: (a, b) })))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn enum_name_declaration(s: Span) -> IResult<Span, EnumNameDeclaration> {
|
pub fn enum_name_declaration(s: Span) -> IResult<Span, EnumNameDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = enum_identifier(s)?;
|
||||||
|
let (s, b) = opt(bracket(pair(
|
||||||
|
integral_number,
|
||||||
|
opt(pair(symbol(":"), integral_number)),
|
||||||
|
)))(s)?;
|
||||||
|
let (s, c) = opt(pair(symbol("="), constant_expression))(s)?;
|
||||||
|
Ok((s, EnumNameDeclaration { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn class_scope(s: Span) -> IResult<Span, ClassScope> {
|
pub fn class_scope(s: Span) -> IResult<Span, ClassScope> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = class_type(s)?;
|
||||||
|
let (s, b) = symbol("::")(s)?;
|
||||||
|
Ok((s, ClassScope { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn class_type(s: Span) -> IResult<Span, ClassType> {
|
pub fn class_type(s: Span) -> IResult<Span, ClassType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = ps_class_identifier(s)?;
|
||||||
|
let (s, b) = opt(parameter_value_assignment)(s)?;
|
||||||
|
let (s, c) = many0(triple(
|
||||||
|
symbol("::"),
|
||||||
|
class_identifier,
|
||||||
|
opt(parameter_value_assignment),
|
||||||
|
))(s)?;
|
||||||
|
Ok((s, ClassType { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
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)))
|
alt((
|
||||||
|
map(integer_vector_type, |x| IntegerType::IntegerVectorType(x)),
|
||||||
|
map(integer_atom_type, |x| IntegerType::IntegerAtomType(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn integer_atom_type(s: Span) -> IResult<Span, IntegerAtomType> {
|
pub fn integer_atom_type(s: Span) -> IResult<Span, IntegerAtomType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(symbol("byte"), |x| IntegerAtomType::Byte(x)),
|
||||||
|
map(symbol("shortint"), |x| IntegerAtomType::Shortint(x)),
|
||||||
|
map(symbol("int"), |x| IntegerAtomType::Int(x)),
|
||||||
|
map(symbol("longint"), |x| IntegerAtomType::Longint(x)),
|
||||||
|
map(symbol("integer"), |x| IntegerAtomType::Integer(x)),
|
||||||
|
map(symbol("time"), |x| IntegerAtomType::Time(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn integer_vector_type(s: Span) -> IResult<Span, IntegerVectorType> {
|
pub fn integer_vector_type(s: Span) -> IResult<Span, IntegerVectorType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(symbol("bit"), |x| IntegerVectorType::Bit(x)),
|
||||||
|
map(symbol("logic"), |x| IntegerVectorType::Logic(x)),
|
||||||
|
map(symbol("reg"), |x| IntegerVectorType::Reg(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn non_integer_type(s: Span) -> IResult<Span, NonIntegerType> {
|
pub fn non_integer_type(s: Span) -> IResult<Span, NonIntegerType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(symbol("shortreal"), |x| NonIntegerType::Shortreal(x)),
|
||||||
|
map(symbol("realtime"), |x| NonIntegerType::Realtime(x)),
|
||||||
|
map(symbol("real"), |x| NonIntegerType::Real(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn net_type(s: Span) -> IResult<Span, NetType> {
|
pub fn net_type(s: Span) -> IResult<Span, NetType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(symbol("supply0"), |x| NetType::Supply0(x)),
|
||||||
|
map(symbol("supply1"), |x| NetType::Supply1(x)),
|
||||||
|
map(symbol("tri"), |x| NetType::Tri(x)),
|
||||||
|
map(symbol("triand"), |x| NetType::Triand(x)),
|
||||||
|
map(symbol("trior"), |x| NetType::Trior(x)),
|
||||||
|
map(symbol("trireg"), |x| NetType::Trireg(x)),
|
||||||
|
map(symbol("tri0"), |x| NetType::Tri0(x)),
|
||||||
|
map(symbol("tri1"), |x| NetType::Tri1(x)),
|
||||||
|
map(symbol("uwire"), |x| NetType::Uwire(x)),
|
||||||
|
map(symbol("wire"), |x| NetType::Wire(x)),
|
||||||
|
map(symbol("wand"), |x| NetType::Wand(x)),
|
||||||
|
map(symbol("wor"), |x| NetType::Wor(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn net_port_type(s: Span) -> IResult<Span, NetPortType> {
|
pub fn net_port_type(s: Span) -> IResult<Span, NetPortType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
net_port_type_data_type,
|
||||||
|
map(net_type_identifier, |x| NetPortType::NetTypeIdentifier(x)),
|
||||||
|
net_port_type_interconnect,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn net_port_type_data_type(s: Span) -> IResult<Span, NetPortType> {
|
||||||
|
let (s, a) = opt(net_type)(s)?;
|
||||||
|
let (s, b) = data_type_or_implicit(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NetPortType::DataType(NetPortTypeDataType { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn net_port_type_interconnect(s: Span) -> IResult<Span, NetPortType> {
|
||||||
|
let (s, a) = symbol("interconnect")(s)?;
|
||||||
|
let (s, b) = implicit_data_type(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NetPortType::Interconnect(NetPortTypeInterconnect { nodes: (a, b) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn variable_port_type(s: Span) -> IResult<Span, VariablePortType> {
|
pub fn variable_port_type(s: Span) -> IResult<Span, VariablePortType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = var_data_type(s)?;
|
||||||
|
Ok((s, VariablePortType { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn var_data_type(s: Span) -> IResult<Span, VarDataType> {
|
pub fn var_data_type(s: Span) -> IResult<Span, VarDataType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(data_type, |x| VarDataType::DataType(x)),
|
||||||
|
var_data_type_var,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn var_data_type_var(s: Span) -> IResult<Span, VarDataType> {
|
||||||
|
let (s, a) = symbol("var")(s)?;
|
||||||
|
let (s, b) = data_type_or_implicit(s)?;
|
||||||
|
Ok((s, VarDataType::Var(VarDataTypeVar { nodes: (a, b) })))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn signing(s: Span) -> IResult<Span, Signing> {
|
pub fn signing(s: Span) -> IResult<Span, Signing> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(symbol("signed"), |x| Signing::Signed(x)),
|
||||||
|
map(symbol("unsigned"), |x| Signing::Unsigned(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn simple_type(s: Span) -> IResult<Span, SimpleType> {
|
pub fn simple_type(s: Span) -> IResult<Span, SimpleType> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(integer_type, |x| SimpleType::IntegerType(x)),
|
||||||
|
map(non_integer_type, |x| SimpleType::NonIntegerType(x)),
|
||||||
|
map(ps_type_identifier, |x| SimpleType::PsTypeIdentifier(x)),
|
||||||
|
map(ps_parameter_identifier, |x| {
|
||||||
|
SimpleType::PsParameterIdentifier(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn struct_union_member(s: Span) -> IResult<Span, StructUnionMember> {
|
pub fn struct_union_member(s: Span) -> IResult<Span, StructUnionMember> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = opt(random_qualifier)(s)?;
|
||||||
|
let (s, c) = data_type_or_void(s)?;
|
||||||
|
let (s, d) = list_of_variable_decl_assignments(s)?;
|
||||||
|
let (s, e) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
StructUnionMember {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn data_type_or_void(s: Span) -> IResult<Span, DataTypeOrVoid> {
|
pub fn data_type_or_void(s: Span) -> IResult<Span, DataTypeOrVoid> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(data_type, |x| DataTypeOrVoid::DataType(x)),
|
||||||
|
map(symbol("void"), |x| DataTypeOrVoid::Void(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn struct_union(s: Span) -> IResult<Span, StructUnion> {
|
pub fn struct_union(s: Span) -> IResult<Span, StructUnion> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(symbol("struct"), |x| StructUnion::Struct(x)),
|
||||||
|
map(pair(symbol("union"), symbol("tagged")), |x| {
|
||||||
|
StructUnion::UnionTagged(x)
|
||||||
|
}),
|
||||||
|
map(symbol("union"), |x| StructUnion::Union(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn type_reference(s: Span) -> IResult<Span, TypeReference> {
|
pub fn type_reference(s: Span) -> IResult<Span, TypeReference> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((type_reference_expression, type_reference_data_type))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn type_reference_expression(s: Span) -> IResult<Span, TypeReference> {
|
||||||
|
let (s, a) = symbol("type")(s)?;
|
||||||
|
let (s, b) = paren(expression)(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
TypeReference::Expression(TypeReferenceExpression { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn type_reference_data_type(s: Span) -> IResult<Span, TypeReference> {
|
||||||
|
let (s, a) = symbol("type")(s)?;
|
||||||
|
let (s, b) = paren(data_type)(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
TypeReference::DataType(TypeReferenceDataType { nodes: (a, b) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
//use nom::branch::*;
|
use nom::branch::*;
|
||||||
//use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::error::*;
|
use nom::multi::*;
|
||||||
use nom::{Err, IResult};
|
use nom::sequence::*;
|
||||||
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -40,16 +41,11 @@ pub struct TaskBodyDeclarationWithPort<'a> {
|
|||||||
Symbol<'a>,
|
Symbol<'a>,
|
||||||
Vec<BlockItemDeclaration<'a>>,
|
Vec<BlockItemDeclaration<'a>>,
|
||||||
Vec<StatementOrNull<'a>>,
|
Vec<StatementOrNull<'a>>,
|
||||||
|
Symbol<'a>,
|
||||||
Option<(Symbol<'a>, TaskIdentifier<'a>)>,
|
Option<(Symbol<'a>, TaskIdentifier<'a>)>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
|
||||||
pub enum InterfaceIdentifierOrClassScope<'a> {
|
|
||||||
InterfaceIdentifier((InterfaceIdentifier<'a>, Symbol<'a>)),
|
|
||||||
ClassScope(ClassScope<'a>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub enum TfItemDeclaration<'a> {
|
pub enum TfItemDeclaration<'a> {
|
||||||
BlockItemDeclaration(BlockItemDeclaration<'a>),
|
BlockItemDeclaration(BlockItemDeclaration<'a>),
|
||||||
@ -106,33 +102,113 @@ pub struct TaskPrototype<'a> {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn task_declaration(s: Span) -> IResult<Span, TaskDeclaration> {
|
pub fn task_declaration(s: Span) -> IResult<Span, TaskDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("task")(s)?;
|
||||||
|
let (s, b) = opt(lifetime)(s)?;
|
||||||
|
let (s, c) = task_body_declaration(s)?;
|
||||||
|
Ok((s, TaskDeclaration { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn task_body_declaration(s: Span) -> IResult<Span, TaskBodyDeclaration> {
|
pub fn task_body_declaration(s: Span) -> IResult<Span, TaskBodyDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
task_body_declaration_without_port,
|
||||||
|
task_body_declaration_with_port,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn task_body_declaration_without_port(s: Span) -> IResult<Span, TaskBodyDeclaration> {
|
||||||
|
let (s, a) = opt(interface_identifier_or_class_scope)(s)?;
|
||||||
|
let (s, b) = task_identifier(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
let (s, d) = many0(tf_item_declaration)(s)?;
|
||||||
|
let (s, e) = many0(statement_or_null)(s)?;
|
||||||
|
let (s, f) = symbol("endtask")(s)?;
|
||||||
|
let (s, g) = opt(pair(symbol(":"), task_identifier))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
TaskBodyDeclaration::WithoutPort(TaskBodyDeclarationWithoutPort {
|
||||||
|
nodes: (a, b, c, d, e, f, g),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn task_body_declaration_with_port(s: Span) -> IResult<Span, TaskBodyDeclaration> {
|
||||||
|
let (s, a) = opt(interface_identifier_or_class_scope)(s)?;
|
||||||
|
let (s, b) = task_identifier(s)?;
|
||||||
|
let (s, c) = paren(opt(tf_port_list))(s)?;
|
||||||
|
let (s, d) = symbol(";")(s)?;
|
||||||
|
let (s, e) = many0(block_item_declaration)(s)?;
|
||||||
|
let (s, f) = many0(statement_or_null)(s)?;
|
||||||
|
let (s, g) = symbol("endtask")(s)?;
|
||||||
|
let (s, h) = opt(pair(symbol(":"), task_identifier))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
TaskBodyDeclaration::WithPort(TaskBodyDeclarationWithPort {
|
||||||
|
nodes: (a, b, c, d, e, f, g, h),
|
||||||
|
}),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tf_item_declaration(s: Span) -> IResult<Span, TfItemDeclaration> {
|
pub fn tf_item_declaration(s: Span) -> IResult<Span, TfItemDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(block_item_declaration, |x| {
|
||||||
|
TfItemDeclaration::BlockItemDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(tf_port_declaration, |x| {
|
||||||
|
TfItemDeclaration::TfPortDeclaration(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tf_port_list(s: Span) -> IResult<Span, TfPortList> {
|
pub fn tf_port_list(s: Span) -> IResult<Span, TfPortList> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(symbol(","), tf_port_item)(s)?;
|
||||||
|
Ok((s, TfPortList { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tf_port_item(s: Span) -> IResult<Span, TfPortItem> {
|
pub fn tf_port_item(s: Span) -> IResult<Span, TfPortItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = opt(tf_port_direction)(s)?;
|
||||||
|
let (s, c) = opt(var)(s)?;
|
||||||
|
let (s, d) = data_type_or_implicit(s)?;
|
||||||
|
let (s, e) = opt(triple(
|
||||||
|
port_identifier,
|
||||||
|
many0(variable_dimension),
|
||||||
|
opt(pair(symbol(":"), expression)),
|
||||||
|
))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
TfPortItem {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tf_port_direction(s: Span) -> IResult<Span, TfPortDirection> {
|
pub fn tf_port_direction(s: Span) -> IResult<Span, TfPortDirection> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(port_direction, |x| TfPortDirection::PortDirection(x)),
|
||||||
|
map(pair(symbol("const"), symbol("ref")), |x| {
|
||||||
|
TfPortDirection::ConstRef(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tf_port_declaration(s: Span) -> IResult<Span, TfPortDeclaration> {
|
pub fn tf_port_declaration(s: Span) -> IResult<Span, TfPortDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = tf_port_direction(s)?;
|
||||||
|
let (s, c) = opt(var)(s)?;
|
||||||
|
let (s, d) = data_type_or_implicit(s)?;
|
||||||
|
let (s, e) = list_of_tf_variable_identifiers(s)?;
|
||||||
|
let (s, f) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
TfPortDeclaration {
|
||||||
|
nodes: (a, b, c, d, e, f),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn task_prototype(s: Span) -> IResult<Span, TaskPrototype> {
|
pub fn task_prototype(s: Span) -> IResult<Span, TaskPrototype> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("task")(s)?;
|
||||||
|
let (s, b) = task_identifier(s)?;
|
||||||
|
let (s, c) = opt(paren(opt(tf_port_list)))(s)?;
|
||||||
|
Ok((s, TaskPrototype { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
//use nom::branch::*;
|
use nom::branch::*;
|
||||||
//use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::error::*;
|
use nom::multi::*;
|
||||||
use nom::{Err, IResult};
|
use nom::sequence::*;
|
||||||
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct CheckerPortList<'a> {
|
pub struct CheckerPortList<'a> {
|
||||||
pub nodes: (Vec<CheckerPortItem<'a>>,),
|
pub nodes: (List<Symbol<'a>, CheckerPortItem<'a>>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -20,7 +21,7 @@ pub struct CheckerPortItem<'a> {
|
|||||||
PropertyFormalType<'a>,
|
PropertyFormalType<'a>,
|
||||||
FormalPortIdentifier<'a>,
|
FormalPortIdentifier<'a>,
|
||||||
Vec<VariableDimension<'a>>,
|
Vec<VariableDimension<'a>>,
|
||||||
Option<PropertyActualArg<'a>>,
|
Option<(Symbol<'a>, PropertyActualArg<'a>)>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ pub enum CheckerOrGenerateItemDeclaration<'a> {
|
|||||||
GenvarDeclaration(GenvarDeclaration<'a>),
|
GenvarDeclaration(GenvarDeclaration<'a>),
|
||||||
ClockingDeclaration(ClockingDeclaration<'a>),
|
ClockingDeclaration(ClockingDeclaration<'a>),
|
||||||
Clocking(CheckerOrGenerateItemDeclarationClocking<'a>),
|
Clocking(CheckerOrGenerateItemDeclarationClocking<'a>),
|
||||||
Expression(CheckerOrGenerateItemDeclarationExpression<'a>),
|
Disable(CheckerOrGenerateItemDeclarationDisable<'a>),
|
||||||
Empty(Symbol<'a>),
|
Empty(Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,17 +63,23 @@ pub struct CheckerOrGenerateItemDeclarationData<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct Rand<'a> {
|
pub struct Rand<'a> {
|
||||||
pub nodes: (Symbol<'a>),
|
pub nodes: (Symbol<'a>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct CheckerOrGenerateItemDeclarationClocking<'a> {
|
pub struct CheckerOrGenerateItemDeclarationClocking<'a> {
|
||||||
pub nodes: (ClockingIdentifier<'a>,),
|
pub nodes: (Symbol<'a>, Symbol<'a>, ClockingIdentifier<'a>, Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct CheckerOrGenerateItemDeclarationExpression<'a> {
|
pub struct CheckerOrGenerateItemDeclarationDisable<'a> {
|
||||||
pub nodes: (ExpressionOrDist<'a>,),
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
ExpressionOrDist<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -86,27 +93,145 @@ pub enum CheckerGenerateItem<'a> {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn checker_port_list(s: Span) -> IResult<Span, CheckerPortList> {
|
pub fn checker_port_list(s: Span) -> IResult<Span, CheckerPortList> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(symbol(","), checker_port_item)(s)?;
|
||||||
|
Ok((s, CheckerPortList { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn checker_port_item(s: Span) -> IResult<Span, CheckerPortItem> {
|
pub fn checker_port_item(s: Span) -> IResult<Span, CheckerPortItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = opt(checker_port_direction)(s)?;
|
||||||
|
let (s, c) = property_formal_type(s)?;
|
||||||
|
let (s, d) = formal_port_identifier(s)?;
|
||||||
|
let (s, e) = many0(variable_dimension)(s)?;
|
||||||
|
let (s, f) = opt(pair(symbol("="), property_actual_arg))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
CheckerPortItem {
|
||||||
|
nodes: (a, b, c, d, e, f),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn checker_port_direction(s: Span) -> IResult<Span, CheckerPortDirection> {
|
pub fn checker_port_direction(s: Span) -> IResult<Span, CheckerPortDirection> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(symbol("input"), |x| CheckerPortDirection::Input(x)),
|
||||||
|
map(symbol("output"), |x| CheckerPortDirection::Output(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn checker_or_generate_item(s: Span) -> IResult<Span, CheckerOrGenerateItem> {
|
pub fn checker_or_generate_item(s: Span) -> IResult<Span, CheckerOrGenerateItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(checker_or_generate_item_declaration, |x| {
|
||||||
|
CheckerOrGenerateItem::CheckerOrGenerateItemDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(initial_construct, |x| {
|
||||||
|
CheckerOrGenerateItem::InitialConstruct(x)
|
||||||
|
}),
|
||||||
|
map(always_construct, |x| {
|
||||||
|
CheckerOrGenerateItem::AlwaysConstruct(x)
|
||||||
|
}),
|
||||||
|
map(final_construct, |x| {
|
||||||
|
CheckerOrGenerateItem::FinalConstruct(x)
|
||||||
|
}),
|
||||||
|
map(assertion_item, |x| CheckerOrGenerateItem::AssertionItem(x)),
|
||||||
|
map(continuous_assign, |x| {
|
||||||
|
CheckerOrGenerateItem::ContinuousAssign(x)
|
||||||
|
}),
|
||||||
|
map(checker_generate_item, |x| {
|
||||||
|
CheckerOrGenerateItem::CheckerGenerateItem(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn checker_or_generate_item_declaration(
|
pub fn checker_or_generate_item_declaration(
|
||||||
s: Span,
|
s: Span,
|
||||||
) -> IResult<Span, CheckerOrGenerateItemDeclaration> {
|
) -> IResult<Span, CheckerOrGenerateItemDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
checker_or_generate_item_declaration_data,
|
||||||
|
map(function_declaration, |x| {
|
||||||
|
CheckerOrGenerateItemDeclaration::FunctionDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(checker_declaration, |x| {
|
||||||
|
CheckerOrGenerateItemDeclaration::CheckerDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(assertion_item_declaration, |x| {
|
||||||
|
CheckerOrGenerateItemDeclaration::AssertionItemDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(covergroup_declaration, |x| {
|
||||||
|
CheckerOrGenerateItemDeclaration::CovergroupDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(genvar_declaration, |x| {
|
||||||
|
CheckerOrGenerateItemDeclaration::GenvarDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(clocking_declaration, |x| {
|
||||||
|
CheckerOrGenerateItemDeclaration::ClockingDeclaration(x)
|
||||||
|
}),
|
||||||
|
checker_or_generate_item_declaration_clocking,
|
||||||
|
checker_or_generate_item_declaration_disable,
|
||||||
|
map(symbol(";"), |x| CheckerOrGenerateItemDeclaration::Empty(x)),
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn checker_or_generate_item_declaration_data(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, CheckerOrGenerateItemDeclaration> {
|
||||||
|
let (s, a) = opt(rand)(s)?;
|
||||||
|
let (s, b) = data_declaration(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
CheckerOrGenerateItemDeclaration::Data(CheckerOrGenerateItemDeclarationData {
|
||||||
|
nodes: (a, b),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn rand(s: Span) -> IResult<Span, Rand> {
|
||||||
|
let (s, a) = symbol("rand")(s)?;
|
||||||
|
Ok((s, Rand { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn checker_or_generate_item_declaration_clocking(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, CheckerOrGenerateItemDeclaration> {
|
||||||
|
let (s, a) = symbol("default")(s)?;
|
||||||
|
let (s, b) = symbol("clocking")(s)?;
|
||||||
|
let (s, c) = clocking_identifier(s)?;
|
||||||
|
let (s, d) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
CheckerOrGenerateItemDeclaration::Clocking(CheckerOrGenerateItemDeclarationClocking {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn checker_or_generate_item_declaration_disable(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, CheckerOrGenerateItemDeclaration> {
|
||||||
|
let (s, a) = symbol("default")(s)?;
|
||||||
|
let (s, b) = symbol("disable")(s)?;
|
||||||
|
let (s, c) = symbol("iff")(s)?;
|
||||||
|
let (s, d) = expression_or_dist(s)?;
|
||||||
|
let (s, e) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
CheckerOrGenerateItemDeclaration::Disable(CheckerOrGenerateItemDeclarationDisable {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
}),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn checker_generate_item(s: Span) -> IResult<Span, CheckerGenerateItem> {
|
pub fn checker_generate_item(s: Span) -> IResult<Span, CheckerGenerateItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(loop_generate_construct, |x| {
|
||||||
|
CheckerGenerateItem::LoopGenerateConstruct(Box::new(x))
|
||||||
|
}),
|
||||||
|
map(conditional_generate_construct, |x| {
|
||||||
|
CheckerGenerateItem::ConditionalGenerateConstruct(Box::new(x))
|
||||||
|
}),
|
||||||
|
map(generate_region, |x| CheckerGenerateItem::GenerateRegion(x)),
|
||||||
|
map(elaboration_system_task, |x| {
|
||||||
|
CheckerGenerateItem::ElaborationSystemTask(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
//use nom::branch::*;
|
use nom::branch::*;
|
||||||
//use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::error::*;
|
use nom::multi::*;
|
||||||
use nom::{Err, IResult};
|
use nom::sequence::*;
|
||||||
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -14,8 +15,8 @@ pub enum ClassItem<'a> {
|
|||||||
Constraint(ClassItemConstraint<'a>),
|
Constraint(ClassItemConstraint<'a>),
|
||||||
Declaration(ClassItemDeclaration<'a>),
|
Declaration(ClassItemDeclaration<'a>),
|
||||||
Covergroup(ClassItemCovergroup<'a>),
|
Covergroup(ClassItemCovergroup<'a>),
|
||||||
LocalParameterDeclaration(LocalParameterDeclaration<'a>),
|
LocalParameterDeclaration((LocalParameterDeclaration<'a>, Symbol<'a>)),
|
||||||
ParameterDeclaration(ParameterDeclaration<'a>),
|
ParameterDeclaration((ParameterDeclaration<'a>, Symbol<'a>)),
|
||||||
Empty(Symbol<'a>),
|
Empty(Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,10 +59,12 @@ pub struct ClassPropertyNonConst<'a> {
|
|||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ClassPropertyConst<'a> {
|
pub struct ClassPropertyConst<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
Vec<ClassItemQualifier<'a>>,
|
Vec<ClassItemQualifier<'a>>,
|
||||||
DataType<'a>,
|
DataType<'a>,
|
||||||
ConstIdentifier<'a>,
|
ConstIdentifier<'a>,
|
||||||
Option<ConstantExpression<'a>>,
|
Option<(Symbol<'a>, ConstantExpression<'a>)>,
|
||||||
|
Symbol<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,27 +90,47 @@ pub struct ClassMethodFunction<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ClassMethodPureVirtual<'a> {
|
pub struct ClassMethodPureVirtual<'a> {
|
||||||
pub nodes: (Vec<ClassItemQualifier<'a>>, MethodPrototype<'a>),
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Vec<ClassItemQualifier<'a>>,
|
||||||
|
MethodPrototype<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ClassMethodExternMethod<'a> {
|
pub struct ClassMethodExternMethod<'a> {
|
||||||
pub nodes: (Vec<MethodQualifier<'a>>, MethodPrototype<'a>),
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
Vec<MethodQualifier<'a>>,
|
||||||
|
MethodPrototype<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ClassMethodConstructor<'a> {
|
pub struct ClassMethodConstructor<'a> {
|
||||||
pub nodes: (Vec<MethodQualifier<'a>>, ClassConstructorPrototype<'a>),
|
pub nodes: (Vec<MethodQualifier<'a>>, ClassConstructorDeclaration<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ClassMethodExternConstructor<'a> {
|
pub struct ClassMethodExternConstructor<'a> {
|
||||||
pub nodes: (Vec<MethodQualifier<'a>>, ClassConstructorPrototype<'a>),
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
Vec<MethodQualifier<'a>>,
|
||||||
|
ClassConstructorPrototype<'a>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ClassConstructorPrototype<'a> {
|
pub struct ClassConstructorPrototype<'a> {
|
||||||
pub nodes: (Option<TfPortList<'a>>,),
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Option<Paren<'a, Option<TfPortList<'a>>>>,
|
||||||
|
Symbol<'a>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -138,7 +161,7 @@ pub enum RandomQualifier<'a> {
|
|||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub enum MethodQualifier<'a> {
|
pub enum MethodQualifier<'a> {
|
||||||
Virtual(Symbol<'a>),
|
Virtual(Symbol<'a>),
|
||||||
PureVirtual(Symbol<'a>),
|
PureVirtual((Symbol<'a>, Symbol<'a>)),
|
||||||
ClassItemQualifier(ClassItemQualifier<'a>),
|
ClassItemQualifier(ClassItemQualifier<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,12 +174,22 @@ pub enum MethodPrototype<'a> {
|
|||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ClassConstructorDeclaration<'a> {
|
pub struct ClassConstructorDeclaration<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
Option<ClassScope<'a>>,
|
Option<ClassScope<'a>>,
|
||||||
Option<Option<TfPortList<'a>>>,
|
Symbol<'a>,
|
||||||
|
Option<Paren<'a, Option<TfPortList<'a>>>>,
|
||||||
|
Symbol<'a>,
|
||||||
Vec<BlockItemDeclaration<'a>>,
|
Vec<BlockItemDeclaration<'a>>,
|
||||||
Option<Option<ListOfArguments<'a>>>,
|
Option<(
|
||||||
|
Symbol<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
Option<Paren<'a, ListOfArguments<'a>>>,
|
||||||
|
Symbol<'a>,
|
||||||
|
)>,
|
||||||
Vec<FunctionStatementOrNull<'a>>,
|
Vec<FunctionStatementOrNull<'a>>,
|
||||||
Option<New<'a>>,
|
Symbol<'a>,
|
||||||
|
Option<(Symbol<'a>, New<'a>)>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,45 +201,256 @@ pub struct New<'a> {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn class_item(s: Span) -> IResult<Span, ClassItem> {
|
pub fn class_item(s: Span) -> IResult<Span, ClassItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
class_item_property,
|
||||||
|
class_item_method,
|
||||||
|
class_item_constraint,
|
||||||
|
class_item_declaration,
|
||||||
|
class_item_covergroup,
|
||||||
|
map(pair(local_parameter_declaration, symbol(";")), |x| {
|
||||||
|
ClassItem::LocalParameterDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(pair(parameter_declaration, symbol(";")), |x| {
|
||||||
|
ClassItem::ParameterDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(symbol(";"), |x| ClassItem::Empty(x)),
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_item_property(s: Span) -> IResult<Span, ClassItem> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = class_property(s)?;
|
||||||
|
Ok((s, ClassItem::Property(ClassItemProperty { nodes: (a, b) })))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_item_method(s: Span) -> IResult<Span, ClassItem> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = class_method(s)?;
|
||||||
|
Ok((s, ClassItem::Method(ClassItemMethod { nodes: (a, b) })))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_item_constraint(s: Span) -> IResult<Span, ClassItem> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = class_constraint(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ClassItem::Constraint(ClassItemConstraint { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_item_declaration(s: Span) -> IResult<Span, ClassItem> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = class_declaration(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ClassItem::Declaration(ClassItemDeclaration { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_item_covergroup(s: Span) -> IResult<Span, ClassItem> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = covergroup_declaration(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ClassItem::Covergroup(ClassItemCovergroup { nodes: (a, b) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn class_property(s: Span) -> IResult<Span, ClassProperty> {
|
pub fn class_property(s: Span) -> IResult<Span, ClassProperty> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((class_property_non_const, class_property_const))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_property_non_const(s: Span) -> IResult<Span, ClassProperty> {
|
||||||
|
let (s, a) = many0(property_qualifier)(s)?;
|
||||||
|
let (s, b) = data_declaration(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ClassProperty::NonConst(ClassPropertyNonConst { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_property_const(s: Span) -> IResult<Span, ClassProperty> {
|
||||||
|
let (s, a) = symbol("const")(s)?;
|
||||||
|
let (s, b) = many0(class_item_qualifier)(s)?;
|
||||||
|
let (s, c) = data_type(s)?;
|
||||||
|
let (s, d) = const_identifier(s)?;
|
||||||
|
let (s, e) = opt(pair(symbol("="), constant_expression))(s)?;
|
||||||
|
let (s, f) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ClassProperty::Const(ClassPropertyConst {
|
||||||
|
nodes: (a, b, c, d, e, f),
|
||||||
|
}),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn class_method(s: Span) -> IResult<Span, ClassMethod> {
|
pub fn class_method(s: Span) -> IResult<Span, ClassMethod> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
class_method_task,
|
||||||
|
class_method_function,
|
||||||
|
class_method_pure_virtual,
|
||||||
|
class_method_extern_method,
|
||||||
|
class_method_constructor,
|
||||||
|
class_method_extern_constructor,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_method_task(s: Span) -> IResult<Span, ClassMethod> {
|
||||||
|
let (s, a) = many0(method_qualifier)(s)?;
|
||||||
|
let (s, b) = task_declaration(s)?;
|
||||||
|
Ok((s, ClassMethod::Task(ClassMethodTask { nodes: (a, b) })))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_method_function(s: Span) -> IResult<Span, ClassMethod> {
|
||||||
|
let (s, a) = many0(method_qualifier)(s)?;
|
||||||
|
let (s, b) = function_declaration(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ClassMethod::Function(ClassMethodFunction { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_method_pure_virtual(s: Span) -> IResult<Span, ClassMethod> {
|
||||||
|
let (s, a) = symbol("pure")(s)?;
|
||||||
|
let (s, b) = symbol("virtual")(s)?;
|
||||||
|
let (s, c) = many0(class_item_qualifier)(s)?;
|
||||||
|
let (s, d) = method_prototype(s)?;
|
||||||
|
let (s, e) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ClassMethod::PureVirtual(ClassMethodPureVirtual {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_method_extern_method(s: Span) -> IResult<Span, ClassMethod> {
|
||||||
|
let (s, a) = symbol("extern")(s)?;
|
||||||
|
let (s, b) = many0(method_qualifier)(s)?;
|
||||||
|
let (s, c) = method_prototype(s)?;
|
||||||
|
let (s, d) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ClassMethod::ExternMethod(ClassMethodExternMethod {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_method_constructor(s: Span) -> IResult<Span, ClassMethod> {
|
||||||
|
let (s, a) = many0(method_qualifier)(s)?;
|
||||||
|
let (s, b) = class_constructor_declaration(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ClassMethod::Constructor(ClassMethodConstructor { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn class_method_extern_constructor(s: Span) -> IResult<Span, ClassMethod> {
|
||||||
|
let (s, a) = symbol("extern")(s)?;
|
||||||
|
let (s, b) = many0(method_qualifier)(s)?;
|
||||||
|
let (s, c) = class_constructor_prototype(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ClassMethod::ExternConstructor(ClassMethodExternConstructor { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn class_constructor_prototype(s: Span) -> IResult<Span, ClassConstructorPrototype> {
|
pub fn class_constructor_prototype(s: Span) -> IResult<Span, ClassConstructorPrototype> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("function")(s)?;
|
||||||
|
let (s, b) = symbol("new")(s)?;
|
||||||
|
let (s, c) = opt(paren(opt(tf_port_list)))(s)?;
|
||||||
|
let (s, d) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ClassConstructorPrototype {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn class_constraint(s: Span) -> IResult<Span, ClassConstraint> {
|
pub fn class_constraint(s: Span) -> IResult<Span, ClassConstraint> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(constraint_prototype, |x| {
|
||||||
|
ClassConstraint::ConstraintPrototype(x)
|
||||||
|
}),
|
||||||
|
map(constraint_declaration, |x| {
|
||||||
|
ClassConstraint::ConstraintDeclaration(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn class_item_qualifier(s: Span) -> IResult<Span, ClassItemQualifier> {
|
pub fn class_item_qualifier(s: Span) -> IResult<Span, ClassItemQualifier> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(symbol("static"), |x| ClassItemQualifier::Static(x)),
|
||||||
|
map(symbol("protected"), |x| ClassItemQualifier::Protected(x)),
|
||||||
|
map(symbol("local"), |x| ClassItemQualifier::Local(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn property_qualifier(s: Span) -> IResult<Span, PropertyQualifier> {
|
pub fn property_qualifier(s: Span) -> IResult<Span, PropertyQualifier> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(random_qualifier, |x| PropertyQualifier::RandomQualifier(x)),
|
||||||
|
map(class_item_qualifier, |x| {
|
||||||
|
PropertyQualifier::ClassItemQualifier(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn random_qualifier(s: Span) -> IResult<Span, RandomQualifier> {
|
pub fn random_qualifier(s: Span) -> IResult<Span, RandomQualifier> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(symbol("randc"), |x| RandomQualifier::Randc(x)),
|
||||||
|
map(symbol("rand"), |x| RandomQualifier::Rand(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn method_qualifier(s: Span) -> IResult<Span, MethodQualifier> {
|
pub fn method_qualifier(s: Span) -> IResult<Span, MethodQualifier> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(pair(symbol("pure"), symbol("virtual")), |x| {
|
||||||
|
MethodQualifier::PureVirtual(x)
|
||||||
|
}),
|
||||||
|
map(symbol("virtual"), |x| MethodQualifier::Virtual(x)),
|
||||||
|
map(class_item_qualifier, |x| {
|
||||||
|
MethodQualifier::ClassItemQualifier(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn method_prototype(s: Span) -> IResult<Span, MethodPrototype> {
|
pub fn method_prototype(s: Span) -> IResult<Span, MethodPrototype> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(task_prototype, |x| MethodPrototype::TaskPrototype(x)),
|
||||||
|
map(function_prototype, |x| {
|
||||||
|
MethodPrototype::FunctionPrototype(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
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)))
|
let (s, a) = symbol("function")(s)?;
|
||||||
|
let (s, b) = opt(class_scope)(s)?;
|
||||||
|
let (s, c) = symbol("new")(s)?;
|
||||||
|
let (s, d) = opt(paren(opt(tf_port_list)))(s)?;
|
||||||
|
let (s, e) = symbol(";")(s)?;
|
||||||
|
let (s, f) = many0(block_item_declaration)(s)?;
|
||||||
|
let (s, g) = opt(tuple((
|
||||||
|
symbol("super"),
|
||||||
|
symbol("."),
|
||||||
|
symbol("new"),
|
||||||
|
opt(paren(list_of_arguments)),
|
||||||
|
symbol(";"),
|
||||||
|
)))(s)?;
|
||||||
|
let (s, h) = many0(function_statement_or_null)(s)?;
|
||||||
|
let (s, i) = symbol("end")(s)?;
|
||||||
|
let (s, j) = opt(pair(symbol(":"), new))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ClassConstructorDeclaration {
|
||||||
|
nodes: (a, b, c, d, e, f, g, h, i, j),
|
||||||
|
},
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new(s: Span) -> IResult<Span, New> {
|
||||||
|
let (s, a) = symbol("new")(s)?;
|
||||||
|
Ok((s, New { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,37 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
//use nom::branch::*;
|
use nom::branch::*;
|
||||||
//use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::error::*;
|
use nom::multi::*;
|
||||||
use nom::{Err, IResult};
|
use nom::sequence::*;
|
||||||
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConfigDeclaration<'a> {
|
pub struct ConfigDeclaration<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
ConfigIdentifier<'a>,
|
ConfigIdentifier<'a>,
|
||||||
Vec<LocalParameterDeclaration<'a>>,
|
Symbol<'a>,
|
||||||
|
Vec<(LocalParameterDeclaration<'a>, Symbol<'a>)>,
|
||||||
DesignStatement<'a>,
|
DesignStatement<'a>,
|
||||||
Vec<ConfigRuleStatement<'a>>,
|
Vec<ConfigRuleStatement<'a>>,
|
||||||
Option<ConfigIdentifier<'a>>,
|
Symbol<'a>,
|
||||||
|
Option<(Symbol<'a>, ConfigIdentifier<'a>)>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct DesignStatement<'a> {
|
pub struct DesignStatement<'a> {
|
||||||
pub nodes: (Vec<(Option<LibraryIdentifier<'a>>, CellIdentifier<'a>)>,),
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
Vec<(
|
||||||
|
Option<(LibraryIdentifier<'a>, Symbol<'a>)>,
|
||||||
|
CellIdentifier<'a>,
|
||||||
|
)>,
|
||||||
|
Symbol<'a>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -34,27 +45,27 @@ pub enum ConfigRuleStatement<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConfigRuleStatementDefault<'a> {
|
pub struct ConfigRuleStatementDefault<'a> {
|
||||||
pub nodes: (DefaultClause<'a>, LiblistClause<'a>),
|
pub nodes: (DefaultClause<'a>, LiblistClause<'a>, Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConfigRuleStatementInstLib<'a> {
|
pub struct ConfigRuleStatementInstLib<'a> {
|
||||||
pub nodes: (InstClause<'a>, LiblistClause<'a>),
|
pub nodes: (InstClause<'a>, LiblistClause<'a>, Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConfigRuleStatementInstUse<'a> {
|
pub struct ConfigRuleStatementInstUse<'a> {
|
||||||
pub nodes: (InstClause<'a>, UseClause<'a>),
|
pub nodes: (InstClause<'a>, UseClause<'a>, Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConfigRuleStatementCellLib<'a> {
|
pub struct ConfigRuleStatementCellLib<'a> {
|
||||||
pub nodes: (CellClause<'a>, LiblistClause<'a>),
|
pub nodes: (CellClause<'a>, LiblistClause<'a>, Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConfigRuleStatementCellUse<'a> {
|
pub struct ConfigRuleStatementCellUse<'a> {
|
||||||
pub nodes: (CellClause<'a>, UseClause<'a>),
|
pub nodes: (CellClause<'a>, UseClause<'a>, Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -64,22 +75,29 @@ pub struct DefaultClause<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct InstClause<'a> {
|
pub struct InstClause<'a> {
|
||||||
pub nodes: (InstName<'a>,),
|
pub nodes: (Symbol<'a>, InstName<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct InstName<'a> {
|
pub struct InstName<'a> {
|
||||||
pub nodes: (TopmoduleIdentifier<'a>, Vec<InstanceIdentifier<'a>>),
|
pub nodes: (
|
||||||
|
TopmoduleIdentifier<'a>,
|
||||||
|
Vec<(Symbol<'a>, InstanceIdentifier<'a>)>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct CellClause<'a> {
|
pub struct CellClause<'a> {
|
||||||
pub nodes: (Option<LibraryIdentifier<'a>>, CellIdentifier<'a>),
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
Option<(LibraryIdentifier<'a>, Symbol<'a>)>,
|
||||||
|
CellIdentifier<'a>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct LiblistClause<'a> {
|
pub struct LiblistClause<'a> {
|
||||||
pub nodes: (Vec<LibraryIdentifier<'a>>,),
|
pub nodes: (Symbol<'a>, Vec<LibraryIdentifier<'a>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -92,24 +110,30 @@ pub enum UseClause<'a> {
|
|||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct UseClauseCell<'a> {
|
pub struct UseClauseCell<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
Option<LibraryIdentifier<'a>>,
|
Symbol<'a>,
|
||||||
|
Option<(LibraryIdentifier<'a>, Symbol<'a>)>,
|
||||||
CellIdentifier<'a>,
|
CellIdentifier<'a>,
|
||||||
Option<Config<'a>>,
|
Option<(Symbol<'a>, Config<'a>)>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct UseClauseNamed<'a> {
|
pub struct UseClauseNamed<'a> {
|
||||||
pub nodes: (Vec<NamedParameterAssignment<'a>>, Option<Config<'a>>),
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
List<Symbol<'a>, NamedParameterAssignment<'a>>,
|
||||||
|
Option<(Symbol<'a>, Config<'a>)>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct UseClauseCellNamed<'a> {
|
pub struct UseClauseCellNamed<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
Option<LibraryIdentifier<'a>>,
|
Symbol<'a>,
|
||||||
|
Option<(LibraryIdentifier<'a>, Symbol<'a>)>,
|
||||||
CellIdentifier<'a>,
|
CellIdentifier<'a>,
|
||||||
Vec<NamedParameterAssignment<'a>>,
|
List<Symbol<'a>, NamedParameterAssignment<'a>>,
|
||||||
Option<Config<'a>>,
|
Option<(Symbol<'a>, Config<'a>)>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,37 +145,161 @@ pub struct Config<'a> {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn config_declaration(s: Span) -> IResult<Span, ConfigDeclaration> {
|
pub fn config_declaration(s: Span) -> IResult<Span, ConfigDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("config")(s)?;
|
||||||
|
let (s, b) = config_identifier(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
let (s, d) = many0(pair(local_parameter_declaration, symbol(";")))(s)?;
|
||||||
|
let (s, e) = design_statement(s)?;
|
||||||
|
let (s, f) = many0(config_rule_statement)(s)?;
|
||||||
|
let (s, g) = symbol("endconfig")(s)?;
|
||||||
|
let (s, h) = opt(pair(symbol(":"), config_identifier))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConfigDeclaration {
|
||||||
|
nodes: (a, b, c, d, e, f, g, h),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn design_statement(s: Span) -> IResult<Span, DesignStatement> {
|
pub fn design_statement(s: Span) -> IResult<Span, DesignStatement> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("design")(s)?;
|
||||||
|
let (s, b) = many0(pair(
|
||||||
|
opt(pair(library_identifier, symbol("."))),
|
||||||
|
cell_identifier,
|
||||||
|
))(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
Ok((s, DesignStatement { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn config_rule_statement(s: Span) -> IResult<Span, ConfigRuleStatement> {
|
pub fn config_rule_statement(s: Span) -> IResult<Span, ConfigRuleStatement> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
config_rule_statement_default,
|
||||||
|
config_rule_statement_inst_lib,
|
||||||
|
config_rule_statement_inst_use,
|
||||||
|
config_rule_statement_cell_lib,
|
||||||
|
config_rule_statement_cell_use,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn config_rule_statement_default(s: Span) -> IResult<Span, ConfigRuleStatement> {
|
||||||
|
let (s, a) = default_clause(s)?;
|
||||||
|
let (s, b) = liblist_clause(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConfigRuleStatement::Default(ConfigRuleStatementDefault { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn config_rule_statement_inst_lib(s: Span) -> IResult<Span, ConfigRuleStatement> {
|
||||||
|
let (s, a) = inst_clause(s)?;
|
||||||
|
let (s, b) = liblist_clause(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConfigRuleStatement::InstLib(ConfigRuleStatementInstLib { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn config_rule_statement_inst_use(s: Span) -> IResult<Span, ConfigRuleStatement> {
|
||||||
|
let (s, a) = inst_clause(s)?;
|
||||||
|
let (s, b) = use_clause(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConfigRuleStatement::InstUse(ConfigRuleStatementInstUse { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn config_rule_statement_cell_lib(s: Span) -> IResult<Span, ConfigRuleStatement> {
|
||||||
|
let (s, a) = cell_clause(s)?;
|
||||||
|
let (s, b) = liblist_clause(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConfigRuleStatement::CellLib(ConfigRuleStatementCellLib { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn config_rule_statement_cell_use(s: Span) -> IResult<Span, ConfigRuleStatement> {
|
||||||
|
let (s, a) = cell_clause(s)?;
|
||||||
|
let (s, b) = use_clause(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConfigRuleStatement::CellUse(ConfigRuleStatementCellUse { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_clause(s: Span) -> IResult<Span, DefaultClause> {
|
pub fn default_clause(s: Span) -> IResult<Span, DefaultClause> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("default")(s)?;
|
||||||
|
Ok((s, DefaultClause { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inst_clause(s: Span) -> IResult<Span, InstClause> {
|
pub fn inst_clause(s: Span) -> IResult<Span, InstClause> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("instance")(s)?;
|
||||||
|
let (s, b) = inst_name(s)?;
|
||||||
|
Ok((s, InstClause { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inst_name(s: Span) -> IResult<Span, InstName> {
|
pub fn inst_name(s: Span) -> IResult<Span, InstName> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = topmodule_identifier(s)?;
|
||||||
|
let (s, b) = many0(pair(symbol("."), instance_identifier))(s)?;
|
||||||
|
Ok((s, InstName { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cell_clause(s: Span) -> IResult<Span, CellClause> {
|
pub fn cell_clause(s: Span) -> IResult<Span, CellClause> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("cell")(s)?;
|
||||||
|
let (s, b) = opt(pair(library_identifier, symbol(".")))(s)?;
|
||||||
|
let (s, c) = cell_identifier(s)?;
|
||||||
|
Ok((s, CellClause { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn liblist_clause(s: Span) -> IResult<Span, LiblistClause> {
|
pub fn liblist_clause(s: Span) -> IResult<Span, LiblistClause> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("liblist")(s)?;
|
||||||
|
let (s, b) = many0(library_identifier)(s)?;
|
||||||
|
Ok((s, LiblistClause { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn use_clause(s: Span) -> IResult<Span, UseClause> {
|
pub fn use_clause(s: Span) -> IResult<Span, UseClause> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((use_clause_cell, use_clause_named, use_clause_cell_named))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn use_clause_cell(s: Span) -> IResult<Span, UseClause> {
|
||||||
|
let (s, a) = symbol("use")(s)?;
|
||||||
|
let (s, b) = opt(pair(library_identifier, symbol(".")))(s)?;
|
||||||
|
let (s, c) = cell_identifier(s)?;
|
||||||
|
let (s, d) = opt(pair(symbol(":"), config))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
UseClause::Cell(UseClauseCell {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn use_clause_named(s: Span) -> IResult<Span, UseClause> {
|
||||||
|
let (s, a) = symbol("use")(s)?;
|
||||||
|
let (s, b) = list(symbol(","), named_parameter_assignment)(s)?;
|
||||||
|
let (s, c) = opt(pair(symbol(":"), config))(s)?;
|
||||||
|
Ok((s, UseClause::Named(UseClauseNamed { nodes: (a, b, c) })))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn use_clause_cell_named(s: Span) -> IResult<Span, UseClause> {
|
||||||
|
let (s, a) = symbol("use")(s)?;
|
||||||
|
let (s, b) = opt(pair(library_identifier, symbol(".")))(s)?;
|
||||||
|
let (s, c) = cell_identifier(s)?;
|
||||||
|
let (s, d) = list(symbol(","), named_parameter_assignment)(s)?;
|
||||||
|
let (s, e) = opt(pair(symbol(":"), config))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
UseClause::CellNamed(UseClauseCellNamed {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn config(s: Span) -> IResult<Span, Config> {
|
||||||
|
let (s, a) = symbol("config")(s)?;
|
||||||
|
Ok((s, Config { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
//use nom::branch::*;
|
use nom::branch::*;
|
||||||
//use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::error::*;
|
use nom::multi::*;
|
||||||
use nom::{Err, IResult};
|
use nom::sequence::*;
|
||||||
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ use nom::{Err, IResult};
|
|||||||
pub struct ConstraintDeclaration<'a> {
|
pub struct ConstraintDeclaration<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
Option<Static<'a>>,
|
Option<Static<'a>>,
|
||||||
|
Symbol<'a>,
|
||||||
ConstraintIdentifier<'a>,
|
ConstraintIdentifier<'a>,
|
||||||
ConstraintBlock<'a>,
|
ConstraintBlock<'a>,
|
||||||
),
|
),
|
||||||
@ -23,7 +25,7 @@ pub struct Static<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConstraintBlock<'a> {
|
pub struct ConstraintBlock<'a> {
|
||||||
pub nodes: (Vec<ConstraintBlockItem<'a>>,),
|
pub nodes: (Brace<'a, Vec<ConstraintBlockItem<'a>>>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -34,12 +36,18 @@ pub enum ConstraintBlockItem<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConstraintBlockItemSolve<'a> {
|
pub struct ConstraintBlockItemSolve<'a> {
|
||||||
pub nodes: (SolveBeforeList<'a>, SolveBeforeList<'a>),
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
SolveBeforeList<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
SolveBeforeList<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct SolveBeforeList<'a> {
|
pub struct SolveBeforeList<'a> {
|
||||||
pub nodes: (Vec<ConstraintPrimary<'a>>,),
|
pub nodes: (List<Symbol<'a>, ConstraintPrimary<'a>>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -54,7 +62,7 @@ pub struct ConstraintPrimary<'a> {
|
|||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub enum ConstraintExpression<'a> {
|
pub enum ConstraintExpression<'a> {
|
||||||
Expression(ConstraintExpressionExpression<'a>),
|
Expression(ConstraintExpressionExpression<'a>),
|
||||||
UniquenessConstraint(UniquenessConstraint<'a>),
|
UniquenessConstraint((UniquenessConstraint<'a>, Symbol<'a>)),
|
||||||
Arrow(ConstraintExpressionArrow<'a>),
|
Arrow(ConstraintExpressionArrow<'a>),
|
||||||
If(ConstraintExpressionIf<'a>),
|
If(ConstraintExpressionIf<'a>),
|
||||||
Foreach(ConstraintExpressionForeach<'a>),
|
Foreach(ConstraintExpressionForeach<'a>),
|
||||||
@ -63,7 +71,7 @@ pub enum ConstraintExpression<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConstraintExpressionExpression<'a> {
|
pub struct ConstraintExpressionExpression<'a> {
|
||||||
pub nodes: (Option<Soft<'a>>, ExpressionOrDist<'a>),
|
pub nodes: (Option<Soft<'a>>, ExpressionOrDist<'a>, Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -73,47 +81,58 @@ pub struct Soft<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConstraintExpressionArrow<'a> {
|
pub struct ConstraintExpressionArrow<'a> {
|
||||||
pub nodes: (Expression<'a>, ConstraintSet<'a>),
|
pub nodes: (Expression<'a>, Symbol<'a>, ConstraintSet<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConstraintExpressionIf<'a> {
|
pub struct ConstraintExpressionIf<'a> {
|
||||||
pub nodes: (Expression<'a>, ConstraintSet<'a>, Option<ConstraintSet<'a>>),
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
Paren<'a, Expression<'a>>,
|
||||||
|
ConstraintSet<'a>,
|
||||||
|
Option<(Symbol<'a>, ConstraintSet<'a>)>,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConstraintExpressionForeach<'a> {
|
pub struct ConstraintExpressionForeach<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
|
Symbol<'a>,
|
||||||
|
Paren<
|
||||||
|
'a,
|
||||||
|
(
|
||||||
PsOrHierarchicalArrayIdentifier<'a>,
|
PsOrHierarchicalArrayIdentifier<'a>,
|
||||||
LoopVariables<'a>,
|
Bracket<'a, LoopVariables<'a>>,
|
||||||
|
),
|
||||||
|
>,
|
||||||
ConstraintSet<'a>,
|
ConstraintSet<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConstraintExpressionDisable<'a> {
|
pub struct ConstraintExpressionDisable<'a> {
|
||||||
pub nodes: (ConstraintPrimary<'a>,),
|
pub nodes: (Symbol<'a>, Symbol<'a>, ConstraintPrimary<'a>, Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct UniquenessConstraint<'a> {
|
pub struct UniquenessConstraint<'a> {
|
||||||
pub nodes: (OpenRangeList<'a>,),
|
pub nodes: (Symbol<'a>, Brace<'a, OpenRangeList<'a>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub enum ConstraintSet<'a> {
|
pub enum ConstraintSet<'a> {
|
||||||
ConstraintExpression(Box<ConstraintExpression<'a>>),
|
ConstraintExpression(Box<ConstraintExpression<'a>>),
|
||||||
Bracket(ConstraintSetBracket<'a>),
|
Brace(ConstraintSetBrace<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ConstraintSetBracket<'a> {
|
pub struct ConstraintSetBrace<'a> {
|
||||||
pub nodes: (Vec<ConstraintExpression<'a>>,),
|
pub nodes: (Brace<'a, Vec<ConstraintExpression<'a>>>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct DistList<'a> {
|
pub struct DistList<'a> {
|
||||||
pub nodes: (Vec<DistItem<'a>>,),
|
pub nodes: (List<Symbol<'a>, DistItem<'a>>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -129,12 +148,12 @@ pub enum DistWeight<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct DistWeightEqual<'a> {
|
pub struct DistWeightEqual<'a> {
|
||||||
pub nodes: (Expression<'a>,),
|
pub nodes: (Symbol<'a>, Expression<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct DistWeightDivide<'a> {
|
pub struct DistWeightDivide<'a> {
|
||||||
pub nodes: (Expression<'a>,),
|
pub nodes: (Symbol<'a>, Expression<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
@ -142,7 +161,9 @@ pub struct ConstraintPrototype<'a> {
|
|||||||
pub nodes: (
|
pub nodes: (
|
||||||
Option<ConstraintPrototypeQualifier<'a>>,
|
Option<ConstraintPrototypeQualifier<'a>>,
|
||||||
Option<Static<'a>>,
|
Option<Static<'a>>,
|
||||||
|
Symbol<'a>,
|
||||||
ConstraintIdentifier<'a>,
|
ConstraintIdentifier<'a>,
|
||||||
|
Symbol<'a>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,6 +177,7 @@ pub enum ConstraintPrototypeQualifier<'a> {
|
|||||||
pub struct ExternConstraintDeclaration<'a> {
|
pub struct ExternConstraintDeclaration<'a> {
|
||||||
pub nodes: (
|
pub nodes: (
|
||||||
Option<Static<'a>>,
|
Option<Static<'a>>,
|
||||||
|
Symbol<'a>,
|
||||||
ClassScope<'a>,
|
ClassScope<'a>,
|
||||||
ConstraintIdentifier<'a>,
|
ConstraintIdentifier<'a>,
|
||||||
ConstraintBlock<'a>,
|
ConstraintBlock<'a>,
|
||||||
@ -164,67 +186,231 @@ pub struct ExternConstraintDeclaration<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct IdentifierList<'a> {
|
pub struct IdentifierList<'a> {
|
||||||
pub nodes: (Vec<Identifier<'a>>,),
|
pub nodes: (List<Symbol<'a>, Identifier<'a>>,),
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn constraint_declaration(s: Span) -> IResult<Span, ConstraintDeclaration> {
|
pub fn constraint_declaration(s: Span) -> IResult<Span, ConstraintDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = opt(r#static)(s)?;
|
||||||
|
let (s, b) = symbol("constraint")(s)?;
|
||||||
|
let (s, c) = constraint_identifier(s)?;
|
||||||
|
let (s, d) = constraint_block(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConstraintDeclaration {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
},
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn r#static(s: Span) -> IResult<Span, Static> {
|
||||||
|
let (s, a) = symbol("static")(s)?;
|
||||||
|
Ok((s, Static { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constraint_block(s: Span) -> IResult<Span, ConstraintBlock> {
|
pub fn constraint_block(s: Span) -> IResult<Span, ConstraintBlock> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = brace(many0(constraint_block_item))(s)?;
|
||||||
|
Ok((s, ConstraintBlock { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constraint_block_item(s: Span) -> IResult<Span, ConstraintBlockItem> {
|
pub fn constraint_block_item(s: Span) -> IResult<Span, ConstraintBlockItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
constraint_block_item_solve,
|
||||||
|
map(constraint_expression, |x| {
|
||||||
|
ConstraintBlockItem::ConstraintExpression(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn constraint_block_item_solve(s: Span) -> IResult<Span, ConstraintBlockItem> {
|
||||||
|
let (s, a) = symbol("solve")(s)?;
|
||||||
|
let (s, b) = solve_before_list(s)?;
|
||||||
|
let (s, c) = symbol("before")(s)?;
|
||||||
|
let (s, d) = solve_before_list(s)?;
|
||||||
|
let (s, e) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConstraintBlockItem::Solve(ConstraintBlockItemSolve {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
}),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn solve_before_list(s: Span) -> IResult<Span, SolveBeforeList> {
|
pub fn solve_before_list(s: Span) -> IResult<Span, SolveBeforeList> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(symbol(","), constraint_primary)(s)?;
|
||||||
|
Ok((s, SolveBeforeList { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constraint_primary(s: Span) -> IResult<Span, ConstraintPrimary> {
|
pub fn constraint_primary(s: Span) -> IResult<Span, ConstraintPrimary> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = opt(implicit_class_handle_or_class_scope)(s)?;
|
||||||
|
let (s, b) = hierarchical_identifier(s)?;
|
||||||
|
let (s, c) = select(s)?;
|
||||||
|
Ok((s, ConstraintPrimary { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constraint_expression(s: Span) -> IResult<Span, ConstraintExpression> {
|
pub fn constraint_expression(s: Span) -> IResult<Span, ConstraintExpression> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
constraint_expression_expression,
|
||||||
|
map(pair(uniqueness_constraint, symbol(";")), |x| {
|
||||||
|
ConstraintExpression::UniquenessConstraint(x)
|
||||||
|
}),
|
||||||
|
constraint_expression_arrow,
|
||||||
|
constraint_expression_if,
|
||||||
|
constraint_expression_foreach,
|
||||||
|
constraint_expression_disable,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn constraint_expression_expression(s: Span) -> IResult<Span, ConstraintExpression> {
|
||||||
|
let (s, a) = opt(soft)(s)?;
|
||||||
|
let (s, b) = expression_or_dist(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConstraintExpression::Expression(ConstraintExpressionExpression { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn soft(s: Span) -> IResult<Span, Soft> {
|
||||||
|
let (s, a) = symbol("soft")(s)?;
|
||||||
|
Ok((s, Soft { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn constraint_expression_arrow(s: Span) -> IResult<Span, ConstraintExpression> {
|
||||||
|
let (s, a) = expression(s)?;
|
||||||
|
let (s, b) = symbol("->")(s)?;
|
||||||
|
let (s, c) = constraint_set(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConstraintExpression::Arrow(ConstraintExpressionArrow { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn constraint_expression_if(s: Span) -> IResult<Span, ConstraintExpression> {
|
||||||
|
let (s, a) = symbol("if")(s)?;
|
||||||
|
let (s, b) = paren(expression)(s)?;
|
||||||
|
let (s, c) = constraint_set(s)?;
|
||||||
|
let (s, d) = opt(pair(symbol("else"), constraint_set))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConstraintExpression::If(ConstraintExpressionIf {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn constraint_expression_foreach(s: Span) -> IResult<Span, ConstraintExpression> {
|
||||||
|
let (s, a) = symbol("foreach")(s)?;
|
||||||
|
let (s, b) = paren(pair(
|
||||||
|
ps_or_hierarchical_array_identifier,
|
||||||
|
bracket(loop_variables),
|
||||||
|
))(s)?;
|
||||||
|
let (s, c) = constraint_set(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConstraintExpression::Foreach(ConstraintExpressionForeach { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn constraint_expression_disable(s: Span) -> IResult<Span, ConstraintExpression> {
|
||||||
|
let (s, a) = symbol("disable")(s)?;
|
||||||
|
let (s, b) = symbol("soft")(s)?;
|
||||||
|
let (s, c) = constraint_primary(s)?;
|
||||||
|
let (s, d) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConstraintExpression::Disable(ConstraintExpressionDisable {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
}),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uniqueness_constraint(s: Span) -> IResult<Span, UniquenessConstraint> {
|
pub fn uniqueness_constraint(s: Span) -> IResult<Span, UniquenessConstraint> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = symbol("unique")(s)?;
|
||||||
|
let (s, b) = brace(open_range_list)(s)?;
|
||||||
|
Ok((s, UniquenessConstraint { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constraint_set(s: Span) -> IResult<Span, ConstraintSet> {
|
pub fn constraint_set(s: Span) -> IResult<Span, ConstraintSet> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(constraint_expression, |x| {
|
||||||
|
ConstraintSet::ConstraintExpression(Box::new(x))
|
||||||
|
}),
|
||||||
|
constraint_set_brace,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn constraint_set_brace(s: Span) -> IResult<Span, ConstraintSet> {
|
||||||
|
let (s, a) = brace(many0(constraint_expression))(s)?;
|
||||||
|
Ok((s, ConstraintSet::Brace(ConstraintSetBrace { nodes: (a,) })))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dist_list(s: Span) -> IResult<Span, DistList> {
|
pub fn dist_list(s: Span) -> IResult<Span, DistList> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(symbol(","), dist_item)(s)?;
|
||||||
|
Ok((s, DistList { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dist_item(s: Span) -> IResult<Span, DistItem> {
|
pub fn dist_item(s: Span) -> IResult<Span, DistItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = value_range(s)?;
|
||||||
|
let (s, b) = opt(dist_weight)(s)?;
|
||||||
|
Ok((s, DistItem { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dist_weight(s: Span) -> IResult<Span, DistWeight> {
|
pub fn dist_weight(s: Span) -> IResult<Span, DistWeight> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((dist_weight_equal, dist_weight_divide))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dist_weight_equal(s: Span) -> IResult<Span, DistWeight> {
|
||||||
|
let (s, a) = symbol(":=")(s)?;
|
||||||
|
let (s, b) = expression(s)?;
|
||||||
|
Ok((s, DistWeight::Equal(DistWeightEqual { nodes: (a, b) })))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dist_weight_divide(s: Span) -> IResult<Span, DistWeight> {
|
||||||
|
let (s, a) = symbol(":/")(s)?;
|
||||||
|
let (s, b) = expression(s)?;
|
||||||
|
Ok((s, DistWeight::Divide(DistWeightDivide { nodes: (a, b) })))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constraint_prototype(s: Span) -> IResult<Span, ConstraintPrototype> {
|
pub fn constraint_prototype(s: Span) -> IResult<Span, ConstraintPrototype> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = opt(constraint_prototype_qualifier)(s)?;
|
||||||
|
let (s, b) = opt(r#static)(s)?;
|
||||||
|
let (s, c) = symbol("constraint")(s)?;
|
||||||
|
let (s, d) = constraint_identifier(s)?;
|
||||||
|
let (s, e) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ConstraintPrototype {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constraint_prototype_qualifier(s: Span) -> IResult<Span, ConstraintPrototypeQualifier> {
|
pub fn constraint_prototype_qualifier(s: Span) -> IResult<Span, ConstraintPrototypeQualifier> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(symbol("extern"), |x| {
|
||||||
|
ConstraintPrototypeQualifier::Extern(x)
|
||||||
|
}),
|
||||||
|
map(symbol("pure"), |x| ConstraintPrototypeQualifier::Pure(x)),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn extern_constraint_declaration(s: Span) -> IResult<Span, ExternConstraintDeclaration> {
|
pub fn extern_constraint_declaration(s: Span) -> IResult<Span, ExternConstraintDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = opt(r#static)(s)?;
|
||||||
|
let (s, b) = symbol("constraint")(s)?;
|
||||||
|
let (s, c) = class_scope(s)?;
|
||||||
|
let (s, d) = constraint_identifier(s)?;
|
||||||
|
let (s, e) = constraint_block(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ExternConstraintDeclaration {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn identifier_list(s: Span) -> IResult<Span, IdentifierList> {
|
pub fn identifier_list(s: Span) -> IResult<Span, IdentifierList> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
let (s, a) = list(symbol(","), identifier)(s)?;
|
||||||
|
Ok((s, IdentifierList { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
//use nom::branch::*;
|
use nom::branch::*;
|
||||||
//use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::error::*;
|
use nom::multi::*;
|
||||||
use nom::{Err, IResult};
|
use nom::sequence::*;
|
||||||
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -31,17 +32,17 @@ pub enum ExternTfDeclaration<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ExternTfDeclarationMethod<'a> {
|
pub struct ExternTfDeclarationMethod<'a> {
|
||||||
pub nodes: (MethodPrototype<'a>),
|
pub nodes: (Symbol<'a>, MethodPrototype<'a>, Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub struct ExternTfDeclarationTask<'a> {
|
pub struct ExternTfDeclarationTask<'a> {
|
||||||
pub nodes: (TaskPrototype<'a>),
|
pub nodes: (Symbol<'a>, Symbol<'a>, TaskPrototype<'a>, Symbol<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub enum InterfaceItem<'a> {
|
pub enum InterfaceItem<'a> {
|
||||||
PortDeclaration(PortDeclaration<'a>),
|
PortDeclaration((PortDeclaration<'a>, Symbol<'a>)),
|
||||||
NonPortInterfaceItem(NonPortInterfaceItem<'a>),
|
NonPortInterfaceItem(NonPortInterfaceItem<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,17 +59,85 @@ pub enum NonPortInterfaceItem<'a> {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn interface_or_generate_item(s: Span) -> IResult<Span, InterfaceOrGenerateItem> {
|
pub fn interface_or_generate_item(s: Span) -> IResult<Span, InterfaceOrGenerateItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
interface_or_generate_item_module,
|
||||||
|
interface_or_generate_item_extern,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn interface_or_generate_item_module(s: Span) -> IResult<Span, InterfaceOrGenerateItem> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = module_common_item(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
InterfaceOrGenerateItem::Module(InterfaceOrGenerateItemModule { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn interface_or_generate_item_extern(s: Span) -> IResult<Span, InterfaceOrGenerateItem> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = extern_tf_declaration(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
InterfaceOrGenerateItem::Extern(InterfaceOrGenerateItemExtern { nodes: (a, b) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn extern_tf_declaration(s: Span) -> IResult<Span, ExternTfDeclaration> {
|
pub fn extern_tf_declaration(s: Span) -> IResult<Span, ExternTfDeclaration> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((extern_tf_declaration_method, extern_tf_declaration_task))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn extern_tf_declaration_method(s: Span) -> IResult<Span, ExternTfDeclaration> {
|
||||||
|
let (s, a) = symbol("extern")(s)?;
|
||||||
|
let (s, b) = method_prototype(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ExternTfDeclaration::Method(ExternTfDeclarationMethod { nodes: (a, b, c) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn extern_tf_declaration_task(s: Span) -> IResult<Span, ExternTfDeclaration> {
|
||||||
|
let (s, a) = symbol("extern")(s)?;
|
||||||
|
let (s, b) = symbol("forkjoin")(s)?;
|
||||||
|
let (s, c) = task_prototype(s)?;
|
||||||
|
let (s, d) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ExternTfDeclaration::Task(ExternTfDeclarationTask {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
}),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn interface_item(s: Span) -> IResult<Span, InterfaceItem> {
|
pub fn interface_item(s: Span) -> IResult<Span, InterfaceItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(pair(port_declaration, symbol(";")), |x| {
|
||||||
|
InterfaceItem::PortDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(non_port_interface_item, |x| {
|
||||||
|
InterfaceItem::NonPortInterfaceItem(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn non_port_interface_item(s: Span) -> IResult<Span, NonPortInterfaceItem> {
|
pub fn non_port_interface_item(s: Span) -> IResult<Span, NonPortInterfaceItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(generate_region, |x| NonPortInterfaceItem::GenerateRegion(x)),
|
||||||
|
map(interface_or_generate_item, |x| {
|
||||||
|
NonPortInterfaceItem::InterfaceOrGenerateItem(x)
|
||||||
|
}),
|
||||||
|
map(program_declaration, |x| {
|
||||||
|
NonPortInterfaceItem::ProgramDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(modport_declaration, |x| {
|
||||||
|
NonPortInterfaceItem::ModportDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(interface_declaration, |x| {
|
||||||
|
NonPortInterfaceItem::InterfaceDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(timeunits_declaration, |x| {
|
||||||
|
NonPortInterfaceItem::TimeunitsDeclaration(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
use crate::parser::*;
|
use crate::parser::*;
|
||||||
//use nom::branch::*;
|
use nom::branch::*;
|
||||||
//use nom::combinator::*;
|
use nom::combinator::*;
|
||||||
use nom::error::*;
|
use nom::multi::*;
|
||||||
use nom::{Err, IResult};
|
use nom::sequence::*;
|
||||||
|
use nom::IResult;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub enum ProgramItem<'a> {
|
pub enum ProgramItem<'a> {
|
||||||
PortDeclaration(PortDeclaration<'a>),
|
PortDeclaration((PortDeclaration<'a>, Symbol<'a>)),
|
||||||
NonPortProgramItem(NonPortProgramItem<'a>),
|
NonPortProgramItem(NonPortProgramItem<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ pub struct NonPortProgramItemAssertion<'a> {
|
|||||||
|
|
||||||
#[derive(Debug, Node)]
|
#[derive(Debug, Node)]
|
||||||
pub enum ProgramGenerateItem<'a> {
|
pub enum ProgramGenerateItem<'a> {
|
||||||
LoopGenerateConstuct(LoopGenerateConstruct<'a>),
|
LoopGenerateConstruct(LoopGenerateConstruct<'a>),
|
||||||
ConditionalGenerateConstruct(ConditionalGenerateConstruct<'a>),
|
ConditionalGenerateConstruct(ConditionalGenerateConstruct<'a>),
|
||||||
GenerateRegion(GenerateRegion<'a>),
|
GenerateRegion(GenerateRegion<'a>),
|
||||||
ElaborationSystemTask(ElaborationSystemTask<'a>),
|
ElaborationSystemTask(ElaborationSystemTask<'a>),
|
||||||
@ -63,13 +64,88 @@ pub enum ProgramGenerateItem<'a> {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub fn program_item(s: Span) -> IResult<Span, ProgramItem> {
|
pub fn program_item(s: Span) -> IResult<Span, ProgramItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(pair(port_declaration, symbol(";")), |x| {
|
||||||
|
ProgramItem::PortDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(non_port_program_item, |x| {
|
||||||
|
ProgramItem::NonPortProgramItem(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn non_port_program_item(s: Span) -> IResult<Span, NonPortProgramItem> {
|
pub fn non_port_program_item(s: Span) -> IResult<Span, NonPortProgramItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
non_port_program_item_assign,
|
||||||
|
non_port_program_item_module,
|
||||||
|
non_port_program_item_initial,
|
||||||
|
non_port_program_item_final,
|
||||||
|
non_port_program_item_assertion,
|
||||||
|
map(timeunits_declaration, |x| {
|
||||||
|
NonPortProgramItem::TimeunitsDeclaration(x)
|
||||||
|
}),
|
||||||
|
map(program_generate_item, |x| {
|
||||||
|
NonPortProgramItem::ProgramGenerateItem(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn non_port_program_item_assign(s: Span) -> IResult<Span, NonPortProgramItem> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = continuous_assign(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NonPortProgramItem::Assign(NonPortProgramItemAssign { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn non_port_program_item_module(s: Span) -> IResult<Span, NonPortProgramItem> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = module_or_generate_item_declaration(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NonPortProgramItem::Module(NonPortProgramItemModule { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn non_port_program_item_initial(s: Span) -> IResult<Span, NonPortProgramItem> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = initial_construct(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NonPortProgramItem::Initial(NonPortProgramItemInitial { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn non_port_program_item_final(s: Span) -> IResult<Span, NonPortProgramItem> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = final_construct(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NonPortProgramItem::Final(NonPortProgramItemFinal { nodes: (a, b) }),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn non_port_program_item_assertion(s: Span) -> IResult<Span, NonPortProgramItem> {
|
||||||
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
|
let (s, b) = concurrent_assertion_item(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NonPortProgramItem::Assertion(NonPortProgramItemAssertion { nodes: (a, b) }),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn program_generate_item(s: Span) -> IResult<Span, ProgramGenerateItem> {
|
pub fn program_generate_item(s: Span) -> IResult<Span, ProgramGenerateItem> {
|
||||||
Err(Err::Error(make_error(s, ErrorKind::Fix)))
|
alt((
|
||||||
|
map(loop_generate_construct, |x| {
|
||||||
|
ProgramGenerateItem::LoopGenerateConstruct(x)
|
||||||
|
}),
|
||||||
|
map(conditional_generate_construct, |x| {
|
||||||
|
ProgramGenerateItem::ConditionalGenerateConstruct(x)
|
||||||
|
}),
|
||||||
|
map(generate_region, |x| ProgramGenerateItem::GenerateRegion(x)),
|
||||||
|
map(elaboration_system_task, |x| {
|
||||||
|
ProgramGenerateItem::ElaborationSystemTask(x)
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user