-
Notifications
You must be signed in to change notification settings - Fork 121
AST-36 Allow (cascaded) tuple projections #177
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
Changes from all commits
61be517
1f832e3
5542dfa
e1e509c
1f080fd
e4c3737
6caacda
cd61d35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,6 +107,7 @@ let share_expfield (ef : exp_field) = | |
| %token PLUSASSIGN MINUSASSIGN MULASSIGN DIVASSIGN MODASSIGN POWASSIGN CATASSIGN | ||
| %token ANDASSIGN ORASSIGN XORASSIGN SHLASSIGN SHRASSIGN ROTLASSIGN ROTRASSIGN | ||
| %token NULL | ||
| %token<string> DOT_NUM | ||
| %token<string> NAT | ||
| %token<string> FLOAT | ||
| %token<Value.unicode> CHAR | ||
|
|
@@ -348,7 +349,7 @@ exp_post : | |
| { ArrayE(m, es) @? at $sloc } | ||
| | e1=exp_post LBRACKET e2=exp RBRACKET | ||
| { IdxE(e1, e2) @? at $sloc } | ||
| | e=exp_post DOT s=NAT | ||
| | e=exp_post s=DOT_NUM | ||
| { ProjE (e, int_of_string s) @? at $sloc } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is motivated by how
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit undecided on this one, but seems fine for now. |
||
| | e=exp_post DOT x=id | ||
| { DotE(e, dummy_obj_sort(), {x with it = Name x.it}) @? at $sloc } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // AST-36: foo.bar.1.zap won't parse | ||
|
|
||
| type Z = { zap : Nat }; | ||
| type B = { bar : (Int, Z) }; | ||
|
|
||
| let inner : Z = new { zap = 42 }; | ||
| let foo : B = new { bar = (25, inner) }; | ||
|
|
||
| assert(foo.bar.0 == 25); | ||
|
|
||
| assert(foo.bar.1.zap == 42); | ||
|
|
||
| assert((0,((1,1,2), (3,5), 8), 12).1.1.1 == 5); | ||
|
|
||
| // Slight imbalance: between DOT and ID we can have whitespace... | ||
|
|
||
| assert(foo. bar .1 . zap == 42); | ||
|
|
||
| // but not between DOT and NUM: | ||
|
|
||
| // assert(foo.bar. 2.zap == 42) // Error | ||
|
|
||
| // N.B.: We did not change the FLOAT syntax: | ||
|
|
||
| let (f, g, h) : (Float, Float, Float) = (1., 1.7, 1.8e-4); | ||
|
|
||
| // N.B. these fail in wasm (AST-40) | ||
|
|
||
| let (k, l) : (Float, Float) = (0x644., 0x644.5P-1) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| _out/issue36.wasm:0x___: runtime trap: unreachable executed |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| compile_lit: (FloatLit 1.) | ||
| compile_lit: (FloatLit 1.7) | ||
| compile_lit: (FloatLit 0.000_18) | ||
| compile_lit: (FloatLit 1_604.) | ||
| compile_lit: (FloatLit 802.156_25) |
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.
NATwas probably a bug, as we don't want.0x3to be a projection, right?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.
Indeed!