-
Notifications
You must be signed in to change notification settings - Fork 44
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
Integrate menhir parser and elaborator tests #1220
base: dev
Are you sure you want to change the base?
Conversation
… more binops, etc)
…sues with the output from the menhir -> DHExp
…es & changed tests to reflect this
…ng to better handle parens + added free var application elaboration test with menhir
… added ids to the pats
…ory, added in the plus to the fix point function name
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.
left some notes on tweaks. this is going to need to be reworked a bit (but should be mostly similar) with @Negabinary 's upcoming refactoring of DHExp / UExp. since that is coming soon, so will hold off on merging for now but you can make the syntactic changes in the grammar in anticipation of that at least
src/haz3lcore/dune
Outdated
@@ -2,7 +2,7 @@ | |||
|
|||
(library | |||
(name haz3lcore) | |||
(libraries util re sexplib unionFind uuidm) | |||
(libraries util re sexplib unionFind uuidm hazel_menhir) |
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 directory is called menhir-parser and the library is called hazel_menhir.
it may make more sense here to just put the parser in haz3lcore under a parser directory.
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.
@cyrus- it seems that the standard/recommended way to do this is with a separate directory/library (see https://stackoverflow.com/questions/70805926/include-mly-files-nested-in-subdirectories-when-compiling-with-dune and ocaml/dune#4381) due to a bug in Dune - if you would prefer I could also place it in a subdirectory of haz3lcore with its own Dune file. I don't have a preference either way - what would you prefer? Thanks!
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.
Can we put the necessary dune menhir invocations into the haz3lcore dune file or does it need its own in a subdirectory? No strong preference here, but would like the directory and library to at least have the same name.
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.
Unfortunately it seems that we can't (that's a known bug with dune according to the stack overflow I linked) - we can put the parser in haz3lcore but the parser directory will also need its own dune file. I think that will keep it part of the same library as haz3lcore? I could try that and if that doesn't work I'll just change the current directory/library to have matching names?
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.
sounds good
| Let(DHPat.t, t, t) | ||
| FixF(Var.t, Typ.t, t) | ||
| Fun(DHPat.t, Typ.t, t, option(Var.t)) | ||
| Filter(DHFilter.t, t) //pause a == 2 b |
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.
this can have a few different concrete forms depending on the filter... @tonyfettes
src/haz3lcore/dynamics/DH.re
Outdated
| EmptyHole(MetaVar.t, HoleInstanceId.t) | ||
| NonEmptyHole(ErrStatus.HoleReason.t, MetaVar.t, HoleInstanceId.t, t) | ||
| FreeVar(MetaVar.t, HoleInstanceId.t, Var.t) | ||
| EmptyHole(MetaVar.t, HoleInstanceId.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.
()
is the notation for unit values, so let's use ?
for empty holes
src/haz3lcore/dynamics/DH.re
Outdated
| NonEmptyHole(ErrStatus.HoleReason.t, MetaVar.t, HoleInstanceId.t, t) | ||
| FreeVar(MetaVar.t, HoleInstanceId.t, Var.t) | ||
| EmptyHole(MetaVar.t, HoleInstanceId.t) //() | ||
| NonEmptyHole(ErrStatus.HoleReason.t, MetaVar.t, HoleInstanceId.t, t) //(_HOLE x) |
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.
let's use {{e}}
for non-empty holes
src/haz3lcore/dynamics/DH.re
Outdated
| FreeVar(MetaVar.t, HoleInstanceId.t, Var.t) | ||
| EmptyHole(MetaVar.t, HoleInstanceId.t) //() | ||
| NonEmptyHole(ErrStatus.HoleReason.t, MetaVar.t, HoleInstanceId.t, t) //(_HOLE x) | ||
| FreeVar(MetaVar.t, HoleInstanceId.t, Var.t) //(_FREE x) |
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.
let's use {{?x}}
for free variables
src/haz3lcore/dynamics/DH.re
Outdated
| BoundVar(Var.t) //x | ||
| Sequence(t, t) //a; b | ||
| Let(DHPat.t, t, t) //let x = y in z | ||
| FixF(Var.t, Typ.t, t) //_FIX f Int -> Int fun: Int x -> 1 + x f in 55 |
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.
I believe the syntax here should be fix x : ty -> e
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.
Ok, I fixed that but I unfortunately cant use the "->" because it seems to create a conflict in Menhir between the exp and typ (I'm pretty sure it is conflicting with the "->" in arrow types) so instead I used "=>". The syntax is now fix x: ty => e
, are you alright with that or would you prefer I try to find some way around the conflict?
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.
Maybe have it be parenthesized, so fix x -> e
or fix (x : ty) -> e
? would prefer to keep the Hazel notation consistent here so if we change it here then we should change it in Hazel
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.
That worked! Thank you!
src/haz3lcore/dynamics/DH.re
Outdated
| Sequence(t, t) //a; b | ||
| Let(DHPat.t, t, t) //let x = y in z | ||
| FixF(Var.t, Typ.t, t) //_FIX f Int -> Int fun: Int x -> 1 + x f in 55 | ||
| Fun(DHPat.t, Typ.t, t, option(Var.t)) //fun: Int x -> x + 1 |
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 syntax here should be fun p -> e
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.
I had to add in manual annotations for the type of the function to be able to construct the dhexp with the type. The current elaborator gets the type from the pattern but uses the statics map - I thought it would be best to just add in the annotations rather than try to interface with that. What do you think?
src/haz3lcore/dynamics/DH.re
Outdated
| TypFun(Term.UTPat.t, t, option(Var.t)) | ||
| TypAp(t, Typ.t) | ||
| Ap(t, t) | ||
| Ap(t, t) //a(1) |
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.
e1(e2)
| Cons(t, t) //a :: b | ||
| ListConcat(t, t) //a @ b | ||
| Tuple(list(t)) //(a, b) | ||
| Prj(t, int) //TODO |
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.
e.n
src/haz3lcore/dynamics/DH.re
Outdated
| Constructor(string) //X | ||
| ConsistentCase(case) //4 == 3 | true => 24 | false => false end | ||
| Cast(t, Typ.t, Typ.t) //x <Unknown Internal => Int> | ||
| FailedCast(t, Typ.t, Typ.t) //x ?<Int => Int> |
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.
e<ty1 =!> ty2>
or something like that
Sounds good, thanks for the feedback. I'll make those syntactic changes and wait for the new UExp/DHExp to update then I'll mark as ready for review again. |
…dh docs to use metavariables
…xtual syntax, fixed menhir conflict with fixf
No description provided.