-
Notifications
You must be signed in to change notification settings - Fork 8
Parse tuple types and expressions #93
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
Conversation
fdeb90d to
61f3301
Compare
61f3301 to
1f9bcb3
Compare
969a9bc to
3a09819
Compare
| }, | ||
| Block(Block), | ||
| If(IfExpr), | ||
| Tuple(Vec<Expr>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is a tuple a kind of immediate or literal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have something more complex such as:
let tuple = (
{ ... }, // code block
if cond { .. } else { .. }, // if expressions
foo(), // function call,
etc.
);I suppose adding tests for these would be quite useful.
sezna
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved but curious if a tuple could be a literal
3a09819 to
affce34
Compare
| Tuple indexing expressions are written as: | ||
|
|
||
| ```ebnf | ||
| <tuple-index-expr> ::= <expr-atom> "." [0-9]+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's an expr-atom? It can be any expression which has a tuple type, which might be a fn call, identifier or other tuple index. So it should just be expr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I will restructure this. See #99
Closes #72
Fairly simple change:
0xaor anything that is not ausize.Note that
t.0.0does not currently work, butt.0 .0. Once we implement #66, we can then write(t.0).0. In the future, we can supportt.0.0which can be done in two ways:0.0as a real in the case of a tuple access (this means the lexer now has to concern itself with the context).0.0apart in the pasrer, which kinda what Rust does (see Accept tuple.0.0 as tuple indexing (take 2) rust-lang/rust#71322 after an attempt for the other method in Accept tuple.0.0 as tuple indexing rust-lang/rust#70420)