Robert Roessler wrote:
I am the author of the OCaml plugin for the Scintilla editing component, and would like to adapt it for Poly/ML (ML97)... while the changes needed are largely obvious (different keywords, changed/added token types, etc), I have two really basic questions:
That sounds really interesting and if you're doing that I'd be happy to provide any help you need.
The main focus for 5.3 is in improving various aspects of the user interface. That has included improving error messages and changing various aspects of printing values. A major change, though, is in providing mechanisms for development environments to hook into Poly/ML in order to be able to provide users with much more information about their programs. I've been working on a short project at Edinburgh University with Lucas Dixon to see if we can get a little way with this. Much of it will have to wait until we have time and money to do it properly but we've managed to get some way with it in the last few months.
Lucas has been working on a jEdit plug-in while I've been working on adding this IDE support to my "MLShell" mini-IDE for Windows. The latter isn't (currently) open-source so I'm not distributing it at the moment but the jEdit plug-in is in the Poly/ML SVN repository. In either of these it's possible to compile some ML source code and then browse the source and ask for the type of an expression or go to the declaration of an identifier. This works even if there are type errors in the ML source code so that it won't fully compile. It just needs to be able to be parsed.
The hooks have been designed to work at two different levels. Part of the aim was to allow Isabelle to have access to this information and in Isabelle the ML code is wrapped within Isabelle code. There is therefore a functional interface available that allows ML code to capture an abstracted view of the parse-tree, navigate over it and extract type and declaration location information. Makarius has been involved in this part of the work.
Support for programming directly in ML is provided through the IDE protocol and this is the way that the jEdit plug-in and MLShell work. The IDE starts a background Poly/ML process that can compile ML code and keeps the last parse-tree. The IDE protocol defined in the documentation allows the IDE to extract information from the parse-tree. The user sees only the source code and navigates on that while the IDE and background Poly/ML process map between positions in the source code and nodes in the parse-tree.
We're not yet at the point of releasing this although much of the code is in SVN so it is possible to try it out. A major issue we're struggling with is exactly what constitutes a "project". For other languages and IDEs there's a clear distinction between compilation and run-time. With ML, though, compilation involves execution. Typically, a project will involve calling "use" on various files but "use" is actually being executed. Creating an ML structure also involves execution.
To answer your specific questions:
- where is a good place to look for an official ML97 grammar? Actually,
I would like to be able to easily distinguish between that and the apparent(?) superset that Poly/ML accepts (I say this because when browsing the [S]ML sources, there seem to be anachronisms present - although this could just be me learning to read ML97 vs OCaml ;) ).
The official definition of Standard ML is "The Definition of Standard ML (Revised)" by Milner, Tofte, Harper and MacQueen. I don't know whether there is a version of the grammar on the net somewhere. As far as possible Poly/ML accepts only the standard grammar although there may be one or two minor extensions. There are a few cases that are very difficult to parse exactly.
- what is/are the preferred file extension(s)? The main ones in OCaml
are [of course] .ml for source and .mli for interface files, but it isn't clear how this plays out for Poly etc...
Frequently ".ML" in upper case is used for ML source although case isn't significant on Windows. ".sml" is also widely used.
Regards, David