google / google/xls

[enhancement] DSLX should introduce turbofish qualifier to avoid need to backtrack

Open
#1,691 0 comments 0 reactions 0 assignees View on GitHub
dslx enhancement
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

### What's hard to do? (limit 100 words)

We still have backtracking in the parser on account of the fact we don't know if `identifier oangle` (in an expression grammatical context) is going to be a less-than symbol or a parametric instantiation. To disambiguate this and avoid the need for backtracking Rust has the turbofish qualifier which I'd like to propose we adopt to fully eliminate the backtracking (good explainer blog post with more links here: https://matematikaadit.github.io/posts/rust-turbofish.html )

Code is here:
- https://github.com/google/xls/blob/6b7c0dcae9c9b90c3d4e7f7b2c7b38af6b39fdea/xls/dslx/frontend/parser.cc#L1730
- https://github.com/google/xls/blob/6b7c0dcae9c9b90c3d4e7f7b2c7b38af6b39fdea/xls/dslx/frontend/parser.cc#L1967

### Current best alternative workaround (limit 100 words)

Keep backtracking -- this had led to bugs historically, and I was able to eliminate almost all backtracking in the past, but this one remains.

### Your view of the "best case XLS enhancement" (limit 100 words)

Introduce turbofish to make the parse unambiguous.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.