This commit is contained in:
dalance 2019-08-12 19:40:04 +09:00
parent 377fa5bd42
commit c1efdca522
9 changed files with 530 additions and 410 deletions

View File

@ -82,15 +82,15 @@ A parser library for System Verilog.
| Clause | Exist | Pass | Clause | Exist | Pass | Clause | Exist | Pass | Clause | Exist | Pass | | Clause | Exist | Pass | Clause | Exist | Pass | Clause | Exist | Pass | Clause | Exist | Pass |
| ------ | ----- | ---- | ------ | ----- | ---- | ------ | ----- | ---- | ------ | ----- | ---- | | ------ | ----- | ---- | ------ | ----- | ---- | ------ | ----- | ---- | ------ | ----- | ---- |
| 3 | x | x | 13 | x | | 23 | x | | 33 | x | | | 3 | x | x | 13 | x | | 23 | x | | 33 | x | |
| 4 | x | x | 14 | x | | 24 | x | | 34 | x | | | 4 | x | x | 14 | x | | 24 | x | x | 34 | x | |
| 5 | x | x | 15 | x | | 25 | x | | 35 | | | | 5 | x | x | 15 | x | | 25 | x | | 35 | x | |
| 6 | x | x | 16 | x | | 26 | x | | 36 | | | | 6 | x | x | 16 | x | | 26 | x | | 36 | x | x |
| 7 | x | x | 17 | x | | 27 | x | | 37 | | | | 7 | x | x | 17 | x | | 27 | x | | | | |
| 8 | x | | 18 | x | | 28 | x | | 38 | | | | 8 | x | x | 18 | x | | 28 | x | x | | | |
| 9 | x | | 19 | x | | 29 | x | | 39 | | | | 9 | x | x | 19 | x | | 29 | x | | | | |
| 10 | x | | 20 | x | | 30 | x | | 40 | | | | 10 | x | x | 20 | x | | 30 | x | | | | |
| 11 | x | | 21 | x | | 31 | x | | | | | | 11 | x | | 21 | x | | 31 | x | | | | |
| 12 | x | | 22 | | | 32 | x | | | | | | 12 | x | | 22 | | | 32 | x | x | | | |
## Missing entry of specification ## Missing entry of specification

View File

@ -6,10 +6,10 @@ use crate::*;
#[packrat_parser] #[packrat_parser]
pub(crate) fn action_block(s: Span) -> IResult<Span, ActionBlock> { pub(crate) fn action_block(s: Span) -> IResult<Span, ActionBlock> {
alt(( alt((
action_block_else,
map(statement_or_null, |x| { map(statement_or_null, |x| {
ActionBlock::StatementOrNull(Box::new(x)) ActionBlock::StatementOrNull(Box::new(x))
}), }),
action_block_else,
))(s) ))(s)
} }

View File

