8000 [netlist] Do not abort when '/' or '(' is the last input character by 12yuuuu · Pull Request #5571 · google/xls · GitHub
[go: up one dir, main page]

Skip to content

[netlist] Do not abort when '/' or '(' is the last input character - #5571

Open
12yuuuu wants to merge 1 commit into
google:mainfrom
12yuuuu:fix-5563-scanner-peek-eof
Open

12yuuuu wants to merge 1 commit into
google:mainfrom
12yuuuu:fix-5563-scanner-peek-eof

Conversation

@12yuuuu
@12yuuuu 12yuuuu commented Nov 29, 2026
Copy link
Copy Markdown
Contributor

Part of #5563 (item 2).

The netlist scanner aborted when the input ended with / or (. It looks at the next character to find comments and attributes, and PeekChar2OrDie() CHECK-fails when there is no next character. A file with only / was enough.

This PR replaces it with PeekChar2(), which returns std::nullopt at the end of the input.

Input Before After
/ abort UNIMPLEMENTED: Unsupported character: '/'
( abort INVALID_ARGUMENT: Want keyword 'module'

I added five tests. bazel test //xls/netlist:netlist_parser_test passes locally.

Items 1 and 3 of the issue are not changed. Because of item 1, some inputs like module main(); / still abort in the parser.

This PR was written with AI assistance (Claude); I reviewed and tested the changes.

The scanner looks at the next character after '/' or '(' to find
comments and attributes. PeekChar2OrDie aborted when there was no
next character. A file with only '/' was enough.

Replace it with PeekChar2, which returns std::nullopt at the end of
the input. Now '/' gives an error and '(' gives a normal token.

Part of google#5563.

Assisted-by: Claude (Anthropic)

This branch has not been deployed

No deployments
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

0