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

Support BER MetaOCaml N111 (in Unix) #1602

Closed
wants to merge 1 commit into from
Closed

Conversation

moatom
Copy link

@moatom moatom commented Feb 13, 2021

This PR is for supporting BER MetaOCaml N111, which is OCaml 4.11.1 extended to support meta-programming (see http://okmij.org/ftp/ML/MetaOCaml.html). Because MetaOCaml adds >., .~, and .< to original OCaml syntax, it adds GREATERDOT, DOTTILDE, and DOTLESS to token.

I tested it but tools/test_branch.sh ber-n111 did't work, of course because HEAD was not buildable in MetaOCaml.
The test by make test worked fine :-)

@hhugo
Copy link
Collaborator

hhugo commented Feb 13, 2021

I'm surprised this is enough. Don't you want to print theses new tokens back ?

@moatom
Copy link
Author

moatom commented Feb 13, 2021

Hi!

Don't you want to print theses new tokens back ?

Are you mentioning about OCamlFormat's changing quoting syntax sugars to attributes representations (e.g. .<1>. -> 1[@metaocaml.bracket]) ? Yes, I do. But I don't know how to do it.

@moatom
Copy link
Author

moatom commented Feb 14, 2021

Although I am not familiar with the entire structure of OCamlFormat, I think Printast.expression's difference is related to this problem.

@hhugo
Copy link
Collaborator

hhugo commented Feb 14, 2021

A special case will need to be added early in https://github.com/ocaml-ppx/ocamlformat/blob/master/lib/Fmt_ast.ml#L1553.
similar to what is done in metaocaml.
Note that Metaocaml uses attributes to encode theses new constructs. It is not ideal as it makes attributes order dependent, see discussion in ocaml/ocaml#10131

@craigfe
Copy link
Contributor

craigfe commented Feb 14, 2021

You may be interested in the corresponding issue for BER MetaOCaml support in OCamlFormat, and this patch that provides a minimal implementation with the current use of attributes.

@hhugo
Copy link
Collaborator

hhugo commented Feb 14, 2021

You may be interested in the corresponding issue for BER MetaOCaml support in OCamlFormat, and this patch that provides a minimal implementation with the current use of attributes.

You may be interested in the corresponding issue for BER MetaOCaml support in OCamlFormat, and this patch that provides a minimal implementation with the current use of attributes.

Nice
Note that your patch doesn't not care about the order of attributes. I think it will make both .< .~x >. and .~(.<x>.) format the same

@craigfe
Copy link
Contributor

craigfe commented Feb 14, 2021

Indeed, thanks.

For what it's worth, I agree with your comments on the corresponding OCaml PR that extension points would be a better representation here & think it's worth waiting a little bit on the OCamlformat side until that question is resolved upstream.

@moatom
Copy link
Author

moatom commented Feb 14, 2021

You may be interested in the corresponding issue for BER MetaOCaml support in OCamlFormat, and this patch that provides a minimal implementation with the current use of attributes.

Thanks! It was very easy to understand.

think it's worth waiting a little bit on the OCamlformat side until that question is resolved upstream.

I roughly understand the current situation. I think so, personally.

@moatom moatom closed this Feb 14, 2021
@hhugo
Copy link
Collaborator

hhugo commented Nov 26, 2024

metaocaml support added in #2630

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.

4 participants