@ -26,7 +26,10 @@ pub(crate) fn statement_or_null_attribute(s: Span) -> IResult<Span, StatementOrN
#[tracable_parser] #[tracable_parser]
#[packrat_parser] #[packrat_parser]
pub(crate) fn statement(s: Span) -> IResult<Span, Statement> { pub(crate) fn statement(s: Span) -> IResult<Span, Statement> {
let (s, a) = opt(pair(block_identifier, symbol(":")))(s)?; let (s, a) = opt(pair(
block_identifier,
terminated(symbol(":"), peek(not(symbol(":")))),
))(s)?;
let (s, b) = many0(attribute_instance)(s)?; let (s, b) = many0(attribute_instance)(s)?;
let (s, c) = statement_item(s)?; let (s, c) = statement_item(s)?;
Ok((s, Statement { nodes: (a, b, c) })) Ok((s, Statement { nodes: (a, b, c) }))

View File

@ -223,7 +223,7 @@ pub(crate) fn class_scope(s: Span) -> IResult<Span, ClassScope> {
#[tracable_parser] #[tracable_parser]
#[packrat_parser] #[packrat_parser]
pub(crate) fn class_type_class_scope(s: Span) -> IResult<Span, ClassType> { pub(crate) fn class_type_class_scope(s: Span) -> IResult<Span, ClassType> {
let (s, a) = ps_class_identifier(s)?; let (s, a) = ps_class_identifier_class_type_class_scope(s)?;
let (s, b) = opt(parameter_value_assignment)(s)?; let (s, b) = opt(parameter_value_assignment)(s)?;
let (s, c) = many0(terminated( let (s, c) = many0(terminated(
triple( triple(
@ -236,6 +236,19 @@ pub(crate) fn class_type_class_scope(s: Span) -> IResult<Span, ClassType> {
Ok((s, ClassType { nodes: (a, b, c) })) Ok((s, ClassType { nodes: (a, b, c) }))
} }
#[tracable_parser]
#[packrat_parser]
pub(crate) fn ps_class_identifier_class_type_class_scope(
s: Span,
) -> IResult<Span, PsClassIdentifier> {
let (s, a) = opt(terminated(
package_scope,
peek(pair(class_identifier, symbol("::"))),
))(s)?;
let (s, b) = class_identifier(s)?;
Ok((s, PsClassIdentifier { nodes: (a, b) }))
}
#[tracable_parser] #[tracable_parser]
#[packrat_parser] #[packrat_parser]
pub(crate) fn class_type(s: Span) -> IResult<Span, ClassType> { pub(crate) fn class_type(s: Span) -> IResult<Span, ClassType> {

View File

@ -53,7 +53,7 @@ pub(crate) fn multiple_concatenation(s: Span) -> IResult<Span, MultipleConcatena
pub(crate) fn streaming_concatenation(s: Span) -> IResult<Span, StreamingConcatenation> { pub(crate) fn streaming_concatenation(s: Span) -> IResult<Span, StreamingConcatenation> {
let (s, a) = brace(triple( let (s, a) = brace(triple(
stream_operator, stream_operator,
opt(slice_size), opt(terminated(slice_size, peek(symbol("{")))),
stream_concatenation, stream_concatenation,
))(s)?; ))(s)?;
Ok((s, StreamingConcatenation { nodes: (a,) })) Ok((s, StreamingConcatenation { nodes: (a,) }))
@ -99,12 +99,12 @@ pub(crate) fn stream_expression(s: Span) -> IResult<Span, StreamExpression> {
#[packrat_parser] #[packrat_parser]
pub(crate) fn array_range_expression(s: Span) -> IResult<Span, ArrayRangeExpression> { pub(crate) fn array_range_expression(s: Span) -> IResult<Span, ArrayRangeExpression> {
alt(( alt((
map(expression, |x| {
ArrayRangeExpression::Expression(Box::new(x))
}),
array_range_expression_colon, array_range_expression_colon,
array_range_expression_plus_colon, array_range_expression_plus_colon,
array_range_expression_minus_colon, array_range_expression_minus_colon,
map(expression, |x| {
ArrayRangeExpression::Expression(Box::new(x))
}),
))(s) ))(s)
} }

View File

@ -44,9 +44,9 @@ pub(crate) fn net_lvalue_lvalue(s: Span) -> IResult<Span, NetLvalue> {
#[packrat_parser] #[packrat_parser]
pub(crate) fn variable_lvalue(s: Span) -> IResult<Span, VariableLvalue> { pub(crate) fn variable_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
alt(( alt((
variable_lvalue_pattern,
variable_lvalue_identifier, variable_lvalue_identifier,
variable_lvalue_lvalue, variable_lvalue_lvalue,
variable_lvalue_pattern,
map(streaming_concatenation, |x| { map(streaming_concatenation, |x| {
VariableLvalue::StreamingConcatenation(Box::new(x)) VariableLvalue::StreamingConcatenation(Box::new(x))
}), }),

View File

@ -153,9 +153,6 @@ pub(crate) fn module_path_primary_mintypmax_expression(
#[packrat_parser] #[packrat_parser]
pub(crate) fn primary(s: Span) -> IResult<Span, Primary> { pub(crate) fn primary(s: Span) -> IResult<Span, Primary> {
alt(( alt((
map(keyword("this"), |x| Primary::This(Box::new(x))),
map(keyword("$"), |x| Primary::Dollar(Box::new(x))),
map(keyword("null"), |x| Primary::Null(Box::new(x))),
map(assignment_pattern_expression, |x| { map(assignment_pattern_expression, |x| {
Primary::AssignmentPatternExpression(Box::new(x)) Primary::AssignmentPatternExpression(Box::new(x))
}), }),
@ -184,6 +181,9 @@ pub(crate) fn primary(s: Span) -> IResult<Span, Primary> {
map(sequence_method_call, |x| { map(sequence_method_call, |x| {
Primary::SequenceMethodCall(Box::new(x)) Primary::SequenceMethodCall(Box::new(x))
}), }),
map(keyword("this"), |x| Primary::This(Box::new(x))),
map(keyword("$"), |x| Primary::Dollar(Box::new(x))),
map(keyword("null"), |x| Primary::Null(Box::new(x))),
))(s) ))(s)
} }
@ -259,10 +259,10 @@ pub(crate) fn class_qualifier(s: Span) -> IResult<Span, ClassQualifier> {
#[packrat_parser] #[packrat_parser]
pub(crate) fn range_expression(s: Span) -> IResult<Span, RangeExpression> { pub(crate) fn range_expression(s: Span) -> IResult<Span, RangeExpression> {
alt(( alt((
map(expression, |x| RangeExpression::Expression(Box::new(x))),
map(part_select_range, |x| { map(part_select_range, |x| {
RangeExpression::PartSelectRange(Box::new(x)) RangeExpression::PartSelectRange(Box::new(x))
}), }),
map(expression, |x| RangeExpression::Expression(Box::new(x))),
))(s) ))(s)
} }

View File

@ -564,10 +564,10 @@ pub(crate) fn ps_or_hierarchical_tf_identifier(
s: Span, s: Span,
) -> IResult<Span, PsOrHierarchicalTfIdentifier> { ) -> IResult<Span, PsOrHierarchicalTfIdentifier> {
alt(( alt((
ps_or_hierarchical_tf_identifier_package_scope,
map(hierarchical_tf_identifier, |x| { map(hierarchical_tf_identifier, |x| {
PsOrHierarchicalTfIdentifier::HierarchicalTfIdentifier(Box::new(x)) PsOrHierarchicalTfIdentifier::HierarchicalTfIdentifier(Box::new(x))
}), }),
ps_or_hierarchical_tf_identifier_package_scope,
))(s) ))(s)
} }

File diff suppressed because it is too large Load Diff