Skip to content
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

Closed
brianhuffman opened this issue Jul 28, 2020 · 4 comments · Fixed by #904
Closed

Comments at the REPL #838

brianhuffman opened this issue Jul 28, 2020 · 4 comments · Fixed by #904
Assignees
Labels
command-line-repl Related to Cryptol's text-based UI feature request Asking for new or improved functionality
Milestone

Comments

@brianhuffman
Copy link
Contributor

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.

GHCi, version 8.8.3: https://www.haskell.org/ghc/  :? for help
Loaded package environment from /Users/huffman/.ghc/x86_64-darwin-8.8.3/environments/default
Prelude>
Prelude> -- comment
Prelude> {- comment -}
Prelude>

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:

┏━╸┏━┓╻ ╻┏━┓╺┳╸┏━┓╻
┃  ┣┳┛┗┳┛┣━┛ ┃ ┃ ┃┃
┗━╸╹┗╸ ╹ ╹   ╹ ┗━┛┗━╸
version 2.9.0 (a28e7b9, modified)
https://cryptol.net  :? for help

Loading module Cryptol
Cryptol>
Cryptol> // comment

Parse error at <interactive>:3:0,
  unexpected: end of file
Cryptol> /* comment */

Parse error at <interactive>:3:0,
  unexpected: end of file
Cryptol>

It might be nice to support this; then I'd be able to put comments in .icry files, for example.

@robdockins robdockins added command-line-repl Related to Cryptol's text-based UI feature request Asking for new or improved functionality low-hanging fruit For issues that should be easy to fix labels Jul 29, 2020
@yav
Copy link
Member

yav commented Jul 29, 2020

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.

@brianhuffman
Copy link
Contributor Author

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 Enter on a blank line. How does that work?

@yav
Copy link
Member

yav commented Jul 29, 2020

We just check if all isSpace before processing the command.

@yav yav removed the low-hanging fruit For issues that should be easy to fix label Sep 17, 2020
@atomb atomb added this to the 2.10.0 milestone Sep 22, 2020
@brianhuffman brianhuffman self-assigned this Sep 22, 2020
@brianhuffman
Copy link
Contributor Author

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.

brianhuffman pushed a commit that referenced this issue Sep 23, 2020
brianhuffman pushed a commit that referenced this issue Sep 23, 2020
@brianhuffman brianhuffman mentioned this issue Sep 23, 2020
brianhuffman pushed a commit that referenced this issue Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command-line-repl Related to Cryptol's text-based UI feature request Asking for new or improved functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants