Skip to content

Commit a2b942b

Browse files
Switch to regex for TXT header detection
1 parent 0e9f589 commit a2b942b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/parse.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export class YosysJsonStatsParseError extends Error {
2424
}
2525
}
2626

27-
const STAT_FILE_HEADER = "Printing statistics."
2827
const TOP_METANAME = "@Top@"
2928

3029
export function parseTextStats(input: string): ParsedModule[] {
@@ -38,7 +37,10 @@ export function parseTextStats(input: string): ParsedModule[] {
3837
if (rawModules.length === 0) {
3938
return []
4039
}
41-
if (rawModules[0].length !== 1 || !rawModules[0][0].trim().endsWith(STAT_FILE_HEADER)) {
40+
if (
41+
rawModules[0].length !== 1 ||
42+
!rawModules[0][0].trim().match(/^[0-9]+\. Printing statistics\.$/)
43+
) {
4244
throw new TextStatsParseError("Bad header")
4345
}
4446
const parsedRawModules: (ParsedModule | string)[] = rawModules.slice(1).map((rawModule) => {

0 commit comments

Comments
 (0)