handle [ in var declaration and ( or [ in scope declaration - #29
Closed
andreabellizzi wants to merge 2 commits into
Closed
handle [ in var declaration and ( or [ in scope declaration#29andreabellizzi wants to merge 2 commits into
andreabellizzi wants to merge 2 commits into
Conversation
some var are declared like: $var integer 32 p&! varname [1423][2] $end some scope are declared like: $scope begin scope_name(432) $end which is out of spec but seen in vcd dump
jpgrayson
added a commit
that referenced
this pull request
Aug 10, 2026
Scope identifiers and variable references in real VCD files routinely
contain characters that IEEE 1800-2023 21.7 admits only within escaped
identifiers, e.g. verilator's mem_array[0] and genblock[3].mod, UVM's
uvm_phase::m_wait_for_pred, and cva6's scope_name(432). Extending the
simple identifier character set once per newly reported character does
not converge, so lex these names as everything up to whitespace instead,
and keep the identifier lexer for keywords, types, and units, where the
character set of a simple identifier does apply. For scopes this also
matches the grammar, which gives scope_identifier ::= { ASCII character }
rather than an identifier.
A variable reference is ambiguous once brackets are part of a name:
mem_array[0] is indistinguishable from a bit select of mem_array.
Whitespace cannot separate the two, as the reference in the standard's
own example is unspaced:
$var reg 32 (k accumulator[31:0] $end
So only the final bracketed section of a reference is treated as a bit
index, and only when it holds decimal indices. This preserves the
existing interpretation of accumulator[31:0] and foo [17] while
admitting references such as varname[1423][SOMENAME][2]. Brackets within
an escaped identifier are always part of the name.
Resolves issues #22 and #35 and supersedes PRs #29, #40, and #41.
Collaborator
|
Thanks for this, and sorry for the long delay. Fixed in 92b8181 by a different route. Rather than special-casing brackets and parens in the parser, Both of your cases are covered, including I added test cases from your report. Closing in favor of the version on master. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
some var are declared like:
$var integer 32 p&! varname [1423][SOMENAME][2] $end
some scope are declared like:
$scope begin scope_name(432) $end
which is out of spec but seen in vcd dump