hazel
hazel copied to clipboard
Parsing
Adds ability to import text into hazel as a program, as well as exporting the current program to plain text.
Currently is part of the hamburger menu as separate options (could easily be combined). Import errors are shown, but currently are quite rudimentary, only showing what character caused a problem.
A couple commits are still local, for cleanup and additional tests. There is a behavior difference with regard to empty or comment lines, but nothing that impacts correct programs.
ExternalLineBreak was added to Layout.t, but may be better as an Annot (for a future PR). The module naming for the parser and lexer are somewhat confusing, i.e. Parsing.Parser, and Lexing.Lexer. Could use better names.
Is an interesting idea, I shall look into it. My only questions would be on how to display errors resulting in trying to go back to structured, though maybe that'll be taking care of from running the evaluator during edit. Though I do wonder if that would be problematic to run on every character typed.
I'll also have to see how easy it would be to switch the main text box between modes, or do some other method.
You can use the same area in the UI that results are displayed to show errors, since no result is available when parsing fails, and the button to toggle back to structure editing can be disabled when there is a parse error. Don't worry about the performance cost of running the parser on each edit. If that becomes an issue down the line we can look into incremental parsing approaches, but nothing at the scale we're using Hazel should cause an issue. Learn OCaml already parses and pretty prints on every character.
Shouldn't be too difficult GUI wise with the model-view-controller approach. When in text mode, render the text box you already have set up from the pop up in your branch, otherwise render the existing structure editor box.
no longer relevant with the two other PRs.