fix(parser): accept single-value rvalues and C-style block comments - #11
Open
ThVerg wants to merge 1 commit into
Open
fix(parser): accept single-value rvalues and C-style block comments#11ThVerg wants to merge 1 commit into
ThVerg wants to merge 1 commit into
Conversation
IEEE 1497 defines rvalue as "(" [signed_real_number] ")" | "(" [rtriple] ")",
but the grammar admitted only an empty () or a full two-colon triple, so any
SDF file using the scalar form failed to parse outright. rvalue is the shared
value rule for every delay and timing check, so the missing alternative
rejected the whole file.
The alternative is added at the rvalue level rather than to real_triple; the
latter does not build under LALR (reduce/reduce collision on RPAR between
real_triple: FLOAT and rvalue: FLOAT).
A lone number also applies to all three of min:typ:max, not to typ alone, so
rvalue() now fills every field. Without this, (5) parsed but reported no min
or max, dropping the delay from critical-path and stats and round-tripping as
(:5:).
Separately, only // line comments were ignored, so a file carrying a /* */
banner failed at its first character. BLOCK_COMMENT matches a multi-line,
non-greedy /* ... */ and is ignored alongside COMMENT.
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.
Single-value rvalue is unparseable, rejecting most real-world SDF
Replacing
(5)with(5:5:5)parses fine, confirming thervaluerule is the cause.IEEE 1497 defines
rvalue ::= "(" [signed_real_number] ")" | "(" [rtriple] ")", so aparenthesised single number is legal everywhere a delay or check value appears. The
grammar currently admits only an empty
()or a full two-colon triple, so any file usingthe scalar form fails to parse outright.
rvalueis the shared value rule for every delay and every timing check (IOPATH,INTERCONNECT,PORT,DEVICEviadelval_list, plusSETUP,HOLD,SETUPHOLD,RECOVERY,REMOVAL,WIDTH,PERIOD,PATHCONSTRAINT), so the single missingalternative rejects the whole file with no partial recovery.
Changes
1.
sdf.lark— the missingrvaluealternativeAdded at the
rvaluelevel rather than as an alternative toreal_triple. The latterlooks more natural but does not build — the parser is LALR, and
real_triple: ... | FLOATgives:The existing bare-
FLOATalternative is kept: it is what makes the unparenthesised headerforms
(VOLTAGE 1.8)/(TEMPERATURE 25)parse.2.
transformers.py— a single number applies to all three cornersThe grammar change alone is not sufficient. Without this,
(5)parses but storesmin=None, avg=5.0, max=None, soget_scalar("nominal", "max")returnsNone— delaysdisappear from
critical-path,statsand slack — and a round-trip rewrites(5)as(:5:), which tells downstream tools the min and max are unknown.3.
sdf.lark— C-style block commentsSame class of problem, separate cause. Only
//line comments were ignored, so a filecarrying a
/* ... */banner — a normal thing for an EDA tool to emit — fails to parse atthe very first character:
The terminal matches
/*, then any characters, then*/;%ignorediscards those tokensbefore the grammar sees them, mirroring the existing
COMMENT/%ignore COMMENTpairdirectly above.
Two details in the pattern:
[\s\S]rather than., because.does not match a newline and block comments areusually multi-line.
*?rather than*, because a greedy match would run from the first/*tothe last
*/in the file and swallow all the SDF in between.