C#_strange_Kuznetsov#28
Conversation
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: Dmitri <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
| open Stdio | ||
|
|
||
| type opts = | ||
| { mutable dump_parse_tree : bool |
There was a problem hiding this comment.
Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable references and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
| type opts = | ||
| { mutable dump_parse_tree : bool | ||
| ; mutable file_path : string option | ||
| ; mutable eval : bool |
There was a problem hiding this comment.
Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable references and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
| match interpret_program ast with | ||
| | Ok (Some v) -> printf "Result: %s\n" (show_value v) | ||
| | Ok None -> printf "Result: void\n" | ||
| | Error _ -> failwith (sprintf "Interpretation error")) |
There was a problem hiding this comment.
Using failwith (or assert false) usually is a clue that a corner case is not being handled properly. To report errors we recommend using error monad instead. In princliple, these construction are OK for temporary work-in-progress code, but in release they should be eliminated
| | Ok (Some v) -> printf "Result: %s\n" (show_value v) | ||
| | Ok None -> printf "Result: void\n" | ||
| | Error _ -> failwith (sprintf "Interpretation error")) | ||
| | Error msg -> failwith (sprintf "Failed to parse file: %s" msg) |
There was a problem hiding this comment.
Using failwith (or assert false) usually is a clue that a corner case is not being handled properly. To report errors we recommend using error monad instead. In princliple, these construction are OK for temporary work-in-progress code, but in release they should be eliminated
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
|
Документация и тестовое покрытие (81.07%) должны скоро появиться. https://kakadu.github.io/fp25/docs/CSharpStrange_Kuznetsov https://kakadu.github.io/fp25/cov/CSharpStrange_Kuznetsov 2026-03-16 21:39 |
| | Error e -> failwith (sprintf "Interpretation error: %s" (show_error e))) | ||
| | None, Ok _ -> failwith "Interpretation error: Main method not found" | ||
| | _, Error e -> failwith (sprintf "Typecheck error: %s" (show_error e)))) | ||
| | Error msg -> failwith (sprintf "Parser error: Failed to parse file: %s" msg) |
There was a problem hiding this comment.
Using failwith (or assert false) usually is a clue that a corner case is not being handled properly. To report errors we recommend using error monad instead. In princliple, these construction are OK for temporary work-in-progress code, but in release they should be eliminated
| gen_expr_no_assign env var_type >>= fun e -> return (EBinOp (OpAssign, EId id, e))) | ||
|
|
||
| (* Binary operations *) | ||
| and gen_binop_expr env expected_type = |
There was a problem hiding this comment.
Using function is recommended
| | _ -> gen_expr_no_assign env expected_type | ||
|
|
||
| (* Binary operations without assignment *) | ||
| and gen_binop_expr_no_assign env expected_type = |
There was a problem hiding this comment.
Using function is recommended
| ; (4, gen_funcall env TypeVoid >>= fun e -> return (SExpr e)) | ||
| ; ( 2 | ||
| , if | ||
| List.length (List.filter (fun (_, (_, ret)) -> ret <> TypeVoid) env.functions) |
There was a problem hiding this comment.
Bad measurement of a list (with non-negative size)
Between 'List.length
(List.filter (fun (, (, ret)) -> ret <> TypeVoid) env.functions)' and '
0'.
| with | ||
| | Ok expr' -> | ||
| let code_str' = expr_to_code_string expr' in | ||
| if code_str = code_str' |
There was a problem hiding this comment.
Executing 'if ... then true' smells bad
| with | ||
| | Ok prog' -> | ||
| let code_str' = program_to_code_string prog' in | ||
| if code_str = code_str' |
There was a problem hiding this comment.
Executing 'if ... then true' smells bad
| Angstrom.parse_string ~consume:Angstrom.Consume.All Parser.parse_ops code_str | ||
| with | ||
| | Ok expr' -> | ||
| if compare_expr_structure expr expr' |
There was a problem hiding this comment.
Executing 'if ... then true' smells bad
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
Signed-off-by: f1i3g3 <dmitrvlkuznetsov@gmail.com>
|
Linter report from 2026-03-16 22:13, for mini language CSharpStrange_Kuznetsov |
Added my version of C# language's subset (which is similar to miniML).
Supported: