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

The format of dune files is not exactly the same as the sexplib format #4

Open
ghost opened this issue Apr 6, 2020 · 8 comments
Open
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Apr 6, 2020

There are a few differences between the format of dune files and the s-expressions parsed by sexplib. As a result, dune-deps cannot parse certain files. For instance, if I call dune-deps on dune itself, I get:

$ dune-deps 
Error: Cannot parse dune file ./test/blackbox-tests/test-cases/dune-ppx-driver-system/driver-tests/dune: exception (Sexplib.Sexp.Parse_error
  ((err_msg "unexpected character: ')'") (text_line 116) (text_char 21)
    (global_offset 2645) (buf_pos 2645)))

Eventually, we will probably extract a small stable library as we did for csexp and pp for parsing dune files. Another idea would be to rely on dune describe, which is meant precisely for this purpose: providing a stable interface for extracting information out of a dune project.

@mjambon mjambon added the bug Something isn't working label Apr 6, 2020
@mjambon
Copy link
Owner

mjambon commented Apr 6, 2020

I had noticed this error while running dune-deps on dune, but I quickly brushed it off, wrongly assuming that it was an intentionally broken test case :-p

The solutions you suggest look promising. Not sure what's best at the moment. To be continued.

@mjambon
Copy link
Owner

mjambon commented Apr 9, 2020

I haven't added support for the real dune syntax, but I added a --exclude or -x option to work around it. :-p

Together with the new -h option, we're getting something which looks usable.

dune

The command to make the image above is:

$ cd dune  # dune git repo
$ dune-deps -h dune -x test | tred | dot -Tpng > dune.png

@ghost
Copy link
Author

ghost commented Apr 14, 2020

Nice :)

BTW, I started working on a small separate library for parsing and editing dune files, in particular so that users can apply automatic transformations to dune files (cf ocaml/dune#3337). It's not yet ready, but if you want to experiment with it, I'm happy to put it up.

@mjambon
Copy link
Owner

mjambon commented Apr 14, 2020

I like the idea of relying on a dune-compatible S-expression library, rather than depending on dune as a whole. For the sake of maintenance, I like that dune-deps doesn't depend on a specific version of dune. I don't mind if certain things don't work perfectly, such as the exclusion of files using (dirs ...).

I'm happy to create a branch for testing the new parsing library. I'd need a public git URL and a build/install command.

@ghost
Copy link
Author

ghost commented Apr 15, 2020

Alright, so I got a first version there: https://github.com/diml/dune-files. make&make install should do. A good entry point is Dune_files.Parser.load.

The name is not great BTW, but I don't know how to call it. If you have some ideas, I'm interested :)

@mjambon
Copy link
Owner

mjambon commented Apr 15, 2020

Looking good so far, thank you! I'll let you know how it goes.

@mjambon
Copy link
Owner

mjambon commented Apr 16, 2020

I created a parsing branch which works (as of commit ef75f53). You can try it out if you want. make && make test && make install should work if you have dune-files installed.

Regarding the name: dune-file sounds better to me than the plural version. I'm not great with names in general, though.

I also have a couple questions which I'll post on the dune-files repo.

@ghost
Copy link
Author

ghost commented Apr 16, 2020

dune-file seems better indeed, I'll remove the s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant