Skip to content

sverilogparse: accept empty line-comments (//\n)#2

Open
robtaylor wants to merge 1 commit into
masterfrom
fix/empty-line-comments
Open

sverilogparse: accept empty line-comments (//\n)#2
robtaylor wants to merge 1 commit into
masterfrom
fix/empty-line-comments

Conversation

@robtaylor
Copy link
Copy Markdown

`skip_whitespace_and_comment`'s line-comment matcher used `is_not("\r\n")`, which in nom 7 requires at least one character. So `//\n` — a `//` immediately followed by a newline, no body text — failed parsing.

This is the dominant shape in human-written file headers (license blocks, design notes, IP integration comments with empty separator lines between paragraphs), so consumers either had to strip the blank-comment lines or switch the entire header to `/* … /` block comments. Bit me writing the ANSI test fixture for #1 (worked around by removing blank `//` lines from the fixture); bit a downstream Jacquard consumer next (worked around by switching their shim's header to `/ */` block comments).

Fix

Swap to `take_while(|c| c != b'\r' && c != b'\n')` which accepts zero-length matches. `is_not` is no longer used in this module, so drop it from the import block.

Tests

New `test_header_comments_with_empty_lines` covers the empty-comment-line case plus a multi-paragraph header layout matching how foundry IP cells typically ship their copyright + license + integration-notes blocks. All 7 pre-existing tests stay green.

Downstream

Jacquard's submodule pointer will need bumping once this lands — straightforward, no Jacquard-side code change needed.

`skip_whitespace_and_comment`'s line-comment matcher used
`is_not("\r\n")`, which in nom 7 requires at least one character —
so `//\n` (a `//` immediately followed by a newline, no body text)
failed parsing. This is the dominant shape in human-written file
headers (license blocks, design notes, IP integration comments
with empty separator lines between paragraphs), so consumers
either had to strip the blank-comment lines or switch the whole
header to `/* … */` block comments.

Swap to `take_while(|c| c != b'\r' && c != b'\n')` which accepts
zero-length matches. `is_not` is no longer needed in this module,
so drop it from the import block.

New test `test_header_comments_with_empty_lines` covers the
empty-comment-line case plus a multi-paragraph header layout
matching how foundry IP cells typically ship their copyright +
license + integration-notes blocks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant