Refactoring

This commit is contained in:
dalance 2019-07-12 21:51:00 +09:00
parent d839a4a47b
commit 783a420cfa
16 changed files with 1523 additions and 270 deletions

View File

@ -15,27 +15,27 @@ A parser library for System Verilog.
| source_text | checker_items | | | |
| source_text | class_items | | | |
| source_text | constraints | | | |
| source_text | package_items | | | |
| source_text | package_items | x | x | |
| declaration | module_parameter_declarations | x | x | |
| declaration | port_declarations | x | x | |
| declaration | type_declarations | x | x | |
| declaration | net_and_variable_types | | | |
| declaration | net_and_variable_types | x | | |
| declaration | strengths | x | x | x |
| declaration | delays | x | x | |
| declaration | declaration_lists | | | |
| declaration | declaration_assignments | | | |
| declaration | declaration_ranges | | | |
| declaration | function_declarations | | | |
| declaration | task_declarations | | | |
| declaration | declaration_lists | x | | |
| declaration | declaration_assignments | x | | |
| declaration | declaration_ranges | x | | |
| declaration | function_declarations | x | | |
| declaration | task_declarations | x | | |
| declaration | block_item_declarations | x | x | |
| declaration | interface_declarations | | | |
| declaration | assertion_declarations | | | |
| declaration | interface_declarations | x | | |
| declaration | assertion_declarations | x | | |
| declaration | covergroup_declarations | | | |
| declaration | let_declarations | | | |
| primitive_instance | primitive_instantiation_and_instances | | | |
| primitive_instance | primitive_strengths | | | |
| primitive_instance | primitive_terminals | | | |
| primitive_instance | primitive_gate_and_switch_types | | | |
| primitive_instance | primitive_instantiation_and_instances | x | x | |
| primitive_instance | primitive_strengths | x | x | x |
| primitive_instance | primitive_terminals | x | x | |
| primitive_instance | primitive_gate_and_switch_types | x | x | x |
| instantiations | module_instantiation | x | x | |
| instantiations | interface_instantiation | x | x | |
| instantiations | program_instantiation | x | x | |

View File

