-
Notifications
You must be signed in to change notification settings - Fork 0
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
Ed binop #86
Ed binop #86
Changes from 3 commits
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 |
---|---|---|
|
@@ -14,11 +14,37 @@ let rec castx_of_sastx texpr = | |
| Sast.LitStr(x) -> Cast.LitStr(x) | ||
| Sast.LitUnit -> Cast.LitUnit | ||
|
||
| Sast.Binop(lexpr, op, rexpr) | ||
-> ignore lexpr; ignore op; ignore rexpr; failwith "Binop cast_sast not implemented" | ||
| Sast.Binop(lexpr, op, rexpr) -> | ||
begin match op with | ||
| Ast.Zip -> failwith "Internal error: binop zip should have been converted to Call NhFunction in ast2sast" | ||
| Ast.Concat -> | ||
Cast.Call(Cast.Function("nh_support","concat"),[castx_of_sastx lexpr; castx_of_sastx rexpr]) | ||
| Ast.Chord -> failwith "Internal error: binop chord should have been converted to Call NhFunction in ast2sast" | ||
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. In typed_ast.ml, we have | Ast.Chord ->
(* guarantee that chord binop is between two chords *)
Sast.Binop(chord_of lexprt, op, chord_of rexprt), Ast.Type("chord") Doesn't that mean it's possible to get Sast.Binop(_, Ast.Chord, _) in here? 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. ah i forgot to change it thanks. |
||
| Ast.Octave -> failwith "Internal error: binop octave should have been converted to Call NhFunction in ast2sast" | ||
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. Potentially an unpopular opinion, but i think we should make a Sast binop that excludes Zip, Chord, and Octave. Reasoning:
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. (And the same for uniop's flat and sharp) 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 agree, but be aware that you are also giving me arthritis of the fingers. 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. ticketed as #88 |
||
| _ as cop -> let op = begin match cop with | ||
| Ast.Add -> Cast.Add | ||
| Ast.Sub -> Cast.Sub | ||
| Ast.Mul -> Cast.Mult | ||
| Ast.Div -> Cast.Div | ||
| Ast.Mod -> Cast.Mod | ||
| Ast.Eq -> Cast.Equal | ||
| Ast.Neq -> Cast.Neq | ||
| Ast.Lt -> Cast.Less | ||
| Ast.Lte -> Cast.Leq | ||
| Ast.And -> Cast.And | ||
| Ast.Or -> Cast.Or | ||
| _ -> failwith "Internal error: failed to match all possible binops in sast2cast" | ||
end in Cast.Binop(castx_of_sastx lexpr, op, castx_of_sastx rexpr) | ||
end | ||
|
||
|
||
| Sast.Uniop(op, expr) | ||
-> ignore op; ignore expr; failwith "Uniop cast_sast not implemented" | ||
| Sast.Uniop(op, expr) -> | ||
begin match op with | ||
| Ast.Not -> Cast.Uniop(Cast.Not, castx_of_sastx expr) | ||
| Ast.Neg -> Cast.Uniop(Cast.Neg, castx_of_sastx expr) | ||
| _ -> failwith | ||
"Internal error: uniop flat and sharp should have been converted to Call NhFunction in ast2sast" | ||
end | ||
|
||
| Sast.VarRef(names) -> Cast.VarRef(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.
this crashes the parser.
could you comment it out, and change tabs to spaces?