kfl / mosml

Moscow ML is a light-weight implementation of Standard ML (SML), a strict functional language widely used in teaching and research.
http://mosml.org
341 stars 42 forks source link

Very preliminary version of parser for .mlb files. #41

Closed const-rs closed 8 years ago

const-rs commented 8 years ago

This is a very preliminary version of the parsers to parse .mlb files.

Currently it can read all .mlb files from MLton, sml-nj and all but 4 files from MLkit distributions and correctly make Parse tree.

Files that break parser contain non-standard keywords.

Parser

kfl commented 8 years ago

From my first review it looks good.

Maybe @melsman have a test-suite for .mlb files used in MLKit that you try your parser on. Because I would like mosml to be compatible with both MLTon and MLKit.

kfl commented 8 years ago

There seem to be some tests at https://github.com/melsman/mlkit/tree/master/test/mlbtest

const-rs commented 8 years ago
  1. I hope, you are not spammed by my commits - this pull request helps me to see, what is done. That's why I pushed so often.
  2. Thanks for tests!
  3. Yes, sure, it should be compatible with MLkit and MLton, which are a bit ahead of documentation. :-)
const-rs commented 8 years ago

Ken, actually we need to discuss the request - it is growing. :-) At some point it should be merged and mosmlb developed further. Do you agree to merge if if I add invocation of mosmlc and relative paths to current state of the program? Or you think that it should be merged only when it is absolutely complete? (i.e. can compile MLkit + MLton?)

Current state - correct parse of all VALID constructions (there are some extensions in MLkit), can substitute path variables, work with quoted paths, read recursively included .mlb files (though does not check if there are cycles).

Besides that I need you or me to update bootstrap versions of MosML compiler tools (src/{mosmlcmp,mosmllnk,mosmldep and etc) - currently present are really old and sometimes bootstrap compiler fails with Size exception (if sources have syntax errors). If I just recompile everything and replace these tools with new version, everything works smooth. Of course double recompilation is necessary - recompile, replace bootstrap by new ones, recompile and again replace.

kfl commented 8 years ago

I'd be perfectly happy to merge mosmlb, once you think it is in a state where it make sense to merge. The biggest thing I see missing is a README.md file with an overview of what is done and what is missing. Once a minimal README file is added I'd be happy to merge.

From my own work on mlb support fo mosml, I don't think that you fully support all features .mlb files without extending mosmlc. The main problem is that allows local hiding of compilation units/structures. That said I think that a version of mosmlb that support basic .mlb files would be a really valuable first step.

Second, updating the bootstrap versions of the compiler tools is a bit more intricate that it seems. It needs to be done on a 32-bit platform, because a compile-time dependency on the platform gets baked into the files. Maybe that's why you get a Size exception. I'll look into it.

const-rs commented 8 years ago

Great!

My target is as complete as possible implementation. But yes, this target requires extending mosmlc.

At first I want to complete mosmlb to the point where it can provide support for basic mlb files - i.e. without transferring information to mosmlc except list of files to compile and name of output file.

I will write TODO and README.md files and check everything above (except test suites - they will make PR less clear to read). Hope to complete it in couple days - this week was extremely busy.

I think it worth splitting this PR into:

  1. Very base implementation - no error/warning report, rudimentary mlb semantics, no test suite (from ML kit).
  2. Test suite integration.
  3. Errors and warnings.
  4. Full or as full as possible mlb features handling.
  5. Corrections to above, small work on compiler annotations.
const-rs commented 8 years ago

I just checked the version of bootstrap mosmlcmp - it is really outdated:

[const@altair mosmlb]$ ../camlrunm ../mosmlcmp -v Moscow ML compiler version 2.10 PRE-RELEASE SHOULD NOT BE DISTRIBUTED (May 2008) Based in part on Caml Light and the ML Kit

const-rs commented 8 years ago

As promised, I've completed MosMLB to some checkpoint, where it can at least compile mosmlb-test (program to run MLB parser unit tests) on my machine. I added README.md file for MosMLB. First milestone - proof-of-concept is reached, so this PR can be merged.

The next target is to add all necessary features as mentioned in README.md. After merging current PR, I would like:

  1. Have updated bootstrap compiler/linker/other tools.
  2. Add sort_uniq function to Listsort module of stdlib (same as Ocaml List.sort_uniq). I will write it in a separate PR.
const-rs commented 8 years ago

Ken, would you please merge this PR. There are already 20 files and 35 commits. The first goal in README.md is reached - mosmlb can compile itself (try ../camlrunm mosmlb mosmlb.mlb).

I have another patch for MosML pending (header for executables should be generated at the build stage, not installation stage, because RPM and DPKG use fake root directory to make a package).

kfl commented 8 years ago

Sorry, the last couple of weeks have been rather busy on my side.

Everything looks fine, I'll merge the PR right away,

Thanks!