Skip to content

Handle function calls to integers in model lexer correctly #20330

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

Merged
merged 3 commits into from
Dec 31, 2014

Conversation

fhahn
Copy link
Contributor

@fhahn fhahn commented Dec 30, 2014

This patch resolves the second problem mentioned in #15877: function calls to integers, e.g. 3.b().

It does so, by checking whether the character following the first dot of a FLOAT_LIT is a character or an underscore (these should denote a valid identifier). This does not look like a particularly, but it seems like a lookahead of 1 is needed for this distinction.

Another interesting aspect are ranges that start with a integer constant, but end with a function call, e.g. 1..b(). Rust treats this as a range from 1 to b(), but given that 1. is a valid FLOAT_LIT, 1..b() could be a function call to a float as well.

cc @cmr

@rust-highfive
Copy link
Contributor

r? @pcwalton

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

@fhahn
Copy link
Contributor Author

fhahn commented Dec 30, 2014

I've added 2 additional commits. check.sh now counts passed, failed and skipped tests and prints a summary and I've updated src/grammar/README.me to work with the current version of the lexer and verify.rs.

I could submit another pull request for these changes, if that's easier to review/accept?

@alexcrichton
Copy link
Member

r? @cmr

@alexcrichton alexcrichton assigned emberian and unassigned pcwalton Dec 30, 2014
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Dec 31, 2014
This patch resolves the second problem mentioned in rust-lang#15877: function calls to integers, e.g. `3.b()`.

 It does so, by checking whether the character following the first dot of a FLOAT_LIT is a character or an underscore (these should denote a valid identifier). This does not look like a particularly, but it seems like a lookahead of 1 is needed for this distinction.

Another interesting aspect are ranges that start with a integer constant, but end with a function call, e.g. `1..b()`. Rust treats this as a range from 1 to `b()`, but given that `1.` is a valid FLOAT_LIT, `1..b()` could be a function call to a float as well.

cc @cmr
@bors bors merged commit 1e278c1 into rust-lang:master Dec 31, 2014
@fhahn fhahn deleted the issue-15877-model-lexer-range-2 branch January 5, 2015 21:44
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.

6 participants