205 Commits

Author SHA1 Message Date
Gabriel Scherer
19255bce2c split the test file into several testfiles 2020-12-12 12:04:37 +01:00
Gabriel Scherer
6874fb0436 guile compile.scm lib.ml --open Lib main.ml 2020-12-12 11:41:05 +01:00
Gabriel Scherer
1860dc91f8 multifile support: guile compile.scm a.ml b.ml c.ml -o foo.byte
The declarations of each file are placed into a module whose name is
derived from the filename in the standard OCaml way.

In particular, this changes slightly the semantics of single-file
invocations: now foo.ml is interpreted as if its declarations were
wrapped into a Foo module. The observable behavior of program does not
change, of course, as we only observe the side-effects of the
evaluation.

(This should not change the compilation either, as structure items,
even nested, are compiled into globals. I checked that the generated
bytecode programs for hello.ml keeps the same size.)
2020-12-11 21:41:00 +01:00
Gabriel Scherer
c61d94ed0e turn hello.ml into a more convenient test
Now you can run

    make compiler-test

from the root of the repository to run hello.ml, and compare its
output to a version-controlled reference output.

If the output changes for good reasons, you can update the reference
file with

    make compiler-test-promote

Note: it may sound unpleasant to version-control program-generated
outputs, but in fact (as long as those outputs are kept
human-readable) this is an excellent idea for testing: it means that
any change to the testing output will be part of the commits/diffs,
making it easier for reviewers to understand the impact of a change.
2020-12-11 18:42:18 +01:00
Gabriel Scherer
b4b165ed29
Merge pull request #22 from gasche/update-4.07
update the ocaml-src submodule to track the maintenance 4.07 branch
2020-12-11 13:21:09 +01:00
Gabriel Scherer
8d83210804 [minor] move functions around 2020-12-11 13:21:00 +01:00
Gabriel Scherer
456df1d279 lower function declarations 2020-12-11 13:21:00 +01:00
Gabriel Scherer
13f0fd4c5d Makefile: track dependencies to avoid reconfiguring ocaml-src all the time 2020-12-11 13:18:34 +01:00
Gabriel Scherer
eae8c877fe update the ocaml-src submodule to track the maintenance 4.07 branch
Building 4.07 (and 4.08) was broken on recent GCC versions; I just
pushed a commit to the maintenance branch of 4.07 to fix this, so that
I can build on my machine.
2020-12-10 21:28:48 +01:00
Gabriel Scherer
f6039c4315
Merge pull request #20 from Ekdohibs/readme
Add READMEs
2020-12-07 22:08:13 +01:00
Gabriel Scherer
ed5d352242
Merge pull request #19 from Ekdohibs/infix-new
General infix and prefix operators
2020-12-07 22:06:22 +01:00
Nathanaël Courant
a590b6b5ea Add links to OCaml and guile's homepages, add comment about guile being already bootstrapped 2020-12-07 22:00:09 +01:00
Nathanaël Courant
a5a47ba108 Use pair? for condition on pair 2020-12-07 21:46:01 +01:00
Nathanaël Courant
435d3f8755 Use string-index to make symbol lexing more readable, remove unused errorp parameter 2020-12-07 21:44:29 +01:00
Nathanaël Courant
23bd655873 Add comment about the interpreter needing a few more features than the current version of miniml 2020-12-07 21:26:42 +01:00
Nathanaël Courant
e469c51a3a Fix typos in README after review 2020-12-07 21:23:57 +01:00
Nathanaël Courant
b84dff4c94 Add READMEs 2020-12-07 18:07:44 +01:00
Nathanaël Courant
cf4506e656 Change bytecode magic number to match the one in the ocaml version we use 2020-12-07 17:16:08 +01:00
Gabriel Scherer
35ffa040ee allow (Cons _) patterns even if Cons has arity >1 2020-12-07 16:24:37 +01:00
Gabriel Scherer
5c3a9b264f first-class status for wildcard patterns 2020-12-07 16:24:37 +01:00
Gabriel Scherer
9a5f6a091c change the grammar of patterns to accept patterns under constructors... but require variable for compilation 2020-12-07 16:24:37 +01:00
Nathanaël Courant
2617b736cc General infix and prefix operators 2020-12-07 16:07:38 +01:00
Gabriel Scherer
b5bb3c8932
Merge pull request #14 from Ekdohibs/functors
Compilation of functors
2020-12-07 13:31:38 +01:00
Nathanaël Courant
5cb0ed73f3 Add tests for argument of functor 2020-12-07 13:29:28 +01:00
Nathanaël Courant
637eb2c355 miniml: add functors 2020-12-07 12:33:33 +01:00
Gabriel Scherer
2fe9599bc1 environments: weird code factorization 2020-12-07 11:36:43 +01:00
Gabriel Scherer
46ca612508 bindings visibility: bindings-exported-only, bindings-make-local 2020-12-07 11:36:43 +01:00
Gabriel Scherer
9dbc6ac08a bindings-filter-map 2020-12-07 11:36:43 +01:00
Gabriel Scherer
2680aa4ff3 bindings in env: introduce bindings-replace to elide explicit 'Export markers 2020-12-07 11:36:43 +01:00
Gabriel Scherer
1bde4c5d88 environments contain "bindings", export bindings-get
This is a new abstraction/concept in the codebase: the vhashes that
contain visibility information and a definition are called
"environment bindings".

For now there is only an accessor, bindings-get.
2020-12-07 11:36:43 +01:00
Gabriel Scherer
ed364b7ee4 clarify the purpose of (cons #t ...) in primitive declarations 2020-12-07 11:25:08 +01:00
Gabriel Scherer
45e1f17227 clarify the visibility of environment items
Before doing this change, I had no clue what those (cons # ...) would mean,
2020-12-07 11:25:08 +01:00
Gabriel Scherer
7a14982cc2 [minor] pattern-matching in vhash-{map,filter-map} 2020-12-07 11:25:08 +01:00
Gabriel Scherer
0b197cb705
Merge pull request #15 from Ekdohibs/ocamllex
Ocamllex
2020-12-05 16:51:37 +01:00
Julien Lepiller
de8c561c40 Ignore generated interpreter files 2020-12-05 15:33:44 +01:00
Julien Lepiller
eb98434c9f lexer: lex_string: Use buffer directly. 2020-12-05 14:58:08 +01:00
Julien Lepiller
c195c3b83e lexer: try_skip_space_and_comments: Make tail-recursive. 2020-12-05 14:58:04 +01:00
Julien Lepiller
7ff2fb4f6c lexer: Use Char.code '0' instead of magic constant 2020-12-05 14:57:44 +01:00
Julien Lepiller
55d5bce3ae interp: Add missing end 2020-12-05 13:38:40 +01:00
Gabriel Scherer
da11c946dc fix IRebind compilation 2020-12-05 07:21:11 +01:00
Nathanaël Courant
bc1487b12c Add definition for infix :: constructor 2020-12-04 15:15:50 +01:00
Nathanaël Courant
603090e8c3 Use the new infix operators instead of fixed names 2020-12-04 15:15:50 +01:00
Nathanaël Courant
2e0d235ce3 Fix the other conflict 2020-12-04 15:15:50 +01:00
Nathanaël Courant
654f8a7989 Fix lident_ext 2020-12-04 15:15:50 +01:00
Nathanaël Courant
cbfa7ff6a0 Fix conflict with infix operators 2020-12-04 15:15:50 +01:00
Nathanaël Courant
95da29da2f Record construction must use longident_field... but more conflicts 2020-12-04 15:15:50 +01:00
Nathanaël Courant
a037d4071d Initial try for infix operators 2020-12-04 15:15:50 +01:00
Nathanaël Courant
e783d2c8c0 Fix shape of let ... = function at toplevel 2020-12-03 22:27:21 +01:00
Julien Lepiller
a6990cc1fb Add ocamllex bootstrap lexer 2020-12-03 20:00:53 +01:00
Nathanaël Courant
ff6db2bb00 Fix interpreter genfile 2020-12-02 15:15:49 +01:00