Support camlp5 by using Toploop.parse_toplevel_phrase instead of Parse.toplevel_phrase - #486
Merged
Merged
Conversation
Octachron
reviewed
Jun 23, 2025
| Error ([], "Unknown parsing error (please report it to the utop project): " ^ Printexc.to_string exn) | ||
|
|
||
| let parse_toplevel_phrase_default = parse_default Parse.toplevel_phrase | ||
| let parse_toplevel_phrase_default = fun str -> parse_default !Toploop.parse_toplevel_phrase str |
Member
There was a problem hiding this comment.
This is a bit of unusual way to write
let parse_toplevel_phrase_default str = ...Otherwise the change is correct. However, we probably also want parse_use_file to use Toploop.parse_use_file.
Don't hesitate to tell me if you don't wish to come back to this PR. Also without answer, I am planning to merge the current state, and fix those minor quibbles subsequently.
Contributor
Author
There was a problem hiding this comment.
Thanks for reviewing this patch! Yes, please feel free fix as you wish or even merge it. :)
Octachron
approved these changes
Jun 24, 2025
Octachron
added a commit
to Octachron/opam-repository
that referenced
this pull request
Jul 25, 2025
CHANGES: * Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro) * restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon) * support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune) * utop configuration and state files (utoprc, utop-history) are now always in the relevant utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy). * fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov) * implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron
added a commit
to Octachron/opam-repository
that referenced
this pull request
Jul 25, 2025
CHANGES: * Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro) * restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon) * support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune) * utop configuration and state files (utoprc, utop-history) are now always in the relevant utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy). * fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov) * implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron
added a commit
to Octachron/opam-repository
that referenced
this pull request
Jul 25, 2025
CHANGES: * Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro) * restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon) * support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune) * utop configuration and state files (utoprc, utop-history) are now always in the relevant utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy). * fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov) * implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron
added a commit
to Octachron/opam-repository
that referenced
this pull request
Jul 25, 2025
CHANGES: * Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro) * restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon) * support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune) * utop configuration and state files (utoprc, utop-history) are now always in the relevant utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy). * fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov) * implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron
added a commit
to Octachron/opam-repository
that referenced
this pull request
Jul 25, 2025
CHANGES: * Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro) * restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon) * support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune) * utop configuration and state files (utoprc, utop-history) are now always in the relevant utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy). * fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov) * implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron
added a commit
to Octachron/opam-repository
that referenced
this pull request
Jul 25, 2025
CHANGES: * Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro) * restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon) * support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune) * utop configuration and state files (utoprc, utop-history) are now always in the relevant utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy). * fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov) * implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This resolves issue #485 (and the equivalent issue discussed in this thread) by fixing the definition of
parse_toplevel_phrase_defaultofUTopto use!Toploop.parse_toplevel_phraseinstead ofParse.toplevel_phrase.Note that
!Toploop.parse_toplevel_phraseis equal toParse.toplevel_phrasewhen utop was just initiated: https://github.com/ocaml/ocaml/blob/trunk/toplevel/topcommon.ml#L29However, a user may add its preprocessor to
Toploop.parse_toplevel_phraselater using camlp5, making!Toploop.parse_toplevel_phraseandParse.toplevel_phraseunequal.This patch simply replaces
Parse.toplevel_phrasewith!Toploop.parse_toplevel_phraseso that the preprocessor can do its work.