Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# sv-parser
SystemVerilog parser library fully compliant with [IEEE 1800-2017](https://standards.ieee.org/standard/1800-2017.html).
SystemVerilog parser library fully compliant with [IEEE 1800-2017](https://standards.ieee.org/standard/1800-2017.html). Relaxed parsing rues are possible via feature flags.

[![Actions Status](https://github.com/dalance/sv-parser/workflows/Regression/badge.svg)](https://github.com/dalance/sv-parser/actions)
[![Crates.io](https://img.shields.io/crates/v/sv-parser.svg)](https://crates.io/crates/sv-parser)
Expand Down
30 changes: 20 additions & 10 deletions sv-parser-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,25 @@ tag = false

[features]
default = []
trace = ["nom-tracable/trace"]
trace = ["nom-tracable/trace"]
nested-gen-block-begin = []
empty-queue-syntax = []
consecutive-unary-operators = []
allow-no-apostrophe = []
vendor-extensions = [
"nested-gen-block-begin",
"empty-queue-syntax",
"consecutive-unary-operators",
"allow-no-apostrophe",
]

[dependencies]
nom = "7"
nom_locate = "4"
nom-greedyerror = "0.5"
nom-packrat = "0.7"
nom-recursive = {version = "0.5", features = ["tracer128"]}
nom-tracable = "0.9"
str-concat = "0.2"
sv-parser-macros = {version = "^0.13.5", path = "../sv-parser-macros"}
sv-parser-syntaxtree = {version = "^0.13.5", path = "../sv-parser-syntaxtree"}
nom = "7"
nom_locate = "4"
nom-greedyerror = "0.5"
nom-packrat = "0.7"
nom-recursive = { version = "0.5", features = ["tracer128"] }
nom-tracable = "0.9"
str-concat = "0.2"
sv-parser-macros = { version = "^0.13.5", path = "../sv-parser-macros" }
sv-parser-syntaxtree = { version = "^0.13.5", path = "../sv-parser-syntaxtree" }
19 changes: 19 additions & 0 deletions sv-parser-parser/src/behavioral_statements/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,29 @@ pub(crate) fn assignment_pattern_structure(s: Span) -> IResult<Span, AssignmentP
#[tracable_parser]
#[packrat_parser]
pub(crate) fn assignment_pattern_array(s: Span) -> IResult<Span, AssignmentPattern> {
#[cfg(not(feature = "allow-no-apostrophe"))]
let (s, a) = apostrophe_brace(list(
symbol(","),
triple(array_pattern_key, symbol(":"), expression),
))(s)?;
#[cfg(feature = "allow-no-apostrophe")]
let (s, a) = alt((
map(
apostrophe_brace(list(
symbol(","),
triple(array_pattern_key, symbol(":"), expression),
)),
|ab| BraceOrApostropheBraceArray::ApostropheBrace(ab),
),
map(
brace(list(
symbol(","),
triple(array_pattern_key, symbol(":"), expression),
)),
|b| BraceOrApostropheBraceArray::Brace(b),
),
))(s)?;

Ok((
s,
AssignmentPattern::Array(Box::new(AssignmentPatternArray { nodes: (a,) })),
Expand Down
2 changes: 2 additions & 0 deletions sv-parser-parser/src/expressions/concatenations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ pub(crate) fn array_range_expression_minus_colon(s: Span) -> IResult<Span, Array
pub(crate) fn empty_unpacked_array_concatenation(
s: Span,
) -> IResult<Span, EmptyUnpackedArrayConcatenation> {
#[cfg(feature = "empty-queue-syntax")]
let (s, _) = opt(symbol("'"))(s)?;
let (s, a) = symbol("{")(s)?;
let (s, b) = symbol("}")(s)?;
Ok((s, EmptyUnpackedArrayConcatenation { nodes: (a, b) }))
Expand Down
18 changes: 14 additions & 4 deletions sv-parser-parser/src/expressions/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,23 @@ pub(crate) fn expression(s: Span) -> IResult<Span, Expression> {
#[tracable_parser]
#[packrat_parser]
pub(crate) fn expression_unary(s: Span) -> IResult<Span, Expression> {
let (s, x) = unary_operator(s)?;
let (s, w) = unary_operator(s)?;
#[cfg(feature = "consecutive-unary-operators")]
let (s, x) = many0(unary_operator)(s)?;
let (s, y) = many0(attribute_instance)(s)?;
let (s, z) = primary(s)?;
Ok((
#[cfg(not(feature = "consecutive-unary-operators"))]
return Ok((
s,
Expression::Unary(Box::new(ExpressionUnary { nodes: (x, y, z) })),
))
Expression::Unary(Box::new(ExpressionUnary { nodes: (w, y, z) })),
));
#[cfg(feature = "consecutive-unary-operators")]
return Ok((
s,
Expression::Unary(Box::new(ExpressionUnary {
nodes: (w, x, y, z),
})),
));
}

#[tracable_parser]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ pub(crate) fn generate_block_multiple(s: Span) -> IResult<Span, GenerateBlock> {
let (s, a) = opt(pair(generate_block_identifier, symbol(":")))(s)?;
let (s, b) = keyword("begin")(s)?;
let (s, c) = opt(pair(symbol(":"), generate_block_identifier))(s)?;
#[cfg(feature = "nested-gen-block-begin")]
let (s, (d, e)) = many_till(generate_block, keyword("end"))(s)?;
#[cfg(not(feature = "nested-gen-block-begin"))]
let (s, (d, e)) = many_till(generate_item, keyword("end"))(s)?;
let (s, f) = opt(pair(symbol(":"), generate_block_identifier))(s)?;
Ok((
Expand Down
15 changes: 12 additions & 3 deletions sv-parser-syntaxtree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ license = "MIT OR Apache-2.0"
readme = "../README.md"
description = "Helper crate of sv-parser"
edition = "2018"
build = "build.rs"

[lib]
doctest = false
Expand All @@ -18,8 +17,18 @@ doctest = false
tag = false

[dependencies]
sv-parser-macros = {version = "^0.13.5", path = "../sv-parser-macros"}
sv-parser-macros = { version = "^0.13.5", path = "../sv-parser-macros" }

[build-dependencies]
regex = "1"
regex = "1"
walkdir = "2"

[features]
nested-gen-block-begin = []
consecutive-unary-operators = []
allow-no-apostrophe = []
vendor-extensions = [
"nested-gen-block-begin",
"consecutive-unary-operators",
"allow-no-apostrophe",
]
103 changes: 0 additions & 103 deletions sv-parser-syntaxtree/build.rs

This file was deleted.

Loading
Loading