Skip to content

Support CRLF BLIF files and expose string parser#1

Open
benjaminwp18 wants to merge 7 commits intoucb-bar:mainfrom
benjaminwp18:main
Open

Support CRLF BLIF files and expose string parser#1
benjaminwp18 wants to merge 7 commits intoucb-bar:mainfrom
benjaminwp18:main

Conversation

@benjaminwp18
Copy link

On Windows, YOSYS generates BLIF files with CRLF line endings. blif-parser currently errors on CRLF line endings. This PR:

  • makes blif-parser accept both \n and \r\n
  • makes the string parsing function public so any future file format wonkiness can be solved by the user

I'd be happy to make changes if anyone sees this and has feedback!

src/parser.rs Outdated
};

const MODULE_END_UNIX: &'static str = "\n.end\n";
const MODULE_END_WINDOWS: &'static str = "\r\n.end\r\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is undesirable to have global constants embedded in the file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with local constants; only used in one function

@joonho3020
Copy link
Contributor

joonho3020 commented Feb 1, 2026

  • The changes you made causes the parser to hang for certain files. Can you investigate the issue and fix it? The test is added in the upstream blif-parser repo

@benjaminwp18
Copy link
Author

Looks like the hang was just very slow parsing; removing my take_until_newline parser brought performance back in line with the trunk. take_until_newline used an alt that performed MUCH worse than a single take_until("\n"), and all its usages discarded the \r separately anyway.

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.

2 participants