-
Notifications
You must be signed in to change notification settings - Fork 54
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
Syntax factory #1530
base: dev
Are you sure you want to change the base?
Syntax factory #1530
Conversation
…statics tests - Uses temp module to remove fresh/invalid calls in statics test - Uses Info error module to create expressions with default no errors
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1530 +/- ##
==========================================
+ Coverage 50.33% 50.88% +0.55%
==========================================
Files 103 103
Lines 10442 10594 +152
==========================================
+ Hits 5256 5391 +135
- Misses 5186 5203 +17
|
src/haz3lcore/lang/term/Grammar.re
Outdated
}; | ||
|
||
// pat | ||
let pat_invalid = (~ann=?, s): pat_t(DefaultAnnotation.t) => { |
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 can also nest modules inside here instead of prepending sort. This works with local open so you could do:
FTemp.(Exp.(list([int(1), int(2), cast(int(3), Typ.int(), Typ.unknown(Internal)))))
test/Test_Statics.re
Outdated
ty_prod([ | ||
ty_tup_label( | ||
ty_label("a"), | ||
ty_prod([ | ||
ty_tup_label( | ||
ty_label("b"), | ||
ty_prod([ | ||
ty_tup_label(ty_label("c"), ty_unknown(Hole(EmptyHole))), | ||
]), | ||
), | ||
]), | ||
), | ||
]), |
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.
Example of the fresh calls being removed.
test/Test_Statics.re
Outdated
Common( | ||
TupleLabelError({ | ||
malformed_labels: [], | ||
duplicate_labels: [], | ||
invalid_labels: ["c"], | ||
typ: | ||
TupLabel( | ||
Label("c") |> Typ.fresh, | ||
Int |> Typ.fresh, | ||
) | ||
|> Typ.fresh, | ||
}), | ||
), | ||
), | ||
TupLabel( | ||
error_exp( | ||
Exp(Common(NoType(InvalidLabel("c")))), | ||
Label("c"), | ||
Inconsistent( | ||
FTemp.( | ||
Expectation({ | ||
ana: | ||
ty_parens( | ||
ty_prod([ | ||
ty_int(), | ||
ty_tup_label(ty_label("a"), ty_string()), | ||
]), | ||
), | ||
syn: | ||
ty_prod([ | ||
ty_tup_label(ty_label("c"), ty_int()), | ||
ty_tup_label(ty_label("a"), ty_string()), | ||
]), | ||
}) | ||
), | ||
no_error_exp(Int(1)), | ||
), | ||
), | ||
no_error_exp( | ||
TupLabel( | ||
no_error_exp(Label("a")), | ||
no_error_exp(String("hello")), | ||
), | ||
), | ||
tuple( | ||
~ann= | ||
Some( | ||
Exp( | ||
Common( | ||
TupleLabelError({ | ||
malformed_labels: [], | ||
duplicate_labels: [], | ||
invalid_labels: ["c"], | ||
typ: | ||
FTemp.( | ||
ty_prod([ | ||
ty_tup_label(ty_label("c"), ty_int()), | ||
ty_tup_label(ty_label("a"), ty_string()), | ||
]) | ||
), | ||
}), | ||
), | ||
), | ||
]), | ||
), | ||
), | ||
[ | ||
{ | ||
tup_label( | ||
~ann= | ||
Some( | ||
Exp( | ||
Common( | ||
TupleLabelError({ | ||
malformed_labels: [], | ||
duplicate_labels: [], | ||
invalid_labels: ["c"], | ||
typ: | ||
FTemp.( | ||
ty_tup_label(ty_label("c"), ty_int()) | ||
), | ||
}), | ||
), | ||
), | ||
), | ||
error_exp( | ||
Exp(Common(NoType(InvalidLabel("c")))), | ||
Label("c"), | ||
), | ||
int(1), | ||
); | ||
}, | ||
tup_label(label("a"), string("hello")), | ||
], | ||
), | ||
), | ||
no_error_exp(Bool(true)), | ||
), | ||
bool(true), | ||
) |
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.
The test is significantly smaller and only 30 out of the remaining ~90 lines are the AST. The rest are the annotations.
d4c597f
to
c5ebe7d
Compare
let default_annotation = ann => | ||
Option.value(~default=DefaultAnnotation.default_value(), ann); | ||
module Exp = { | ||
let invalid = (~ann=?, s): exp_t(DefaultAnnotation.t) => { |
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.
Figure out if we want to have a pattern match from the original one to make sure we don't miss one of these.
Add factory functions for AST
Needs to be merged after #1518
Adds a bunch of helper functions for building up the AST with default annotations.