@ -67,70 +67,118 @@ where
}
}
impl<'a, T: 'a, U: 'a> From<&'a (T, U)> for AnyNodes<'a>
impl<'a, T0: 'a, T1: 'a> From<&'a (T0, T1)> for AnyNodes<'a>
where
&'a T: Into<AnyNodes<'a>>,
&'a U: Into<AnyNodes<'a>>,
&'a T0: Into<AnyNodes<'a>>,
&'a T1: Into<AnyNodes<'a>>,
{
fn from(x: &'a (T, U)) -> Self {
fn from(x: &'a (T0, T1)) -> Self {
let mut ret = Vec::new();
let (t, u) = x;
ret.append(&mut t.into().0);
ret.append(&mut u.into().0);
let (t0, t1) = x;
ret.append(&mut t0.into().0);
ret.append(&mut t1.into().0);
ret.into()
}
}
impl<'a, T: 'a, U: 'a, V: 'a> From<&'a (T, U, V)> for AnyNodes<'a>
impl<'a, T0: 'a, T1: 'a, T2: 'a> From<&'a (T0, T1, T2)> for AnyNodes<'a>
where
&'a T: Into<AnyNodes<'a>>,
&'a U: Into<AnyNodes<'a>>,
&'a V: Into<AnyNodes<'a>>,
&'a T0: Into<AnyNodes<'a>>,
&'a T1: Into<AnyNodes<'a>>,
&'a T2: Into<AnyNodes<'a>>,
{
fn from(x: &'a (T, U, V)) -> Self {
fn from(x: &'a (T0, T1, T2)) -> Self {
let mut ret = Vec::new();
let (t, u, v) = x;
ret.append(&mut t.into().0);
ret.append(&mut u.into().0);
ret.append(&mut v.into().0);
let (t0, t1, t2) = x;
ret.append(&mut t0.into().0);
ret.append(&mut t1.into().0);
ret.append(&mut t2.into().0);
ret.into()
}
}
impl<'a, T: 'a, U: 'a, V: 'a, W: 'a> From<&'a (T, U, V, W)> for AnyNodes<'a>
impl<'a, T0: 'a, T1: 'a, T2: 'a, T3: 'a> From<&'a (T0, T1, T2, T3)> for AnyNodes<'a>
where
&'a T: Into<AnyNodes<'a>>,
&'a U: Into<AnyNodes<'a>>,
&'a V: Into<AnyNodes<'a>>,
&'a W: Into<AnyNodes<'a>>,
&'a T0: Into<AnyNodes<'a>>,
&'a T1: Into<AnyNodes<'a>>,
&'a T2: Into<AnyNodes<'a>>,
&'a T3: Into<AnyNodes<'a>>,
{
fn from(x: &'a (T, U, V, W)) -> Self {
fn from(x: &'a (T0, T1, T2, T3)) -> Self {
let mut ret = Vec::new();
let (t, u, v, w) = x;
ret.append(&mut t.into().0);
ret.append(&mut u.into().0);
ret.append(&mut v.into().0);
ret.append(&mut w.into().0);
let (t0, t1, t2, t3) = 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.into()
}
}
impl<'a, T: 'a, U: 'a, V: 'a, W: 'a, S: 'a> From<&'a (T, U, V, W, S)> for AnyNodes<'a>
impl<'a, T0: 'a, T1: 'a, T2: 'a, T3: 'a, T4: 'a> From<&'a (T0, T1, T2, T3, T4)> for AnyNodes<'a>
where
&'a T: Into<AnyNodes<'a>>,
&'a U: Into<AnyNodes<'a>>,
&'a V: Into<AnyNodes<'a>>,
&'a W: Into<AnyNodes<'a>>,
&'a S: Into<AnyNodes<'a>>,
&'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>>,
{
fn from(x: &'a (T, U, V, W, S)) -> Self {
fn from(x: &'a (T0, T1, T2, T3, T4)) -> Self {
let mut ret = Vec::new();
let (t, u, v, w, s) = x;
ret.append(&mut t.into().0);
ret.append(&mut u.into().0);
ret.append(&mut v.into().0);
ret.append(&mut w.into().0);
ret.append(&mut s.into().0);
let (t0, t1, t2, t3, t4) = 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.into()
}
}
impl<'a, T0: 'a, T1: 'a, T2: 'a, T3: 'a, T4: 'a, T5: 'a> From<&'a (T0, T1, T2, T3, T4, T5)>
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>>,
{
fn from(x: &'a (T0, T1, T2, T3, T4, T5)) -> Self {
let mut ret = Vec::new();
let (t0, t1, t2, t3, t4, t5) = 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.into()
}
}
impl<'a, T0: 'a, T1: 'a, T2: 'a, T3: 'a, T4: 'a, T5: 'a, T6: 'a>
From<&'a (T0, T1, T2, T3, T4, T5, T6)> 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>>,
{
fn from(x: &'a (T0, T1, T2, T3, T4, T5, T6)) -> Self {
let mut ret = Vec::new();
let (t0, t1, t2, t3, t4, t5, t6) = 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.into()
}
}

View File

@ -15,7 +15,10 @@ pub enum ConcurrentAssertionItem<'a> {
#[derive(Debug, Node)]
pub struct ConcurrentAssertionItemStatement<'a> {
pub nodes: (Identifier<'a>, ConcurrentAssertionStatement<'a>),
pub nodes: (
Option<(BlockIdentifier<'a>, Symbol<'a>)>,
ConcurrentAssertionStatement<'a>,
),
}
#[derive(Debug, Node)]
@ -29,42 +32,77 @@ pub enum ConcurrentAssertionStatement<'a> {
#[derive(Debug, Node)]
pub struct AssertPropertyStatement<'a> {
pub nodes: (PropertySpec<'a>, ActionBlock<'a>),
pub nodes: (
Symbol<'a>,
Symbol<'a>,
Paren<'a, PropertySpec<'a>>,
ActionBlock<'a>,
),
}
#[derive(Debug, Node)]
pub struct AssumePropertyStatement<'a> {
pub nodes: (PropertySpec<'a>, ActionBlock<'a>),
pub nodes: (
Symbol<'a>,
Symbol<'a>,
Paren<'a, PropertySpec<'a>>,
ActionBlock<'a>,
),
}
#[derive(Debug, Node)]
pub struct CoverPropertyStatement<'a> {
pub nodes: (PropertySpec<'a>, StatementOrNull<'a>),
pub nodes: (
Symbol<'a>,
Symbol<'a>,
Paren<'a, PropertySpec<'a>>,
StatementOrNull<'a>,
),
}
#[derive(Debug, Node)]
pub struct ExpectPropertyStatement<'a> {
pub nodes: (PropertySpec<'a>, ActionBlock<'a>),
pub nodes: (
Symbol<'a>,
Symbol<'a>,
Paren<'a, PropertySpec<'a>>,
ActionBlock<'a>,
),
}
#[derive(Debug, Node)]
pub struct CoverSequenceStatement<'a> {
pub nodes: (
Symbol<'a>,
Symbol<'a>,
Paren<
'a,
(
Option<ClockingEvent<'a>>,
Option<ExpressionOrDist<'a>>,
Option<(Symbol<'a>, Symbol<'a>, Paren<'a, ExpressionOrDist<'a>>)>,
SequenceExpr<'a>,
),
>,
StatementOrNull<'a>,
),
}
#[derive(Debug, Node)]
pub struct RestrictPropertyStatement<'a> {
pub nodes: (PropertySpec<'a>),
pub nodes: (
Symbol<'a>,
Symbol<'a>,
Paren<'a, PropertySpec<'a>>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct PropertyInstance<'a> {
pub nodes: (Identifier<'a>, Option<PropertyListOfArguments<'a>>),
pub nodes: (
PsOrHierarchicalPropertyIdentifier<'a>,
Option<Paren<'a, Option<PropertyListOfArguments<'a>>>>,
),
}
#[derive(Debug, Node)]
@ -76,14 +114,28 @@ pub enum PropertyListOfArguments<'a> {
#[derive(Debug, Node)]
pub struct PropertyListOfArgumentsOrdered<'a> {
pub nodes: (
Vec<PropertyActualArg<'a>>,
Vec<(Identifier<'a>, Option<PropertyActualArg<'a>>)>,
List<Symbol<'a>, Option<PropertyActualArg<'a>>>,
Vec<(
Symbol<'a>,
Symbol<'a>,
Identifier<'a>,
Paren<'a, Option<PropertyActualArg<'a>>>,
)>,
),
}
#[derive(Debug, Node)]
pub struct PropertyListOfArgumentsNamed<'a> {
pub nodes: (Vec<(Identifier<'a>, Option<PropertyActualArg<'a>>)>,),
pub nodes: (
List<
Symbol<'a>,
(
Symbol<'a>,
Identifier<'a>,
Paren<'a, Option<PropertyActualArg<'a>>>,
),
>,
),
}
#[derive(Debug, Node)]
@ -102,27 +154,32 @@ pub enum AssertionItemDeclaration<'a> {
#[derive(Debug, Node)]
pub struct PropertyDeclaration<'a> {
pub nodes: (
Identifier<'a>,
Option<PropertyPortList<'a>>,
Symbol<'a>,
PropertyIdentifier<'a>,
Option<Paren<'a, Option<PropertyPortList<'a>>>>,
Symbol<'a>,
Vec<AssertionVariableDeclaration<'a>>,
PropertySpec<'a>,
Option<Symbol<'a>>,
Symbol<'a>,
Option<(Symbol<'a>, PropertyIdentifier<'a>)>,
),
}
#[derive(Debug, Node)]
pub struct PropertyPortList<'a> {
pub nodes: (Vec<PropertyPortItem<'a>>,),
pub nodes: (List<Symbol<'a>, PropertyPortItem<'a>>,),
}
#[derive(Debug, Node)]
pub struct PropertyPortItem<'a> {
pub nodes: (
Vec<AttributeInstance<'a>>,
Option<PropertyLvarPortDirection<'a>>,
Option<(Symbol<'a>, Option<PropertyLvarPortDirection<'a>>)>,
PropertyFormalType<'a>,
Identifier<'a>,
FormalPortIdentifier<'a>,
Vec<VariableDimension<'a>>,
Option<PropertyActualArg<'a>>,
Option<(Symbol<'a>, PropertyActualArg<'a>)>,
),
}
@ -141,7 +198,7 @@ pub enum PropertyFormalType<'a> {
pub struct PropertySpec<'a> {
pub nodes: (
Option<ClockingEvent<'a>>,
Option<ExpressionOrDist<'a>>,
Option<(Symbol<'a>, Symbol<'a>, Paren<'a, ExpressionOrDist<'a>>)>,
PropertyExpr<'a>,
),
}
@ -158,7 +215,7 @@ pub enum PropertyExpr<'a> {
ImplicationOverlapped(Box<PropertyExprImplicationOverlapped<'a>>),
ImplicationNonoverlapped(Box<PropertyExprImplicationNonoverlapped<'a>>),
If(Box<PropertyExprIf<'a>>),
Case(PropertyExprCase<'a>),
Case(Box<PropertyExprCase<'a>>),
FollowedByOverlapped(Box<PropertyExprFollowedByOverlapped<'a>>),
FollowedByNonoverlapped(Box<PropertyExprFollowedByNonoverlapped<'a>>),
Nexttime(Box<PropertyExprNexttime<'a>>),
@ -183,146 +240,189 @@ pub enum PropertyExpr<'a> {
#[derive(Debug, Node)]
pub struct PropertyExprStrong<'a> {
pub nodes: (SequenceExpr<'a>,),
pub nodes: (Symbol<'a>, Paren<'a, SequenceExpr<'a>>),
}
#[derive(Debug, Node)]
pub struct PropertyExprWeak<'a> {
pub nodes: (SequenceExpr<'a>,),
pub nodes: (Symbol<'a>, Paren<'a, SequenceExpr<'a>>),
}
#[derive(Debug, Node)]
pub struct PropertyExprParen<'a> {
pub nodes: (PropertyExpr<'a>,),
pub nodes: (Paren<'a, SequenceExpr<'a>>,),
}
#[derive(Debug, Node)]
pub struct PropertyExprNot<'a> {
pub nodes: (PropertyExpr<'a>,),
pub nodes: (Symbol<'a>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprOr<'a> {
pub nodes: (PropertyExpr<'a>, PropertyExpr<'a>),
pub nodes: (PropertyExpr<'a>, Symbol<'a>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprAnd<'a> {
pub nodes: (PropertyExpr<'a>, PropertyExpr<'a>),
pub nodes: (PropertyExpr<'a>, Symbol<'a>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprImplicationOverlapped<'a> {
pub nodes: (SequenceExpr<'a>, PropertyExpr<'a>),
pub nodes: (SequenceExpr<'a>, Symbol<'a>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprImplicationNonoverlapped<'a> {
pub nodes: (SequenceExpr<'a>, PropertyExpr<'a>),
pub nodes: (SequenceExpr<'a>, Symbol<'a>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprIf<'a> {
pub nodes: (
ExpressionOrDist<'a>,
Symbol<'a>,
Paren<'a, ExpressionOrDist<'a>>,
PropertyExpr<'a>,
Option<PropertyExpr<'a>>,
Option<(Symbol<'a>, PropertyExpr<'a>)>,
),
}
#[derive(Debug, Node)]
pub struct PropertyExprCase<'a> {
pub nodes: (ExpressionOrDist<'a>, Vec<PropertyCaseItem<'a>>),
pub nodes: (
Symbol<'a>,
Paren<'a, ExpressionOrDist<'a>>,
PropertyCaseItem<'a>,
Vec<PropertyCaseItem<'a>>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct PropertyExprFollowedByOverlapped<'a> {
pub nodes: (SequenceExpr<'a>, PropertyExpr<'a>),
pub nodes: (SequenceExpr<'a>, Symbol<'a>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprFollowedByNonoverlapped<'a> {
pub nodes: (SequenceExpr<'a>, PropertyExpr<'a>),
pub nodes: (SequenceExpr<'a>, Symbol<'a>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprNexttime<'a> {
pub nodes: (Option<ConstantExpression<'a>>, PropertyExpr<'a>),
pub nodes: (
Symbol<'a>,
Option<Paren<'a, ConstantExpression<'a>>>,
PropertyExpr<'a>,
),
}
#[derive(Debug, Node)]
pub struct PropertyExprSNexttime<'a> {
pub nodes: (Option<ConstantExpression<'a>>, PropertyExpr<'a>),
pub nodes: (
Symbol<'a>,
Option<Paren<'a, ConstantExpression<'a>>>,
PropertyExpr<'a>,
),
}
#[derive(Debug, Node)]
pub struct PropertyExprAlways<'a> {
pub nodes: (Option<CycleDelayConstRangeExpression<'a>>, PropertyExpr<'a>),
pub nodes: (
Symbol<'a>,
Option<Paren<'a, CycleDelayConstRangeExpression<'a>>>,
PropertyExpr<'a>,
),
}
#[derive(Debug, Node)]
pub struct PropertyExprSAlways<'a> {
pub nodes: (Option<CycleDelayConstRangeExpression<'a>>, PropertyExpr<'a>),
pub nodes: (
Symbol<'a>,
Option<Paren<'a, CycleDelayConstRangeExpression<'a>>>,
PropertyExpr<'a>,
),
}
#[derive(Debug, Node)]
pub struct PropertyExprEventually<'a> {
pub nodes: (ConstantRange<'a>, PropertyExpr<'a>),
pub nodes: (Symbol<'a>, Paren<'a, ConstantRange<'a>>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprSEventually<'a> {
pub nodes: (Option<CycleDelayConstRangeExpression<'a>>, PropertyExpr<'a>),
pub nodes: (
Symbol<'a>,
Option<Paren<'a, CycleDelayConstRangeExpression<'a>>>,
PropertyExpr<'a>,
),
}
#[derive(Debug, Node)]
pub struct PropertyExprUntil<'a> {
pub nodes: (PropertyExpr<'a>, PropertyExpr<'a>),
pub nodes: (PropertyExpr<'a>, Symbol<'a>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprSUntil<'a> {
pub nodes: (PropertyExpr<'a>, PropertyExpr<'a>),
pub nodes: (PropertyExpr<'a>, Symbol<'a>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprUntilWith<'a> {
pub nodes: (PropertyExpr<'a>, PropertyExpr<'a>),
pub nodes: (PropertyExpr<'a>, Symbol<'a>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprSUntilWith<'a> {
pub nodes: (PropertyExpr<'a>, PropertyExpr<'a>),
pub nodes: (PropertyExpr<'a>, Symbol<'a>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprImplies<'a> {
pub nodes: (PropertyExpr<'a>, PropertyExpr<'a>),
pub nodes: (PropertyExpr<'a>, Symbol<'a>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprIff<'a> {
pub nodes: (PropertyExpr<'a>, PropertyExpr<'a>),
pub nodes: (PropertyExpr<'a>, Symbol<'a>, PropertyExpr<'a>),
}
#[derive(Debug, Node)]
pub struct PropertyExprAcceptOn<'a> {
pub nodes: (ExpressionOrDist<'a>, PropertyExpr<'a>),
pub nodes: (
Symbol<'a>,
Paren<'a, ExpressionOrDist<'a>>,
PropertyExpr<'a>,
),
}
#[derive(Debug, Node)]
pub struct PropertyExprRejectOn<'a> {
pub nodes: (ExpressionOrDist<'a>, PropertyExpr<'a>),
pub nodes: (
Symbol<'a>,
Paren<'a, ExpressionOrDist<'a>>,
PropertyExpr<'a>,
),
}
#[derive(Debug, Node)]
pub struct PropertyExprSyncAcceptOn<'a> {
pub nodes: (ExpressionOrDist<'a>, PropertyExpr<'a>),
pub nodes: (
Symbol<'a>,
Paren<'a, ExpressionOrDist<'a>>,
PropertyExpr<'a>,
),
}
#[derive(Debug, Node)]
pub struct PropertyExprSyncRejectOn<'a> {
pub nodes: (ExpressionOrDist<'a>, PropertyExpr<'a>),
pub nodes: (
Symbol<'a>,
Paren<'a, ExpressionOrDist<'a>>,
PropertyExpr<'a>,
),
}
#[derive(Debug, Node)]
@ -338,39 +438,48 @@ pub enum PropertyCaseItem<'a> {
#[derive(Debug, Node)]
pub struct PropertyCaseItemNondefault<'a> {
pub nodes: (Vec<ExpressionOrDist<'a>>, PropertyExpr<'a>),
pub nodes: (
List<Symbol<'a>, ExpressionOrDist<'a>>,
Symbol<'a>,
PropertyExpr<'a>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct PropertyCaseItemDefault<'a> {
pub nodes: (PropertyExpr<'a>,),
pub nodes: (Symbol<'a>, Option<Symbol<'a>>, PropertyExpr<'a>, Symbol<'a>),
}
#[derive(Debug, Node)]
pub struct SequenceDeclaration<'a> {
pub nodes: (
Identifier<'a>,
Option<SequencePortList<'a>>,
Symbol<'a>,
SequenceIdentifier<'a>,
Option<Paren<'a, Option<SequencePortList<'a>>>>,
Symbol<'a>,
Vec<AssertionVariableDeclaration<'a>>,
SequenceExpr<'a>,
Option<Identifier<'a>>,
Option<Symbol<'a>>,
Symbol<'a>,
Option<(Symbol<'a>, SequenceIdentifier<'a>)>,
),
}
#[derive(Debug, Node)]
pub struct SequencePortList<'a> {
pub nodes: (Vec<SequencePortItem<'a>>,),
pub nodes: (List<Symbol<'a>, SequencePortItem<'a>>,),
}
#[derive(Debug, Node)]
pub struct SequencePortItem<'a> {
pub nodes: (
Vec<AttributeInstance<'a>>,
Option<SequenceLvarPortDirection<'a>>,
Option<(Symbol<'a>, Option<SequenceLvarPortDirection<'a>>)>,
SequenceFormalType<'a>,
Identifier<'a>,
FormalPortIdentifier<'a>,
Vec<VariableDimension<'a>>,
Option<SequenceActualArg<'a>>,
Option<(Symbol<'a>, SequenceActualArg<'a>)>,
),
}
@ -390,10 +499,10 @@ pub enum SequenceFormalType<'a> {
#[derive(Debug, Node)]
pub enum SequenceExpr<'a> {
CycleDelayExpr(SequenceExprCycleDelayExpr<'a>),
CycleDelayExpr(Box<SequenceExprCycleDelayExpr<'a>>),
ExprCycleDelayExpr(Box<SequenceExprExprCycleDelayExpr<'a>>),
Expression(SequenceExprExpression<'a>),
Instance(SequenceExprInstance<'a>),
Instance(Box<SequenceExprInstance<'a>>),
Paren(Box<SequenceExprParen<'a>>),
And(Box<SequenceExprAnd<'a>>),
Intersect(Box<SequenceExprIntersect<'a>>),
@ -406,12 +515,18 @@ pub enum SequenceExpr<'a> {
#[derive(Debug, Node)]
pub struct SequenceExprCycleDelayExpr<'a> {
pub nodes: (Vec<(CycleDelayRange<'a>, SequenceExpr<'a>)>,),
pub nodes: (
CycleDelayRange<'a>,
SequenceExpr<'a>,
Vec<(CycleDelayRange<'a>, SequenceExpr<'a>)>,
),
}
#[derive(Debug, Node)]
pub struct SequenceExprExprCycleDelayExpr<'a> {
pub nodes: (
SequenceExpr<'a>,
CycleDelayRange<'a>,
SequenceExpr<'a>,
Vec<(CycleDelayRange<'a>, SequenceExpr<'a>)>,
),
@ -430,40 +545,42 @@ pub struct SequenceExprInstance<'a> {
#[derive(Debug, Node)]
pub struct SequenceExprParen<'a> {
pub nodes: (
SequenceExpr<'a>,
Vec<SequenceMatchItem<'a>>,
Paren<'a, (SequenceExpr<'a>, Vec<(Symbol<'a>, SequenceMatchItem<'a>)>)>,
Option<SequenceAbbrev<'a>>,
),
}
#[derive(Debug, Node)]
pub struct SequenceExprAnd<'a> {
pub nodes: (SequenceExpr<'a>, SequenceExpr<'a>),
pub nodes: (SequenceExpr<'a>, Symbol<'a>, SequenceExpr<'a>),
}
#[derive(Debug, Node)]
pub struct SequenceExprIntersect<'a> {
pub nodes: (SequenceExpr<'a>, SequenceExpr<'a>),
pub nodes: (SequenceExpr<'a>, Symbol<'a>, SequenceExpr<'a>),
}
#[derive(Debug, Node)]
pub struct SequenceExprOr<'a> {
pub nodes: (SequenceExpr<'a>, SequenceExpr<'a>),
pub nodes: (SequenceExpr<'a>, Symbol<'a>, SequenceExpr<'a>),
}
#[derive(Debug, Node)]
pub struct SequenceExprFirstMatch<'a> {
pub nodes: (SequenceExpr<'a>, Vec<SequenceMatchItem<'a>>),
pub nodes: (
Symbol<'a>,
Paren<'a, (SequenceExpr<'a>, Vec<(Symbol<'a>, SequenceMatchItem<'a>)>)>,
),
}
#[derive(Debug, Node)]
pub struct SequenceExprThroughout<'a> {
pub nodes: (ExpressionOrDist<'a>, SequenceExpr<'a>),
pub nodes: (ExpressionOrDist<'a>, Symbol<'a>, SequenceExpr<'a>),
}
#[derive(Debug, Node)]
pub struct SequenceExprWithin<'a> {
pub nodes: (SequenceExpr<'a>, SequenceExpr<'a>),
pub nodes: (SequenceExpr<'a>, Symbol<'a>, SequenceExpr<'a>),
}
#[derive(Debug, Node)]
@ -473,15 +590,35 @@ pub struct SequenceExprClockingEvent<'a> {
#[derive(Debug, Node)]
pub enum CycleDelayRange<'a> {
ConstantPrimary(ConstantPrimary<'a>),
CycleDelayConstRangeExpression(CycleDelayConstRangeExpression<'a>),
Asterisk(Symbol<'a>),
Plus(Symbol<'a>),
Primary(CycleDelayRangePrimary<'a>),
Expression(CycleDelayRangeExpression<'a>),
Asterisk(CycleDelayRangeAsterisk<'a>),
Plus(CycleDelayRangePlus<'a>),
}
#[derive(Debug, Node)]
pub struct CycleDelayRangePrimary<'a> {
pub nodes: (Symbol<'a>, ConstantPrimary<'a>),
}
#[derive(Debug, Node)]
pub struct CycleDelayRangeExpression<'a> {
pub nodes: (Symbol<'a>, Bracket<'a, CycleDelayConstRangeExpression<'a>>),
}
#[derive(Debug, Node)]
pub struct CycleDelayRangeAsterisk<'a> {
pub nodes: (Symbol<'a>, Bracket<'a, Symbol<'a>>),
}
#[derive(Debug, Node)]
pub struct CycleDelayRangePlus<'a> {
pub nodes: (Symbol<'a>, Bracket<'a, Symbol<'a>>),
}
#[derive(Debug, Node)]
pub struct SequenceMethodCall<'a> {
pub nodes: (SequenceInstance<'a>, Identifier<'a>),
pub nodes: (SequenceInstance<'a>, Symbol<'a>, MethodIdentifier<'a>),
}
#[derive(Debug, Node)]
@ -493,7 +630,10 @@ pub enum SequenceMatchItem<'a> {
#[derive(Debug, Node)]
pub struct SequenceInstance<'a> {
pub nodes: (Identifier<'a>, Option<SequenceListOfArguments<'a>>),
pub nodes: (
PsOrHierarchicalSequenceIdentifier<'a>,
Option<Paren<'a, Option<SequenceListOfArguments<'a>>>>,
),
}
#[derive(Debug, Node)]
@ -505,14 +645,28 @@ pub enum SequenceListOfArguments<'a> {
#[derive(Debug, Node)]
pub struct SequenceListOfArgumentsOrdered<'a> {
pub nodes: (
Vec<SequenceActualArg<'a>>,
Vec<(Identifier<'a>, Option<SequenceActualArg<'a>>)>,
List<Symbol<'a>, Option<SequenceActualArg<'a>>>,
Vec<(
Symbol<'a>,
Symbol<'a>,
Identifier<'a>,
Paren<'a, Option<SequenceActualArg<'a>>>,
)>,
),
}
#[derive(Debug, Node)]
pub struct SequenceListOfArgumentsNamed<'a> {
pub nodes: (Vec<(Identifier<'a>, Option<SequenceActualArg<'a>>)>,),
pub nodes: (
List<
Symbol<'a>,
(
Symbol<'a>,
Identifier<'a>,
Paren<'a, Option<SequenceActualArg<'a>>>,
),
>,
),
}
#[derive(Debug, Node)]
@ -535,19 +689,34 @@ pub struct SequenceAbbrev<'a> {
#[derive(Debug, Node)]
pub enum ConsecutiveRepetition<'a> {
ConstOrRangeExpression(ConstOrRangeExpression<'a>),
Asterisk(Symbol<'a>),
Plus(Symbol<'a>),
Expression(ConsecutiveRepetitionExpression<'a>),
Asterisk(ConsecutiveRepetitionAsterisk<'a>),
Plus(ConsecutiveRepetitionPlus<'a>),
}
#[derive(Debug, Node)]
pub struct ConsecutiveRepetitionExpression<'a> {
pub nodes: (Bracket<'a, (Symbol<'a>, ConstOrRangeExpression<'a>)>),
}
#[derive(Debug, Node)]
pub struct ConsecutiveRepetitionAsterisk<'a> {
pub nodes: (Bracket<'a, Symbol<'a>>,),
}
#[derive(Debug, Node)]
pub struct ConsecutiveRepetitionPlus<'a> {
pub nodes: (Bracket<'a, Symbol<'a>>,),
}
#[derive(Debug, Node)]
pub struct NonConsecutiveRepetition<'a> {
pub nodes: (ConstOrRangeExpression<'a>,),
pub nodes: (Bracket<'a, (Symbol<'a>, ConstOrRangeExpression<'a>)>,),
}
#[derive(Debug, Node)]
pub struct GotoRepetition<'a> {
pub nodes: (ConstOrRangeExpression<'a>,),
pub nodes: (Bracket<'a, (Symbol<'a>, ConstOrRangeExpression<'a>)>,),
}
#[derive(Debug, Node)]
@ -564,22 +733,29 @@ pub enum CycleDelayConstRangeExpression<'a> {
#[derive(Debug, Node)]
pub struct CycleDelayConstRangeExpressionBinary<'a> {
pub nodes: (ConstantExpression<'a>, ConstantExpression<'a>),
pub nodes: (ConstantExpression<'a>, Symbol<'a>, ConstantExpression<'a>),
}
#[derive(Debug, Node)]
pub struct CycleDelayConstRangeExpressionDollar<'a> {
pub nodes: (ConstantExpression<'a>,),
pub nodes: (ConstantExpression<'a>, Symbol<'a>, Symbol<'a>),
}
#[derive(Debug, Node)]
pub struct ExpressionOrDist<'a> {
pub nodes: (Expression<'a>, Option<DistList<'a>>),
pub nodes: (
Expression<'a>,
Option<(Symbol<'a>, Brace<'a, DistList<'a>>)>,
),
}
#[derive(Debug, Node)]
pub struct AssertionVariableDeclaration<'a> {
pub nodes: (VarDataType<'a>, ListOfVariableDeclAssignments<'a>),
pub nodes: (
VarDataType<'a>,
ListOfVariableDeclAssignments<'a>,
Symbol<'a>,
),
}
// -----------------------------------------------------------------------------

View File

@ -9,20 +9,28 @@ use nom::{Err, IResult};
#[derive(Debug, Node)]
pub struct DefparamAssignment<'a> {
pub nodes: (HierarchicalIdentifier<'a>, ConstantMintypmaxExpression<'a>),
pub nodes: (
HierarchicalParameterIdentifier<'a>,
Symbol<'a>,
ConstantMintypmaxExpression<'a>,
),
}
#[derive(Debug, Node)]
pub struct NetDeclAssignment<'a> {
pub nodes: (Identifier<'a>, Vec<UnpackedDimension<'a>>, Expression<'a>),
pub nodes: (
NetIdentifier<'a>,
Vec<UnpackedDimension<'a>>,
Option<(Symbol<'a>, Expression<'a>)>,
),
}
#[derive(Debug, Node)]
pub struct ParamAssignment<'a> {
pub nodes: (
Identifier<'a>,
ParameterIdentifier<'a>,
Vec<UnpackedDimension<'a>>,
ConstantParamExpression<'a>,
Option<(Symbol<'a>, ConstantParamExpression<'a>)>,
),
}
@ -34,23 +42,54 @@ pub enum SpecparamAssignment<'a> {
#[derive(Debug, Node)]
pub struct SpecparamAssignmentMintypmax<'a> {
pub nodes: (Identifier<'a>, ConstantMintypmaxExpression<'a>),
pub nodes: (
SpecparamIdentifier<'a>,
Symbol<'a>,
ConstantMintypmaxExpression<'a>,
),
}
#[derive(Debug, Node)]
pub struct TypeAssignment<'a> {
pub nodes: (Identifier<'a>, Option<DataType<'a>>),
pub nodes: (TypeIdentifier<'a>, Option<(Symbol<'a>, DataType<'a>)>),
}
#[derive(Debug, Node)]
pub struct PulseControlSpecparam<'a> {
pub enum PulseControlSpecparam<'a> {
WithoutDescriptor(PulseControlSpecparamWithoutDescriptor<'a>),
WithDescriptor(PulseControlSpecparamWithDescriptor<'a>),
}
#[derive(Debug, Node)]
pub struct PulseControlSpecparamWithoutDescriptor<'a> {
pub nodes: (
Option<(
SpecifyInputTerminalDescriptor<'a>,
SpecifyOutputTerminalDescriptor<'a>,
)>,
Symbol<'a>,
Symbol<'a>,
Paren<
'a,
(
RejectLimitValue<'a>,
Option<ErrorLimitValue<'a>>,
Option<(Symbol<'a>, ErrorLimitValue<'a>)>,
),
>,
),
}
#[derive(Debug, Node)]
pub struct PulseControlSpecparamWithDescriptor<'a> {
pub nodes: (
Symbol<'a>,
SpecifyInputTerminalDescriptor<'a>,
Symbol<'a>,
SpecifyOutputTerminalDescriptor<'a>,
Symbol<'a>,
Paren<
'a,
(
RejectLimitValue<'a>,
Option<(Symbol<'a>, ErrorLimitValue<'a>)>,
),
>,
),
}
@ -79,41 +118,57 @@ pub enum VariableDeclAssignment<'a> {
#[derive(Debug, Node)]
pub struct VariableDeclAssignmentVariable<'a> {
pub nodes: (
Identifier<'a>,
VariableIdentifier<'a>,
Vec<VariableDimension<'a>>,
Option<Expression<'a>>,
Option<(Symbol<'a>, Expression<'a>)>,
),
}
#[derive(Debug, Node)]
pub struct VariableDeclAssignmentDynamicArray<'a> {
pub nodes: (
Identifier<'a>,
DynamicArrayVariableIdentifier<'a>,
UnsizedDimension<'a>,
Vec<VariableDimension<'a>>,
Option<DynamicArrayNew<'a>>,
Option<(Symbol<'a>, DynamicArrayNew<'a>)>,
),
}
#[derive(Debug, Node)]
pub struct VariableDeclAssignmentClass<'a> {
pub nodes: (Identifier<'a>, Option<ClassNew<'a>>),
pub nodes: (
ClassVariableIdentifier<'a>,
Option<(Symbol<'a>, ClassNew<'a>)>,
),
}
#[derive(Debug, Node)]
pub enum ClassNew<'a> {
Argument(ClassNewArgument<'a>),
Expression(Expression<'a>),
Expression(ClassNewExpression<'a>),
}
#[derive(Debug, Node)]
pub struct ClassNewArgument<'a> {
pub nodes: (Option<ClassScope<'a>>, Option<ListOfArguments<'a>>),
pub nodes: (
Option<ClassScope<'a>>,
Symbol<'a>,
Option<Paren<'a, ListOfArguments<'a>>>,
),
}
#[derive(Debug, Node)]
pub struct ClassNewExpression<'a> {
pub nodes: (Symbol<'a>, Expression<'a>),
}
#[derive(Debug, Node)]
pub struct DynamicArrayNew<'a> {
pub nodes: (Expression<'a>, Option<Expression<'a>>),
pub nodes: (
Symbol<'a>,
Bracket<'a, Expression<'a>>,
Option<Bracket<'a, Expression<'a>>>,
),
}
// -----------------------------------------------------------------------------

View File

@ -9,78 +9,84 @@ use nom::{Err, IResult};
#[derive(Debug, Node)]
pub struct ListOfDefparamAssignments<'a> {
pub nodes: (Vec<DefparamAssignment<'a>>,),
pub nodes: (List<Symbol<'a>, DefparamAssignment<'a>>,),
}
#[derive(Debug, Node)]
pub struct ListOfGenvarIdentifiers<'a> {
pub nodes: (Vec<Identifier<'a>>,),
pub nodes: (List<Symbol<'a>, GenvarIdentifier<'a>>,),
}
#[derive(Debug, Node)]
pub struct ListOfInterfaceIdentifiers<'a> {
pub nodes: (Vec<(Identifier<'a>, Vec<UnpackedDimension<'a>>)>,),
pub nodes: (List<Symbol<'a>, (InterfaceIdentifier<'a>, Vec<UnpackedDimension<'a>>)>,),
}
#[derive(Debug, Node)]
pub struct ListOfNetDeclAssignments<'a> {
pub nodes: (Vec<NetDeclAssignment<'a>>,),
pub nodes: (List<Symbol<'a>, NetDeclAssignment<'a>>,),
}
#[derive(Debug, Node)]
pub struct ListOfParamAssignments<'a> {
pub nodes: (Vec<ParamAssignment<'a>>,),
pub nodes: (List<Symbol<'a>, ParamAssignment<'a>>,),
}
#[derive(Debug, Node)]
pub struct ListOfPortIdentifiers<'a> {
pub nodes: (Vec<(Identifier<'a>, Vec<UnpackedDimension<'a>>)>,),
pub nodes: (List<Symbol<'a>, (PortIdentifier<'a>, Vec<UnpackedDimension<'a>>)>,),
}
#[derive(Debug, Node)]
pub struct ListOfUdpPortIdentifiers<'a> {
pub nodes: (Vec<Identifier<'a>>,),
pub nodes: (List<Symbol<'a>, PortIdentifier<'a>>,),
}
#[derive(Debug, Node)]
pub struct ListOfSpecparamAssignments<'a> {
pub nodes: (Vec<SpecparamAssignment<'a>>,),
pub nodes: (List<Symbol<'a>, SpecparamAssignment<'a>>,),
}
#[derive(Debug, Node)]
pub struct ListOfTfVariableIdentifiers<'a> {
pub nodes: (
Vec<(
Identifier<'a>,
List<
Symbol<'a>,
(
PortIdentifier<'a>,
Vec<VariableDimension<'a>>,
Option<Expression<'a>>,
)>,
Option<(Symbol<'a>, Expression<'a>)>,
),
>,
),
}
#[derive(Debug, Node)]
pub struct ListOfTypeAssignments<'a> {
pub nodes: (Vec<TypeAssignment<'a>>,),
pub nodes: (List<Symbol<'a>, TypeAssignment<'a>>,),
}
#[derive(Debug, Node)]
pub struct ListOfVariableDeclAssignments<'a> {
pub nodes: (Vec<VariableDeclAssignment<'a>>,),
pub nodes: (List<Symbol<'a>, VariableDeclAssignment<'a>>,),
}
#[derive(Debug, Node)]
pub struct ListOfVariableIdentifiers<'a> {
pub nodes: (Vec<(Identifier<'a>, Vec<VariableDimension<'a>>)>,),
pub nodes: (List<Symbol<'a>, (VariableIdentifier<'a>, Vec<VariableDimension<'a>>)>,),
}
#[derive(Debug, Node)]
pub struct ListOfVariablePortIdentifiers<'a> {
pub nodes: (
Vec<(
Identifier<'a>,
List<
Symbol<'a>,
(
PortIdentifier<'a>,
Vec<VariableDimension<'a>>,
Option<ConstantExpression<'a>>,
)>,
Option<(Symbol<'a>, ConstantExpression<'a>)>,
),
>,
),
}

View File

@ -9,38 +9,63 @@ use nom::{Err, IResult};
#[derive(Debug, Node)]
pub enum UnpackedDimension<'a> {
Range(ConstantRange<'a>),
Expression(ConstantExpression<'a>),
Range(UnpackedDimensionRange<'a>),
Expression(UnpackedDimensionExpression<'a>),
}
#[derive(Debug, Node)]
pub struct UnpackedDimensionRange<'a> {
pub nodes: (Bracket<'a, ConstantRange<'a>>,),
}
#[derive(Debug, Node)]
pub struct UnpackedDimensionExpression<'a> {
pub nodes: (Bracket<'a, ConstantExpression<'a>>,),
}
#[derive(Debug, Node)]
pub enum PackedDimension<'a> {
Range(ConstantRange<'a>),
Range(PackedDimensionRange<'a>),
Unsized(UnsizedDimension<'a>),
}
#[derive(Debug, Node)]
pub struct PackedDimensionRange<'a> {
pub nodes: (Bracket<'a, ConstantRange<'a>>,),
}
#[derive(Debug, Node)]
pub enum AssociativeDimension<'a> {
DataType(DataType<'a>),
Asterisk(Symbol<'a>),
DataType(AssociativeDimensionDataType<'a>),
Asterisk(AssociativeDimensionAsterisk<'a>),
}
#[derive(Debug, Node)]
pub struct AssociativeDimensionDataType<'a> {
pub nodes: (Bracket<'a, DataType<'a>>,),
}
#[derive(Debug, Node)]
pub struct AssociativeDimensionAsterisk<'a> {
pub nodes: (Bracket<'a, Symbol<'a>>,),
}
#[derive(Debug, Node)]
pub enum VariableDimension<'a> {
Unsized(UnsizedDimension<'a>),
Unpacked(UnpackedDimension<'a>),
Associative(AssociativeDimension<'a>),
Queue(QueueDimension<'a>),
UnsizedDimension(UnsizedDimension<'a>),
UnpackedDimension(UnpackedDimension<'a>),
AssociativeDimension(AssociativeDimension<'a>),
QueueDimension(QueueDimension<'a>),
}
#[derive(Debug, Node)]
pub struct QueueDimension<'a> {
pub nodes: (Option<ConstantExpression<'a>>,),
pub nodes: (Bracket<'a, (Symbol<'a>, Option<(Symbol<'a>, ConstantExpression<'a>)>)>,),
}
#[derive(Debug, Node)]
pub struct UnsizedDimension<'a> {
pub nodes: (Symbol<'a>,),
pub nodes: ((Symbol<'a>, Symbol<'a>),),
}
// -----------------------------------------------------------------------------

View File

@ -9,13 +9,17 @@ use nom::{Err, IResult};
#[derive(Debug, Node)]
pub enum FunctionDataTypeOrImplicit<'a> {
DataType(DataTypeOrVoid<'a>),
Implicit(ImplicitDataType<'a>),
DataTypeOrVoid(DataTypeOrVoid<'a>),
ImplicitDataType(ImplicitDataType<'a>),
}
#[derive(Debug, Node)]
pub struct FunctionDeclaration<'a> {
pub nodes: (Option<Lifetime<'a>>, FunctionBodyDeclaration<'a>),
pub nodes: (
Symbol<'a>,
Option<Lifetime<'a>>,
FunctionBodyDeclaration<'a>,
),
}
#[derive(Debug, Node)]
@ -29,10 +33,12 @@ pub struct FunctionBodyDeclarationWithoutPort<'a> {
pub nodes: (
FunctionDataTypeOrImplicit<'a>,
Option<InterfaceIdentifierOrClassScope<'a>>,
Identifier<'a>,
FunctionIdentifier<'a>,
Symbol<'a>,
Vec<TfItemDeclaration<'a>>,
Vec<FunctionStatementOrNull<'a>>,
Option<Identifier<'a>>,
Symbol<'a>,
Option<(Symbol<'a>, FunctionIdentifier<'a>)>,
),
}
@ -41,17 +47,24 @@ pub struct FunctionBodyDeclarationWithPort<'a> {
pub nodes: (
FunctionDataTypeOrImplicit<'a>,
Option<InterfaceIdentifierOrClassScope<'a>>,
Identifier<'a>,
Option<TfPortList<'a>>,
FunctionIdentifier<'a>,
Paren<'a, Option<TfPortList<'a>>>,
Symbol<'a>,
Vec<BlockItemDeclaration<'a>>,
Vec<FunctionStatementOrNull<'a>>,
Option<Identifier<'a>>,
Symbol<'a>,
Option<(Symbol<'a>, FunctionIdentifier<'a>)>,
),
}
#[derive(Debug, Node)]
pub struct FunctionPrototype<'a> {
pub nodes: (DataTypeOrVoid<'a>, Identifier<'a>, Option<TfPortList<'a>>),
pub nodes: (
Symbol<'a>,
DataTypeOrVoid<'a>,
FunctionIdentifier<'a>,
Option<Paren<'a, Option<TfPortList<'a>>>>,
),
}
#[derive(Debug, Node)]
@ -65,31 +78,47 @@ pub enum DpiImportExport<'a> {
#[derive(Debug, Node)]
pub struct DpiImportExportImportFunction<'a> {
pub nodes: (
Symbol<'a>,
DpiSpecString<'a>,
Option<DpiFunctionImportProperty<'a>>,
Option<Identifier<'a>>,
Option<(CIdentifier<'a>, Symbol<'a>)>,
DpiFunctionProto<'a>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct DpiImportExportImportTask<'a> {
pub nodes: (
Symbol<'a>,
DpiSpecString<'a>,
Option<DpiTaskImportProperty<'a>>,
Option<Identifier<'a>>,
Option<(CIdentifier<'a>, Symbol<'a>)>,
DpiTaskProto<'a>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct DpiImportExportExportFunction<'a> {
pub nodes: (DpiSpecString<'a>, Option<Identifier<'a>>, Identifier<'a>),
pub nodes: (
Symbol<'a>,
DpiSpecString<'a>,
Option<(CIdentifier<'a>, Symbol<'a>)>,
Symbol<'a>,
FunctionIdentifier<'a>,
),
}
#[derive(Debug, Node)]
pub struct DpiImportExportExportTask<'a> {
pub nodes: (DpiSpecString<'a>, Option<Identifier<'a>>, Identifier<'a>),
pub nodes: (
Symbol<'a>,
DpiSpecString<'a>,
Option<(CIdentifier<'a>, Symbol<'a>)>,
Symbol<'a>,
TaskIdentifier<'a>,
),
}
#[derive(Debug, Node)]

View File

@ -9,12 +9,15 @@ use nom::{Err, IResult};
#[derive(Debug, Node)]
pub struct ModportDeclaration<'a> {
pub nodes: (Vec<ModportItem<'a>>,),
pub nodes: (Symbol<'a>, List<Symbol<'a>, ModportItem<'a>>, Symbol<'a>),
}
#[derive(Debug, Node)]
pub struct ModportItem<'a> {
pub nodes: (Identifier<'a>, Vec<ModportPortsDeclaraton<'a>>),
pub nodes: (
ModportIdentifier<'a>,
Paren<'a, List<Symbol<'a>, ModportPortsDeclaraton<'a>>>,
),
}
#[derive(Debug, Node)]
@ -44,12 +47,12 @@ pub struct ModportPortsDeclaratonClocking<'a> {
#[derive(Debug, Node)]
pub struct ModportClockingDeclaration<'a> {
pub nodes: (Identifier<'a>),
pub nodes: (Symbol<'a>, ClockingIdentifier<'a>),
}
#[derive(Debug, Node)]
pub struct ModportSimplePortsDeclaration<'a> {
pub nodes: (PortDirection<'a>, Vec<ModportSimplePort<'a>>),
pub nodes: (PortDirection<'a>, List<Symbol<'a>, ModportSimplePort<'a>>),
}
#[derive(Debug, Node)]
@ -60,23 +63,27 @@ pub enum ModportSimplePort<'a> {
#[derive(Debug, Node)]
pub struct ModportSimplePortOrdered<'a> {
pub nodes: (Identifier<'a>,),
pub nodes: (PortIdentifier<'a>,),
}
#[derive(Debug, Node)]
pub struct ModportSimplePortNamed<'a> {
pub nodes: (Identifier<'a>, Option<Expression<'a>>),
pub nodes: (
Symbol<'a>,
PortIdentifier<'a>,
Paren<'a, Option<Expression<'a>>>,
),
}
#[derive(Debug, Node)]
pub struct ModportTfPortsDeclaration<'a> {
pub nodes: (ImportExport<'a>, Vec<ModportTfPort<'a>>),
pub nodes: (ImportExport<'a>, List<Symbol<'a>, ModportTfPort<'a>>),
}
#[derive(Debug, Node)]
pub enum ModportTfPort<'a> {
Prototype(MethodPrototype<'a>),
Identifier(Identifier<'a>),
MethodPrototype(MethodPrototype<'a>),
TfIdentifier(TfIdentifier<'a>),
}
#[derive(Debug, Node)]

View File

@ -21,7 +21,7 @@ pub enum DataType<'a> {
Vector(DataTypeVector<'a>),
Atom(DataTypeAtom<'a>),
NonIntegerType(NonIntegerType<'a>),
Union(DataTypeUnion<'a>),
Union(Box<DataTypeUnion<'a>>),
Enum(DataTypeEnum<'a>),
String(Symbol<'a>),
Chandle(Symbol<'a>),
@ -52,7 +52,8 @@ pub struct DataTypeUnion<'a> {
pub nodes: (
StructUnion<'a>,
Option<(Packed<'a>, Option<Signing<'a>>)>,
Vec<StructUnionMember<'a>>,
Brace<'a, (StructUnionMember<'a>, Vec<StructUnionMember<'a>>)>,
Vec<PackedDimension<'a>>,
),
}
@ -64,8 +65,9 @@ pub struct Packed<'a> {
#[derive(Debug, Node)]
pub struct DataTypeEnum<'a> {
pub nodes: (
Symbol<'a>,
Option<EnumBaseType<'a>>,
Vec<EnumNameDeclaration<'a>>,
Brace<'a, List<Symbol<'a>, EnumNameDeclaration<'a>>>,
Vec<PackedDimension<'a>>,
),
}
@ -73,10 +75,11 @@ pub struct DataTypeEnum<'a> {
#[derive(Debug, Node)]
pub struct DataTypeVirtual<'a> {
pub nodes: (
Symbol<'a>,
Option<Interface<'a>>,
InterfaceIdentifier<'a>,
Option<ParameterValueAssignment<'a>>,
Option<ModportIdentifier<'a>>,
Option<(Symbol<'a>, ModportIdentifier<'a>)>,
),
}
@ -134,30 +137,34 @@ pub struct EnumBaseTypeType<'a> {
#[derive(Debug, Node)]
pub struct EnumNameDeclaration<'a> {
pub nodes: (
Identifier<'a>,
Option<(IntegralNumber<'a>, Option<IntegralNumber<'a>>)>,
Option<ConstantExpression<'a>>,
EnumIdentifier<'a>,
Option<Bracket<'a, (IntegralNumber<'a>, Option<(Symbol<'a>, IntegralNumber<'a>)>)>>,
Option<(Symbol<'a>, ConstantExpression<'a>)>,
),
}
#[derive(Debug, Node)]
pub struct ClassScope<'a> {
pub nodes: (ClassType<'a>,),
pub nodes: (ClassType<'a>, Symbol<'a>),
}
#[derive(Debug, Node)]
pub struct ClassType<'a> {
pub nodes: (
PsClassIdentifier<'a>,
Option<ParameterValueAssignment<'a>>,
Vec<(
Symbol<'a>,
Identifier<'a>,
Option<ParameterValueAssignment<'a>>,
Vec<(Identifier<'a>, Option<ParameterValueAssignment<'a>>)>,
)>,
),
}
#[derive(Debug, Node)]
pub enum IntegerType<'a> {
Vector(IntegerVectorType<'a>),
Atom(IntegerAtomType<'a>),
IntegerVectorType(IntegerVectorType<'a>),
IntegerAtomType(IntegerAtomType<'a>),
}
#[derive(Debug, Node)]
@ -203,8 +210,8 @@ pub enum NetType<'a> {
#[derive(Debug, Node)]
pub enum NetPortType<'a> {
DataType(NetPortTypeDataType<'a>),
NetType(Identifier<'a>),
Interconnect(ImplicitDataType<'a>),
NetTypeIdentifier(NetTypeIdentifier<'a>),
Interconnect(NetPortTypeInterconnect<'a>),
}
#[derive(Debug, Node)]
@ -212,6 +219,11 @@ pub struct NetPortTypeDataType<'a> {
pub nodes: (Option<NetType<'a>>, DataTypeOrImplicit<'a>),
}
#[derive(Debug, Node)]
pub struct NetPortTypeInterconnect<'a> {
pub nodes: (Symbol<'a>, ImplicitDataType<'a>),
}
#[derive(Debug, Node)]
pub struct VariablePortType<'a> {
pub nodes: (VarDataType<'a>,),
@ -220,7 +232,12 @@ pub struct VariablePortType<'a> {
#[derive(Debug, Node)]
pub enum VarDataType<'a> {
DataType(DataType<'a>),
DataTypeOrImplicit(DataTypeOrImplicit<'a>),
Var(VarDataTypeVar<'a>),
}
#[derive(Debug, Node)]
pub struct VarDataTypeVar<'a> {
pub nodes: (Symbol<'a>, DataTypeOrImplicit<'a>),
}
#[derive(Debug, Node)]
@ -233,8 +250,8 @@ pub enum Signing<'a> {
pub enum SimpleType<'a> {
IntegerType(IntegerType<'a>),
NonNonIntegerType(IntegerType<'a>),
TypeIdentifier(Identifier<'a>),
ParameterIdentifier(Identifier<'a>),
PsTypeIdentifier(PsTypeIdentifier<'a>),
PsParameterIdentifier(PsParameterIdentifier<'a>),
}
#[derive(Debug, Node)]
@ -244,6 +261,7 @@ pub struct StructUnionMember<'a> {
Option<RandomQualifier<'a>>,
DataTypeOrVoid<'a>,
ListOfVariableDeclAssignments<'a>,
Symbol<'a>,
),
}
@ -257,13 +275,23 @@ pub enum DataTypeOrVoid<'a> {
pub enum StructUnion<'a> {
Struct(Symbol<'a>),
Union(Symbol<'a>),
UnionTagged(Symbol<'a>),
UnionTagged((Symbol<'a>, Symbol<'a>)),
}
#[derive(Debug, Node)]
pub enum TypeReference<'a> {
Expression(Expression<'a>),
DataType(DataType<'a>),
Expression(TypeReferenceExpression<'a>),
DataType(TypeReferenceDataType<'a>),
}
#[derive(Debug, Node)]
pub struct TypeReferenceExpression<'a> {
pub nodes: (Symbol<'a>, Paren<'a, Expression<'a>>),
}
#[derive(Debug, Node)]
pub struct TypeReferenceDataType<'a> {
pub nodes: (Symbol<'a>, Paren<'a, DataType<'a>>),
}
// -----------------------------------------------------------------------------

View File

@ -9,7 +9,7 @@ use nom::{Err, IResult};
#[derive(Debug, Node)]
pub struct TaskDeclaration<'a> {
pub nodes: (Option<Lifetime<'a>>, TaskBodyDeclaration<'a>),
pub nodes: (Symbol<'a>, Option<Lifetime<'a>>, TaskBodyDeclaration<'a>),
}
#[derive(Debug, Node)]
@ -22,10 +22,12 @@ pub enum TaskBodyDeclaration<'a> {
pub struct TaskBodyDeclarationWithoutPort<'a> {
pub nodes: (
Option<InterfaceIdentifierOrClassScope<'a>>,
Identifier<'a>,
TaskIdentifier<'a>,
Symbol<'a>,
Vec<TfItemDeclaration<'a>>,
Vec<FunctionStatementOrNull<'a>>,
Option<Identifier<'a>>,
Vec<StatementOrNull<'a>>,
Symbol<'a>,
Option<(Symbol<'a>, TaskIdentifier<'a>)>,
),
}
@ -33,29 +35,30 @@ pub struct TaskBodyDeclarationWithoutPort<'a> {
pub struct TaskBodyDeclarationWithPort<'a> {
pub nodes: (
Option<InterfaceIdentifierOrClassScope<'a>>,
Identifier<'a>,
Option<TfPortList<'a>>,
TaskIdentifier<'a>,
Paren<'a, Option<TfPortList<'a>>>,
Symbol<'a>,
Vec<BlockItemDeclaration<'a>>,
Vec<FunctionStatementOrNull<'a>>,
Option<Identifier<'a>>,
Vec<StatementOrNull<'a>>,
Option<(Symbol<'a>, TaskIdentifier<'a>)>,
),
}
#[derive(Debug, Node)]
pub enum InterfaceIdentifierOrClassScope<'a> {
InterfaceIdentifier(InterfaceIdentifier<'a>),
InterfaceIdentifier((InterfaceIdentifier<'a>, Symbol<'a>)),
ClassScope(ClassScope<'a>),
}
#[derive(Debug, Node)]
pub enum TfItemDeclaration<'a> {
Block(BlockItemDeclaration<'a>),
Port(TfPortDeclaration<'a>),
BlockItemDeclaration(BlockItemDeclaration<'a>),
TfPortDeclaration(TfPortDeclaration<'a>),
}
#[derive(Debug, Node)]
pub struct TfPortList<'a> {
pub nodes: (Vec<TfPortItem<'a>>,),
pub nodes: (List<Symbol<'a>, TfPortItem<'a>>,),
}
#[derive(Debug, Node)]
@ -66,9 +69,9 @@ pub struct TfPortItem<'a> {
Option<Var<'a>>,
DataTypeOrImplicit<'a>,
Option<(
Identifier<'a>,
PortIdentifier<'a>,
Vec<VariableDimension<'a>>,
Option<Expression<'a>>,
Option<(Symbol<'a>, Expression<'a>)>,
)>,
),
}
@ -76,7 +79,7 @@ pub struct TfPortItem<'a> {
#[derive(Debug, Node)]
pub enum TfPortDirection<'a> {
PortDirection(PortDirection<'a>),
ConstRef(Symbol<'a>),
ConstRef((Symbol<'a>, Symbol<'a>)),
}
#[derive(Debug, Node)]
@ -87,12 +90,17 @@ pub struct TfPortDeclaration<'a> {
Option<Var<'a>>,
DataTypeOrImplicit<'a>,
ListOfTfVariableIdentifiers<'a>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct TaskPrototype<'a> {
pub nodes: (Identifier<'a>, Option<TfPortList<'a>>),
pub nodes: (
Symbol<'a>,
TaskIdentifier<'a>,
Option<Paren<'a, Option<TfPortList<'a>>>>,
),
}
// -----------------------------------------------------------------------------

View File

@ -1,2 +1,8 @@
pub mod primitive_gate_and_switch_types;
pub mod primitive_instantiation_and_instances;
pub mod primitive_strengths;
pub mod primitive_terminals;
pub use primitive_gate_and_switch_types::*;
pub use primitive_instantiation_and_instances::*;
pub use primitive_strengths::*;
pub use primitive_terminals::*;

View File

@ -0,0 +1,160 @@
use crate::ast::*;
use crate::parser::*;
use nom::branch::*;
use nom::IResult;
// -----------------------------------------------------------------------------
#[derive(Debug, Node)]
pub struct CmosSwitchtype<'a> {
pub nodes: (Symbol<'a>,),
}
#[derive(Debug, Node)]
pub struct EnableGatetype<'a> {
pub nodes: (Symbol<'a>,),
}
#[derive(Debug, Node)]
pub struct MosSwitchtype<'a> {
pub nodes: (Symbol<'a>,),
}
#[derive(Debug, Node)]
pub struct NInputGatetype<'a> {
pub nodes: (Symbol<'a>,),
}
#[derive(Debug, Node)]
pub struct NOutputGatetype<'a> {
pub nodes: (Symbol<'a>,),
}
#[derive(Debug, Node)]
pub struct PassEnSwitchtype<'a> {
pub nodes: (Symbol<'a>,),
}
#[derive(Debug, Node)]
pub struct PassSwitchtype<'a> {
pub nodes: (Symbol<'a>,),
}
// -----------------------------------------------------------------------------
pub fn cmos_switchtype(s: Span) -> IResult<Span, CmosSwitchtype> {
let (s, a) = alt((symbol("cmos"), symbol("rcmos")))(s)?;
Ok((s, CmosSwitchtype { nodes: (a,) }))
}
pub fn enable_gatetype(s: Span) -> IResult<Span, EnableGatetype> {
let (s, a) = alt((
symbol("bufif0"),
symbol("bufif1"),
symbol("notif0"),
symbol("notif1"),
))(s)?;
Ok((s, EnableGatetype { nodes: (a,) }))
}
pub fn mos_switchtype(s: Span) -> IResult<Span, MosSwitchtype> {
let (s, a) = alt((
symbol("nmos"),
symbol("pmos"),
symbol("rnmos"),
symbol("rpmos"),
))(s)?;
Ok((s, MosSwitchtype { nodes: (a,) }))
}
pub fn n_input_gatetype(s: Span) -> IResult<Span, NInputGatetype> {
let (s, a) = alt((
symbol("and"),
symbol("nand"),
symbol("or"),
symbol("nor"),
symbol("xor"),
symbol("xnor"),
))(s)?;
Ok((s, NInputGatetype { nodes: (a,) }))
}
pub fn n_output_gatetype(s: Span) -> IResult<Span, NOutputGatetype> {
let (s, a) = alt((symbol("buf"), symbol("not")))(s)?;
Ok((s, NOutputGatetype { nodes: (a,) }))
}
pub fn pass_en_switchtype(s: Span) -> IResult<Span, PassEnSwitchtype> {
let (s, a) = alt((
symbol("tranif0"),
symbol("tranif1"),
symbol("rtranif0"),
symbol("rtranif1"),
))(s)?;
Ok((s, PassEnSwitchtype { nodes: (a,) }))
}
pub fn pass_switchtype(s: Span) -> IResult<Span, PassSwitchtype> {
let (s, a) = alt((symbol("tran"), symbol("rtran")))(s)?;
Ok((s, PassSwitchtype { nodes: (a,) }))
}
// -----------------------------------------------------------------------------
#[cfg(test)]
mod tests {
use super::*;
use nom::combinator::*;
#[test]
fn test_cmos_switchtype() {
parser_test!(cmos_switchtype, "cmos", Ok((_, _)));
parser_test!(cmos_switchtype, "rcmos", Ok((_, _)));
}
#[test]
fn test_enable_gatetype() {
parser_test!(enable_gatetype, "bufif0", Ok((_, _)));
parser_test!(enable_gatetype, "bufif1", Ok((_, _)));
parser_test!(enable_gatetype, "notif0", Ok((_, _)));
parser_test!(enable_gatetype, "notif1", Ok((_, _)));
}
#[test]
fn test_mos_switchtype() {
parser_test!(mos_switchtype, "nmos", Ok((_, _)));
parser_test!(mos_switchtype, "pmos", Ok((_, _)));
parser_test!(mos_switchtype, "rnmos", Ok((_, _)));
parser_test!(mos_switchtype, "rpmos", Ok((_, _)));
}
#[test]
fn test_n_input_gatetype() {
parser_test!(n_input_gatetype, "and", Ok((_, _)));
parser_test!(n_input_gatetype, "nand", Ok((_, _)));
parser_test!(n_input_gatetype, "or", Ok((_, _)));
parser_test!(n_input_gatetype, "nor", Ok((_, _)));
parser_test!(n_input_gatetype, "xor", Ok((_, _)));
parser_test!(n_input_gatetype, "xnor", Ok((_, _)));
}
#[test]
fn test_n_output_gatetype() {
parser_test!(n_output_gatetype, "buf", Ok((_, _)));
parser_test!(n_output_gatetype, "not", Ok((_, _)));
}
#[test]
fn test_pass_en_switchtype() {
parser_test!(pass_en_switchtype, "tranif0", Ok((_, _)));
parser_test!(pass_en_switchtype, "tranif1", Ok((_, _)));
parser_test!(pass_en_switchtype, "rtranif0", Ok((_, _)));
parser_test!(pass_en_switchtype, "rtranif1", Ok((_, _)));
}
#[test]
fn test_pass_switchtype() {
parser_test!(pass_switchtype, "tran", Ok((_, _)));
parser_test!(pass_switchtype, "rtran", Ok((_, _)));
}
}

View File

@ -1,19 +1,441 @@
use crate::ast::*;
use crate::parser::*;
//use nom::branch::*;
//use nom::combinator::*;
use nom::error::*;
use nom::{Err, IResult};
use nom::branch::*;
use nom::combinator::*;
use nom::sequence::*;
use nom::IResult;
// -----------------------------------------------------------------------------
#[derive(Debug, Node)]
pub struct GateInstantiation<'a> {
pub nodes: (Identifier<'a>,),
pub enum GateInstantiation<'a> {
Cmos(GateInstantiationCmos<'a>),
Enable(GateInstantiationEnable<'a>),
Mos(GateInstantiationMos<'a>),
NInput(GateInstantiationNInput<'a>),
NOutput(GateInstantiationNOutput<'a>),
PassEn(GateInstantiationPassEn<'a>),
Pass(GateInstantiationPass<'a>),
Pulldown(GateInstantiationPulldown<'a>),
Pullup(GateInstantiationPullup<'a>),
}
#[derive(Debug, Node)]
pub struct GateInstantiationCmos<'a> {
pub nodes: (
CmosSwitchtype<'a>,
Option<Delay3<'a>>,
List<Symbol<'a>, CmosSwitchInstance<'a>>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct GateInstantiationEnable<'a> {
pub nodes: (
EnableGatetype<'a>,
Option<DriveStrength<'a>>,
Option<Delay3<'a>>,
List<Symbol<'a>, EnableGateInstance<'a>>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct GateInstantiationMos<'a> {
pub nodes: (
MosSwitchtype<'a>,
Option<Delay3<'a>>,
List<Symbol<'a>, MosSwitchInstance<'a>>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct GateInstantiationNInput<'a> {
pub nodes: (
NInputGatetype<'a>,
Option<DriveStrength<'a>>,
Option<Delay2<'a>>,
List<Symbol<'a>, NInputGateInstance<'a>>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct GateInstantiationNOutput<'a> {
pub nodes: (
NOutputGatetype<'a>,
Option<DriveStrength<'a>>,
Option<Delay2<'a>>,
List<Symbol<'a>, NOutputGateInstance<'a>>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct GateInstantiationPassEn<'a> {
pub nodes: (
PassEnSwitchtype<'a>,
Option<Delay2<'a>>,
List<Symbol<'a>, PassEnableSwitchInstance<'a>>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct GateInstantiationPass<'a> {
pub nodes: (
PassSwitchtype<'a>,
List<Symbol<'a>, PassSwitchInstance<'a>>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct GateInstantiationPulldown<'a> {
pub nodes: (
Symbol<'a>,
Option<PulldownStrength<'a>>,
List<Symbol<'a>, PullGateInstance<'a>>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct GateInstantiationPullup<'a> {
pub nodes: (
Symbol<'a>,
Option<PullupStrength<'a>>,
List<Symbol<'a>, PullGateInstance<'a>>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
pub struct CmosSwitchInstance<'a> {
pub nodes: (
Option<NameOfInstance<'a>>,
Paren<
'a,
(
OutputTerminal<'a>,
Symbol<'a>,
InputTerminal<'a>,
Symbol<'a>,
NcontrolTerminal<'a>,
Symbol<'a>,
PcontrolTerminal<'a>,
),
>,
),
}
#[derive(Debug, Node)]
pub struct EnableGateInstance<'a> {
pub nodes: (
Option<NameOfInstance<'a>>,
Paren<
'a,
(
OutputTerminal<'a>,
Symbol<'a>,
InputTerminal<'a>,
Symbol<'a>,
EnableTerminal<'a>,
),
>,
),
}
#[derive(Debug, Node)]
pub struct MosSwitchInstance<'a> {
pub nodes: (
Option<NameOfInstance<'a>>,
Paren<
'a,
(
OutputTerminal<'a>,
Symbol<'a>,
InputTerminal<'a>,
Symbol<'a>,
EnableTerminal<'a>,
),
>,
),
}
#[derive(Debug, Node)]
pub struct NInputGateInstance<'a> {
pub nodes: (
Option<NameOfInstance<'a>>,
Paren<
'a,
(
OutputTerminal<'a>,
Symbol<'a>,
List<Symbol<'a>, InputTerminal<'a>>,
),
>,
),
}
#[derive(Debug, Node)]
pub struct NOutputGateInstance<'a> {
pub nodes: (
Option<NameOfInstance<'a>>,
Paren<
'a,
(
List<Symbol<'a>, OutputTerminal<'a>>,
Symbol<'a>,
InputTerminal<'a>,
),
>,
),
}
#[derive(Debug, Node)]
pub struct PassSwitchInstance<'a> {
pub nodes: (
Option<NameOfInstance<'a>>,
Paren<'a, (InoutTerminal<'a>, Symbol<'a>, InoutTerminal<'a>)>,
),
}
#[derive(Debug, Node)]
pub struct PassEnableSwitchInstance<'a> {
pub nodes: (
Option<NameOfInstance<'a>>,
Paren<
'a,
(
InoutTerminal<'a>,
Symbol<'a>,
InoutTerminal<'a>,
Symbol<'a>,
EnableTerminal<'a>,
),
>,
),
}
#[derive(Debug, Node)]
pub struct PullGateInstance<'a> {
pub nodes: (Option<NameOfInstance<'a>>, Paren<'a, OutputTerminal<'a>>),
}
// -----------------------------------------------------------------------------
pub fn gate_instantiation(s: Span) -> IResult<Span, GateInstantiation> {
Err(Err::Error(make_error(s, ErrorKind::Fix)))
alt((
gate_instantiation_cmos,
gate_instantiation_enable,
gate_instantiation_mos,
gate_instantiation_n_input,
gate_instantiation_n_output,
gate_instantiation_pass_en,
gate_instantiation_pass,
gate_instantiation_pulldown,
gate_instantiation_pullup,
))(s)
}
pub fn gate_instantiation_cmos(s: Span) -> IResult<Span, GateInstantiation> {
let (s, a) = cmos_switchtype(s)?;
let (s, b) = opt(delay3)(s)?;
let (s, c) = list(symbol(","), cmos_switch_instance)(s)?;
let (s, d) = symbol(";")(s)?;
Ok((
s,
GateInstantiation::Cmos(GateInstantiationCmos {
nodes: (a, b, c, d),
}),
))
}
pub fn gate_instantiation_enable(s: Span) -> IResult<Span, GateInstantiation> {
let (s, a) = enable_gatetype(s)?;
let (s, b) = opt(drive_strength)(s)?;
let (s, c) = opt(delay3)(s)?;
let (s, d) = list(symbol(","), enable_gate_instance)(s)?;
let (s, e) = symbol(";")(s)?;
Ok((
s,
GateInstantiation::Enable(GateInstantiationEnable {
nodes: (a, b, c, d, e),
}),
))
}
pub fn gate_instantiation_mos(s: Span) -> IResult<Span, GateInstantiation> {
let (s, a) = mos_switchtype(s)?;
let (s, b) = opt(delay3)(s)?;
let (s, c) = list(symbol(","), mos_switch_instance)(s)?;
let (s, d) = symbol(";")(s)?;
Ok((
s,
GateInstantiation::Mos(GateInstantiationMos {
nodes: (a, b, c, d),
}),
))
}
pub fn gate_instantiation_n_input(s: Span) -> IResult<Span, GateInstantiation> {
let (s, a) = n_input_gatetype(s)?;
let (s, b) = opt(drive_strength)(s)?;
let (s, c) = opt(delay2)(s)?;
let (s, d) = list(symbol(","), n_input_gate_instance)(s)?;
let (s, e) = symbol(";")(s)?;
Ok((
s,
GateInstantiation::NInput(GateInstantiationNInput {
nodes: (a, b, c, d, e),
}),
))
}
pub fn gate_instantiation_n_output(s: Span) -> IResult<Span, GateInstantiation> {
let (s, a) = n_output_gatetype(s)?;
let (s, b) = opt(drive_strength)(s)?;
let (s, c) = opt(delay2)(s)?;
let (s, d) = list(symbol(","), n_output_gate_instance)(s)?;
let (s, e) = symbol(";")(s)?;
Ok((
s,
GateInstantiation::NOutput(GateInstantiationNOutput {
nodes: (a, b, c, d, e),
}),
))
}
pub fn gate_instantiation_pass_en(s: Span) -> IResult<Span, GateInstantiation> {
let (s, a) = pass_en_switchtype(s)?;
let (s, b) = opt(delay2)(s)?;
let (s, c) = list(symbol(","), pass_enable_switch_instance)(s)?;
let (s, d) = symbol(";")(s)?;
Ok((
s,
GateInstantiation::PassEn(GateInstantiationPassEn {
nodes: (a, b, c, d),
}),
))
}
pub fn gate_instantiation_pass(s: Span) -> IResult<Span, GateInstantiation> {
let (s, a) = pass_switchtype(s)?;
let (s, b) = list(symbol(","), pass_switch_instance)(s)?;
let (s, c) = symbol(";")(s)?;
Ok((
s,
GateInstantiation::Pass(GateInstantiationPass { nodes: (a, b, c) }),
))
}
pub fn gate_instantiation_pulldown(s: Span) -> IResult<Span, GateInstantiation> {
let (s, a) = symbol("pulldown")(s)?;
let (s, b) = opt(pulldown_strength)(s)?;
let (s, c) = list(symbol(","), pull_gate_instance)(s)?;
let (s, d) = symbol(";")(s)?;
Ok((
s,
GateInstantiation::Pulldown(GateInstantiationPulldown {
nodes: (a, b, c, d),
}),
))
}
pub fn gate_instantiation_pullup(s: Span) -> IResult<Span, GateInstantiation> {
let (s, a) = symbol("pullup")(s)?;
let (s, b) = opt(pullup_strength)(s)?;
let (s, c) = list(symbol(","), pull_gate_instance)(s)?;
let (s, d) = symbol(";")(s)?;
Ok((
s,
GateInstantiation::Pullup(GateInstantiationPullup {
nodes: (a, b, c, d),
}),
))
}
pub fn cmos_switch_instance(s: Span) -> IResult<Span, CmosSwitchInstance> {
let (s, a) = opt(name_of_instance)(s)?;
let (s, b) = paren(tuple((
output_terminal,
symbol(","),
input_terminal,
symbol(","),
ncontrol_terminal,
symbol(","),
pcontrol_terminal,
)))(s)?;
Ok((s, CmosSwitchInstance { nodes: (a, b) }))
}
pub fn enable_gate_instance(s: Span) -> IResult<Span, EnableGateInstance> {
let (s, a) = opt(name_of_instance)(s)?;
let (s, b) = paren(tuple((
output_terminal,
symbol(","),
input_terminal,
symbol(","),
enable_terminal,
)))(s)?;
Ok((s, EnableGateInstance { nodes: (a, b) }))
}
pub fn mos_switch_instance(s: Span) -> IResult<Span, MosSwitchInstance> {
let (s, a) = opt(name_of_instance)(s)?;
let (s, b) = paren(tuple((
output_terminal,
symbol(","),
input_terminal,
symbol(","),
enable_terminal,
)))(s)?;
Ok((s, MosSwitchInstance { nodes: (a, b) }))
}
pub fn n_input_gate_instance(s: Span) -> IResult<Span, NInputGateInstance> {
let (s, a) = opt(name_of_instance)(s)?;
let (s, b) = paren(tuple((
output_terminal,
symbol(","),
list(symbol(","), input_terminal),
)))(s)?;
Ok((s, NInputGateInstance { nodes: (a, b) }))
}
pub fn n_output_gate_instance(s: Span) -> IResult<Span, NOutputGateInstance> {
let (s, a) = opt(name_of_instance)(s)?;
let (s, b) = paren(tuple((
list(symbol(","), output_terminal),
symbol(","),
input_terminal,
)))(s)?;
Ok((s, NOutputGateInstance { nodes: (a, b) }))
}
pub fn pass_switch_instance(s: Span) -> IResult<Span, PassSwitchInstance> {
let (s, a) = opt(name_of_instance)(s)?;
let (s, b) = paren(tuple((inout_terminal, symbol(","), inout_terminal)))(s)?;
Ok((s, PassSwitchInstance { nodes: (a, b) }))
}
pub fn pass_enable_switch_instance(s: Span) -> IResult<Span, PassEnableSwitchInstance> {
let (s, a) = opt(name_of_instance)(s)?;
let (s, b) = paren(tuple((
inout_terminal,
symbol(","),
inout_terminal,
symbol(","),
enable_terminal,
)))(s)?;
Ok((s, PassEnableSwitchInstance { nodes: (a, b) }))
}
pub fn pull_gate_instance(s: Span) -> IResult<Span, PullGateInstance> {
let (s, a) = opt(name_of_instance)(s)?;
let (s, b) = paren(output_terminal)(s)?;
Ok((s, PullGateInstance { nodes: (a, b) }))
}

View File

@ -0,0 +1,130 @@
use crate::ast::*;
use crate::parser::*;
use nom::branch::*;
use nom::IResult;
// -----------------------------------------------------------------------------
#[derive(Debug, Node)]
pub enum PulldownStrength<'a> {
Strength01(PulldownStrength01<'a>),
Strength10(PulldownStrength10<'a>),
Strength0(PulldownStrength0<'a>),
}
#[derive(Debug, Node)]
pub struct PulldownStrength01<'a> {
pub nodes: (Paren<'a, (Strength0<'a>, Symbol<'a>, Strength1<'a>)>,),
}
#[derive(Debug, Node)]
pub struct PulldownStrength10<'a> {
pub nodes: (Paren<'a, (Strength1<'a>, Symbol<'a>, Strength0<'a>)>,),
}
#[derive(Debug, Node)]
pub struct PulldownStrength0<'a> {
pub nodes: (Paren<'a, Strength0<'a>>,),
}
#[derive(Debug, Node)]
pub enum PullupStrength<'a> {
Strength01(PullupStrength01<'a>),
Strength10(PullupStrength10<'a>),
Strength1(PullupStrength1<'a>),
}
#[derive(Debug, Node)]
pub struct PullupStrength01<'a> {
pub nodes: (Paren<'a, (Strength0<'a>, Symbol<'a>, Strength1<'a>)>,),
}
#[derive(Debug, Node)]
pub struct PullupStrength10<'a> {
pub nodes: (Paren<'a, (Strength1<'a>, Symbol<'a>, Strength0<'a>)>,),
}
#[derive(Debug, Node)]
pub struct PullupStrength1<'a> {
pub nodes: (Paren<'a, Strength1<'a>>,),
}
// -----------------------------------------------------------------------------
pub fn pulldown_strength(s: Span) -> IResult<Span, PulldownStrength> {
alt((pulldown_strength01, pulldown_strength10, pulldown_strength0))(s)
}
pub fn pulldown_strength01(s: Span) -> IResult<Span, PulldownStrength> {
let (s, a) = paren(triple(strength0, symbol(","), strength1))(s)?;
Ok((
s,
PulldownStrength::Strength01(PulldownStrength01 { nodes: (a,) }),
))
}
pub fn pulldown_strength10(s: Span) -> IResult<Span, PulldownStrength> {
let (s, a) = paren(triple(strength1, symbol(","), strength0))(s)?;
Ok((
s,
PulldownStrength::Strength10(PulldownStrength10 { nodes: (a,) }),
))
}
pub fn pulldown_strength0(s: Span) -> IResult<Span, PulldownStrength> {
let (s, a) = paren(strength0)(s)?;
Ok((
s,
PulldownStrength::Strength0(PulldownStrength0 { nodes: (a,) }),
))
}
pub fn pullup_strength(s: Span) -> IResult<Span, PullupStrength> {
alt((pullup_strength01, pullup_strength10, pullup_strength1))(s)
}
pub fn pullup_strength01(s: Span) -> IResult<Span, PullupStrength> {
let (s, a) = paren(triple(strength0, symbol(","), strength1))(s)?;
Ok((
s,
PullupStrength::Strength01(PullupStrength01 { nodes: (a,) }),
))
}
pub fn pullup_strength10(s: Span) -> IResult<Span, PullupStrength> {
let (s, a) = paren(triple(strength1, symbol(","), strength0))(s)?;
Ok((
s,
PullupStrength::Strength10(PullupStrength10 { nodes: (a,) }),
))
}
pub fn pullup_strength1(s: Span) -> IResult<Span, PullupStrength> {
let (s, a) = paren(strength1)(s)?;
Ok((
s,
PullupStrength::Strength1(PullupStrength1 { nodes: (a,) }),
))
}
// -----------------------------------------------------------------------------
#[cfg(test)]
mod tests {
use super::*;
use nom::combinator::*;
#[test]
fn test_pulldown_strength() {
parser_test!(pulldown_strength, "(supply0, strong1)", Ok((_, _)));
parser_test!(pulldown_strength, "(pull1, weak0)", Ok((_, _)));
parser_test!(pulldown_strength, "(pull0)", Ok((_, _)));
}
#[test]
fn test_pullup_strength() {
parser_test!(pullup_strength, "(supply0, strong1)", Ok((_, _)));
parser_test!(pullup_strength, "(pull1, weak0)", Ok((_, _)));
parser_test!(pullup_strength, "(supply1)", Ok((_, _)));
}
}

View File

@ -0,0 +1,69 @@
use crate::ast::*;
use crate::parser::*;
use nom::IResult;
// -----------------------------------------------------------------------------
#[derive(Debug, Node)]
pub struct EnableTerminal<'a> {
pub nodes: (Expression<'a>,),
}
#[derive(Debug, Node)]
pub struct InoutTerminal<'a> {
pub nodes: (NetLvalue<'a>,),
}
#[derive(Debug, Node)]
pub struct InputTerminal<'a> {
pub nodes: (Expression<'a>,),
}
#[derive(Debug, Node)]
pub struct NcontrolTerminal<'a> {
pub nodes: (Expression<'a>,),
}
#[derive(Debug, Node)]
pub struct OutputTerminal<'a> {
pub nodes: (NetLvalue<'a>,),
}
#[derive(Debug, Node)]
pub struct PcontrolTerminal<'a> {
pub nodes: (Expression<'a>,),
}
// -----------------------------------------------------------------------------
pub fn enable_terminal(s: Span) -> IResult<Span, EnableTerminal> {
let (s, a) = expression(s)?;
Ok((s, EnableTerminal { nodes: (a,) }))
}
pub fn inout_terminal(s: Span) -> IResult<Span, InoutTerminal> {
let (s, a) = net_lvalue(s)?;
Ok((s, InoutTerminal { nodes: (a,) }))
}
pub fn input_terminal(s: Span) -> IResult<Span, InputTerminal> {
let (s, a) = expression(s)?;
Ok((s, InputTerminal { nodes: (a,) }))
}
pub fn ncontrol_terminal(s: Span) -> IResult<Span, NcontrolTerminal> {
let (s, a) = expression(s)?;
Ok((s, NcontrolTerminal { nodes: (a,) }))
}
pub fn output_terminal(s: Span) -> IResult<Span, OutputTerminal> {
let (s, a) = net_lvalue(s)?;
Ok((s, OutputTerminal { nodes: (a,) }))
}
pub fn pcontrol_terminal(s: Span) -> IResult<Span, PcontrolTerminal> {
let (s, a) = expression(s)?;
Ok((s, PcontrolTerminal { nodes: (a,) }))
}
// -----------------------------------------------------------------------------

View File

@ -1,9 +1,10 @@
use crate::ast::*;
use crate::parser::*;
//use nom::branch::*;
//use nom::combinator::*;
use nom::error::*;
use nom::{Err, IResult};
use nom::branch::*;
use nom::combinator::*;
use nom::multi::*;
use nom::sequence::*;
use nom::IResult;
// -----------------------------------------------------------------------------
@ -26,8 +27,8 @@ pub enum PackageOrGenerateItemDeclaration<'a> {
ExternConstraintDeclaration(ExternConstraintDeclaration<'a>),
ClassDeclaration(ClassDeclaration<'a>),
ClassConstructorDeclaration(ClassConstructorDeclaration<'a>),
LocalParameterDeclaration(LocalParameterDeclaration<'a>),
ParameterDeclaration(ParameterDeclaration<'a>),
LocalParameterDeclaration((LocalParameterDeclaration<'a>, Symbol<'a>)),
ParameterDeclaration((ParameterDeclaration<'a>, Symbol<'a>)),
CovergroupDeclaration(CovergroupDeclaration<'a>),
AssertionItemDeclaration(AssertionItemDeclaration<'a>),
Empty(Symbol<'a>),
@ -35,7 +36,12 @@ pub enum PackageOrGenerateItemDeclaration<'a> {
#[derive(Debug, Node)]
pub struct AnonymousProgram<'a> {
pub nodes: (Vec<AnonymousProgramItem<'a>>,),
pub nodes: (
Symbol<'a>,
Symbol<'a>,
Vec<AnonymousProgramItem<'a>>,
Symbol<'a>,
),
}
#[derive(Debug, Node)]
@ -51,19 +57,97 @@ pub enum AnonymousProgramItem<'a> {
// -----------------------------------------------------------------------------
pub fn package_item(s: Span) -> IResult<Span, PackageItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix)))
alt((
map(package_or_generate_item_declaration, |x| {
PackageItem::PackageOrGenerateItemDeclaration(x)
}),
map(anonymous_program, |x| PackageItem::AnonymousProgram(x)),
map(package_export_declaration, |x| {
PackageItem::PackageExportDeclaration(x)
}),
map(timeunits_declaration, |x| {
PackageItem::TimeunitsDeclaration(x)
}),
))(s)
}
pub fn package_or_generate_item_declaration(
s: Span,
) -> IResult<Span, PackageOrGenerateItemDeclaration> {
Err(Err::Error(make_error(s, ErrorKind::Fix)))
alt((
map(net_declaration, |x| {
PackageOrGenerateItemDeclaration::NetDeclaration(x)
}),
map(data_declaration, |x| {
PackageOrGenerateItemDeclaration::DataDeclaration(x)
}),
map(task_declaration, |x| {
PackageOrGenerateItemDeclaration::TaskDeclaration(x)
}),
map(function_declaration, |x| {
PackageOrGenerateItemDeclaration::FunctionDeclaration(x)
}),
map(checker_declaration, |x| {
PackageOrGenerateItemDeclaration::CheckerDeclaration(x)
}),
map(dpi_import_export, |x| {
PackageOrGenerateItemDeclaration::DpiImportExport(x)
}),
map(extern_constraint_declaration, |x| {
PackageOrGenerateItemDeclaration::ExternConstraintDeclaration(x)
}),
map(class_declaration, |x| {
PackageOrGenerateItemDeclaration::ClassDeclaration(x)
}),
map(class_constructor_declaration, |x| {
PackageOrGenerateItemDeclaration::ClassConstructorDeclaration(x)
}),
map(pair(local_parameter_declaration, symbol(";")), |x| {
PackageOrGenerateItemDeclaration::LocalParameterDeclaration(x)
}),
map(pair(parameter_declaration, symbol(";")), |x| {
PackageOrGenerateItemDeclaration::ParameterDeclaration(x)
}),
map(covergroup_declaration, |x| {
PackageOrGenerateItemDeclaration::CovergroupDeclaration(x)
}),
map(assertion_item_declaration, |x| {
PackageOrGenerateItemDeclaration::AssertionItemDeclaration(x)
}),
map(symbol(";"), |x| PackageOrGenerateItemDeclaration::Empty(x)),
))(s)
}
pub fn anonymous_program(s: Span) -> IResult<Span, AnonymousProgram> {
Err(Err::Error(make_error(s, ErrorKind::Fix)))
let (s, a) = symbol("program")(s)?;
let (s, b) = symbol(";")(s)?;
let (s, c) = many0(anonymous_program_item)(s)?;
let (s, d) = symbol("endprogram")(s)?;
Ok((
s,
AnonymousProgram {
nodes: (a, b, c, d),
},
))
}
pub fn anonymous_program_item(s: Span) -> IResult<Span, AnonymousProgramItem> {
Err(Err::Error(make_error(s, ErrorKind::Fix)))
alt((
map(task_declaration, |x| {
AnonymousProgramItem::TaskDeclaration(x)
}),
map(function_declaration, |x| {
AnonymousProgramItem::FunctionDeclaration(x)
}),
map(class_declaration, |x| {
AnonymousProgramItem::ClassDeclaration(x)
}),
map(covergroup_declaration, |x| {
AnonymousProgramItem::CovergroupDeclaration(x)
}),
map(class_constructor_declaration, |x| {
AnonymousProgramItem::ClassConstructorDeclaration(x)
}),
map(symbol(";"), |x| AnonymousProgramItem::Empty(x)),
))(s)
}