Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make some of lexer's API private #59671

Merged
merged 2 commits into from
Apr 4, 2019
Merged

Make some of lexer's API private #59671

merged 2 commits into from
Apr 4, 2019

Conversation

matklad
Copy link
Member

@matklad matklad commented Apr 3, 2019

Lexer is a pub type, so it feels wrong that its fields are just pub (I guess it wasn't exported initially), so let's minimize visibility.

Context: I am looking into extracting rust-lexer into a library, which can be shared by rust-analyzer and rustc. I hope that a simple interface like fn next_token(src: &str) -> (TokenKind, usize) would work, but to try this out I need to understand what is the current API of the lexer.

@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 3, 2019
@eddyb
Copy link
Member

eddyb commented Apr 4, 2019

I hope that a simple interface like fn next_token(src: &str) -> (TokenKind, usize) would work, but to try this out I need to understand what is the current API of the lexer.

The API feels like it predates iterators, in some sense, it should probably be streamlined.

@eddyb
Copy link
Member

eddyb commented Apr 4, 2019

For example, the peeking should ideally be handled with .peekable().

Anyway, this seems like a good start.

@bors r+

@bors
Copy link
Contributor

bors commented Apr 4, 2019

📌 Commit 1763aea has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 4, 2019
Centril added a commit to Centril/rust that referenced this pull request Apr 4, 2019
Make some of lexer's API private

Lexer is a `pub` type, so it feels wrong that its fields are just pub (I guess it wasn't exported initially), so let's minimize visibility.

Context: I am looking into extracting rust-lexer into a library, which can be shared by rust-analyzer and rustc. I hope that a simple interface like `fn next_token(src: &str) -> (TokenKind, usize)` would work, but to try this out I need to understand what is the current API of the lexer.
@matklad
Copy link
Member Author

matklad commented Apr 4, 2019

@eddyb yeah, I feel like this could be improved massively by separating the actual lexing from rustc-specific bits like spans and source maps. See https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Extracting.20the.20lexer/near/162515922 for the rough proposal

bors added a commit that referenced this pull request Apr 4, 2019
Rollup of 8 pull requests

Successful merges:

 - #59470 (Document std::fs::File close behavior ignoring errors)
 - #59555 (update miri)
 - #59556 (update stdsimd)
 - #59596 (Forward formatter settings to bounds of `Range<T>` in `fmt::Debug` impl)
 - #59639 (Never return uninhabited values at all)
 - #59671 (Make some of lexer's API private)
 - #59685 (Add description for -Os and -Oz in rustc.1)
 - #59686 (Temporarily disable stack probing for gnux32.)

Failed merges:

r? @ghost
@bors bors merged commit 1763aea into rust-lang:master Apr 4, 2019
@bors
Copy link
Contributor

bors commented Apr 4, 2019

⌛ Testing commit 1763aea with merge 52980d0...

@bjorn3
Copy link
Member

bjorn3 commented Apr 13, 2019

Why is bors testing this and #59556? It is already merged.

@bjorn3 bjorn3 mentioned this pull request Apr 13, 2019
@RalfJung
Copy link
Member

@bors r- retry

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants