Add test and Fix bug

This commit is contained in:
dalance 2019-08-02 14:14:49 +09:00
parent daa711e81e
commit 46a5caadac
10 changed files with 3399 additions and 1810 deletions

View File

@ -79,22 +79,22 @@ A parser library for System Verilog.
# Test Status
| Clause | Test | Clause | Test | Clause | Test | Clause | Test |
| ------ | ---- | ------ | ---- | ------ | ---- | ------ | ---- |
| 3 | x | 13 | | 23 | | 33 | |
| 4 | x | 14 | | 24 | | 34 | |
| 5 | x | 15 | | 25 | | 35 | |
| 6 | | 16 | | 26 | | 36 | |
| 7 | | 17 | | 27 | | 37 | |
| 8 | | 18 | | 28 | | 38 | |
| 9 | | 19 | | 29 | | 39 | |
| 10 | | 20 | | 30 | | 40 | |
| 11 | | 21 | | 31 | | | |
| 12 | | 22 | | 32 | | | |
| Clause | Exist | Pass | Clause | Exist | Pass | Clause | Exist | Pass | Clause | Exist | Pass |
| ------ | ----- | ---- | ------ | ----- | ---- | ------ | ----- | ---- | ------ | ----- | ---- |
| 3 | x | x | 13 | | | 23 | | | 33 | | |
| 4 | x | x | 14 | | | 24 | | | 34 | | |
| 5 | x | x | 15 | | | 25 | | | 35 | | |
| 6 | x | | 16 | | | 26 | | | 36 | | |
| 7 | x | | 17 | | | 27 | | | 37 | | |
| 8 | x | | 18 | | | 28 | | | 38 | | |
| 9 | | | 19 | | | 29 | | | 39 | | |
| 10 | | | 20 | | | 30 | | | 40 | | |
| 11 | | | 21 | | | 31 | | | | | |
| 12 | | | 22 | | | 32 | | | | | |
## Missing entry of specification
* interface_class_declaration -> connect to description
* interface_class_declaration -> connect to description/package_or_generate_item_declaration/anonymous_program_item
* formal_identifier -> ignore
* covergroup_variable_identifier -> ignore
* array_identifier -> ignore

View File

@ -285,6 +285,10 @@ pub(crate) fn property_spec(s: Span) -> IResult<Span, PropertySpec> {
pub(crate) fn property_expr(s: Span) -> IResult<Span, PropertyExpr> {
alt((
alt((
property_expr_implication_overlapped,
property_expr_implication_nonoverlapped,
property_expr_followed_by_overlapped,
property_expr_followed_by_nonoverlapped,
map(sequence_expr, |x| PropertyExpr::SequenceExpr(Box::new(x))),
property_expr_strong,
property_expr_weak,
@ -292,12 +296,8 @@ pub(crate) fn property_expr(s: Span) -> IResult<Span, PropertyExpr> {
property_expr_not,
property_expr_or,
property_expr_and,
property_expr_implication_overlapped,
property_expr_implication_nonoverlapped,
property_expr_if,
property_expr_case,
property_expr_followed_by_overlapped,
property_expr_followed_by_nonoverlapped,
property_expr_nexttime,
property_expr_s_nexttime,
)),
@ -1151,12 +1151,12 @@ pub(crate) fn goto_repetition(s: Span) -> IResult<Span, GotoRepetition> {
#[tracable_parser]
pub(crate) fn const_or_range_expression(s: Span) -> IResult<Span, ConstOrRangeExpression> {
alt((
map(constant_expression, |x| {
ConstOrRangeExpression::ConstantExpression(Box::new(x))
}),
map(cycle_delay_const_range_expression, |x| {
ConstOrRangeExpression::CycleDelayConstRangeExpression(Box::new(x))
}),
map(constant_expression, |x| {
ConstOrRangeExpression::ConstantExpression(Box::new(x))
}),
))(s)
}

View File

@ -122,9 +122,9 @@ pub(crate) fn limit_value(s: Span) -> IResult<Span, LimitValue> {
#[tracable_parser]
pub(crate) fn variable_decl_assignment(s: Span) -> IResult<Span, VariableDeclAssignment> {
alt((
variable_decl_assignment_variable,
variable_decl_assignment_dynamic_array,
variable_decl_assignment_class,
variable_decl_assignment_variable,
))(s)
}
@ -160,7 +160,7 @@ pub(crate) fn variable_decl_assignment_dynamic_array(
#[tracable_parser]
pub(crate) 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)?;
let (s, b) = pair(symbol("="), class_new)(s)?;
Ok((
s,
VariableDeclAssignment::Class(Box::new(VariableDeclAssignmentClass { nodes: (a, b) })),
@ -169,7 +169,7 @@ pub(crate) fn variable_decl_assignment_class(s: Span) -> IResult<Span, VariableD
#[tracable_parser]
pub(crate) fn class_new(s: Span) -> IResult<Span, ClassNew> {
alt((class_new_argument, class_new_expression))(s)
alt((class_new_expression, class_new_argument))(s)
}
#[tracable_parser]

View File

@ -73,7 +73,13 @@ pub(crate) fn list_of_tf_variable_identifiers(
#[tracable_parser]
pub(crate) fn list_of_type_assignments(s: Span) -> IResult<Span, ListOfTypeAssignments> {
let (s, a) = list(symbol(","), type_assignment)(s)?;
let (s, a) = list(
symbol(","),
terminated(
type_assignment,
peek(alt((symbol(","), symbol(")"), symbol(";")))),
),
)(s)?;
Ok((s, ListOfTypeAssignments { nodes: (a,) }))
}

View File

@ -2,6 +2,7 @@ use crate::*;
// -----------------------------------------------------------------------------
#[recursive_parser]
#[packrat_parser]
#[tracable_parser]
pub(crate) fn casting_type(s: Span) -> IResult<Span, CastingType> {

View File

@ -62,11 +62,11 @@ pub(crate) fn system_tf_call_arg_expression(s: Span) -> IResult<Span, SystemTfCa
#[tracable_parser]
pub(crate) fn subroutine_call(s: Span) -> IResult<Span, SubroutineCall> {
alt((
map(method_call, |x| SubroutineCall::MethodCall(Box::new(x))),
map(tf_call, |x| SubroutineCall::TfCall(Box::new(x))),
map(system_tf_call, |x| {
SubroutineCall::SystemTfCall(Box::new(x))
}),
map(method_call, |x| SubroutineCall::MethodCall(Box::new(x))),
subroutine_call_randomize,
))(s)
}

View File

@ -49,6 +49,9 @@ pub(crate) fn package_or_generate_item_declaration(
map(class_declaration, |x| {
PackageOrGenerateItemDeclaration::ClassDeclaration(Box::new(x))
}),
map(interface_class_declaration, |x| {
PackageOrGenerateItemDeclaration::InterfaceClassDeclaration(Box::new(x))
}),
map(class_constructor_declaration, |x| {
PackageOrGenerateItemDeclaration::ClassConstructorDeclaration(Box::new(x))
}),
@ -96,6 +99,9 @@ pub(crate) fn anonymous_program_item(s: Span) -> IResult<Span, AnonymousProgramI
map(class_declaration, |x| {
AnonymousProgramItem::ClassDeclaration(Box::new(x))
}),
map(interface_class_declaration, |x| {
AnonymousProgramItem::InterfaceClassDeclaration(Box::new(x))
}),
map(covergroup_declaration, |x| {
AnonymousProgramItem::CovergroupDeclaration(Box::new(x))
}),

File diff suppressed because it is too large Load Diff

View File

@ -115,7 +115,7 @@ pub struct VariableDeclAssignmentDynamicArray {
#[derive(Clone, Debug, Node)]
pub struct VariableDeclAssignmentClass {
pub nodes: (ClassVariableIdentifier, Option<(Symbol, ClassNew)>),
pub nodes: (ClassVariableIdentifier, (Symbol, ClassNew)),
}
#[derive(Clone, Debug, Node)]

View File

@ -20,6 +20,7 @@ pub enum PackageOrGenerateItemDeclaration {
DpiImportExport(Box<DpiImportExport>),
ExternConstraintDeclaration(Box<ExternConstraintDeclaration>),
ClassDeclaration(Box<ClassDeclaration>),
InterfaceClassDeclaration(Box<InterfaceClassDeclaration>),
ClassConstructorDeclaration(Box<ClassConstructorDeclaration>),
LocalParameterDeclaration(Box<(LocalParameterDeclaration, Symbol)>),
ParameterDeclaration(Box<(ParameterDeclaration, Symbol)>),
@ -38,6 +39,7 @@ pub enum AnonymousProgramItem {
TaskDeclaration(Box<TaskDeclaration>),
FunctionDeclaration(Box<FunctionDeclaration>),
ClassDeclaration(Box<ClassDeclaration>),
InterfaceClassDeclaration(Box<InterfaceClassDeclaration>),
CovergroupDeclaration(Box<CovergroupDeclaration>),
ClassConstructorDeclaration(Box<ClassConstructorDeclaration>),
Empty(Box<Symbol>),