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

Zero-terminated REPL #1311

Merged
merged 2 commits into from
Sep 25, 2024
Merged

Zero-terminated REPL #1311

merged 2 commits into from
Sep 25, 2024

Conversation

digama0
Copy link
Contributor

@digama0 digama0 commented Sep 24, 2024

This adds a new flag --zero to hol, which when enabled in conjunction with --repl causes HOL to use a zero-terminated REPL. This has the following semantics:

  • User commands are separated by \0. All open lexer state is reset between blocks.
  • Response from ML is terminated by \0. (The end of input counts as one additional input terminator, so if the input contains n \0's then the output contains n+1 \0's unless there is an abnormal exit.)
  • As with the usual REPL, ML can begin processing commands as soon as it sees a complete command terminated by ;, but it will not send a \0 until the full block is concluded, and when timing is enabled, the timing will be aggregated over all commands in the block.

This resolves some parsing issues I encountered when writing the VSCode wrapper over the REPL.

@mn200
Copy link
Member

mn200 commented Sep 24, 2024

Nice!

@mn200
Copy link
Member

mn200 commented Sep 24, 2024

This may well turn out to be something that is constantly exercised, making explicit tests unnecessary, but just in case, can you think about putting something into a test directory for the regression machinery to check please?

@digama0
Copy link
Contributor Author

digama0 commented Sep 24, 2024

Sure, although you'll have to walk me through what that entails

@digama0
Copy link
Contributor Author

digama0 commented Sep 24, 2024

(I'm going to start working on the vscode parser for this format shortly, which may uncover more bugs.)

@mn200
Copy link
Member

mn200 commented Sep 25, 2024

For a shell-level thing like this, I guess you could just add a Holmakefile target that runs a specified file into a built --zero REPL and then compares the result of the output with an "expected" file. E.g., in tools/Holmake/tests/quote-filter, we have

all: $(DEPS)
        $(protect $(HOLDIR)/bin/unquote) < input > output
        $(protect $(HOLDIR)/tools/cmp/cmp.exe) output expected-$(ML_SYSNAME)

@mn200 mn200 merged commit 19ebd25 into HOL-Theorem-Prover:develop Sep 25, 2024
4 checks passed
@digama0 digama0 mentioned this pull request Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants