-
Notifications
You must be signed in to change notification settings - Fork 126
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
Comments at the REPL #838
Comments
The issue here is that if we are trying to parse an expression, and a comment is not a valid expression. I guess we could add a top-level "comment" production to the parser (which would be just empty), and first try to use that, and only if it fails we parse an expression. Or, perhaps we could first run the lexer, inspect the tokens, and based on the decide what parser to run, which could help with completion. Neither seems very nice. I wonder if we may want to think more carefully about the syntax of the language used at the REPL and write a proper parser for it? We've talked about this in the past, and I think at one point SAW was supposed to be that language, but clearly that went into a different direction. To be clear, I am not suggesting we change what the language looks like (although obviously we can make adjustments), but maybe how we implement it. |
Well, a blank line is not a valid expression either, and yet somehow we manage not to report a parse error if the user just presses |
We just check if |
We should be able to implement this easily by adding a new parser production for "optional expression". Then the lexer can take care of removing the comment. We can then also remove the special-case code that exists now for checking whether a line contains only whitespace. |
In
ghci
, the interpreter doesn't complain if I enter an empty line. It also doesn't complain if I enter a line containing only a comment.In
cryptol
, the interpreter is fine with completely empty lines, or lines containing only spaces. However, it gives a parse error if I enter a line with only a comment:It might be nice to support this; then I'd be able to put comments in
.icry
files, for example.The text was updated successfully, but these errors were encountered: