Commit Graph

141 Commits (master)

Author SHA1 Message Date
Drup b507e7f235 Add constants to Ast_mapper. 2019-11-13 16:08:41 +01:00
Drup abc53d1a6e Annotate constant literals with the location of their content. 2019-11-13 16:08:40 +01:00
Thomas Refis 8e928caea7
a better representation for modules with no name (#8908) 2019-10-09 14:15:37 +01:00
Leo White acd06f1eff Remove Misc.may_map and similar 2019-05-23 16:27:58 +01:00
David Allsopp 6e84987715 Restore -vmthreads flag as an error (#2312)
This GPR restores -vmthread with an adapted version of the deprecation message as an error message and also keeps the use_vmthreads part of ppx contexts.

* Partially revert #2289
* Convert -vmthread to an error
* Neuter use_vmthreads in ppx context
* Remove Clflags.use_vmthreads
2019-03-13 10:46:30 +01:00
Jérémie Dimino 705054b346 Delete the vmthreads library (#2289)
* Delete the deprecated vmthreads library

It was deprecated in 4.08.

* Remove the byte/native argument of init_path

It is no longer necessary.

* Error out when passing --{enable,disable}-vmthreads to ./configure

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2019-03-11 19:38:16 +01:00
Jeremie Dimino 7e0862a212 Refactor load path management and initial environment
- Add a Load_path module which caches files lookup

- Instead of falling back to the external environment, allow to
  declare in the environment that a module comes from the external
  world. This allows persistent structures to shadows non-persistent
  ones
2019-01-30 16:36:38 +00:00
Leo White 403003cad5 Add support for "let" operators 2018-11-27 13:30:55 +00:00
Runhang Li 97329f30ed Extend `open` to arbritrary module expressions in structures and to
applicative module paths in signatures
2018-11-26 16:20:37 +00:00
Thomas Refis 6805595f57 introduce local substitutions in signatures
type [params] id := type_expr { and [params] id := type_expr }
    module Uid := extended-module-path
2018-11-09 16:43:43 +00:00
Gabriel Scherer e348103ab8 parsetree.{row,object}_field: move attributes in the wrapper record
The concrete syntax only allows attributes on tags/constructors/fields
(Rtag, Otag), not on inherited subtypes (Rinherit, Oinherit); we add
this as new enforced invariant in ast_invariants.
2018-08-20 19:57:47 +02:00
Gabriel Scherer 48b06a44ae ast_{iter,mapper}: always traverse the attributes right after the location
Now that each node that supports attributes also has a location,
we want to make the attributed node's location robustly available
to AST traversal functions.

The best way to do this would be to change the "attributes" traverser
to take the node's location as extra parameter. However, doing this
changes the type of the traverser interface, with a risk of breaking
user code. This may be the right long-term change, but for now
we go with something weaker: we ensure that the attributes of a node
are always traversed right after the node's location, which lets
user track attributed location (if they wish) through a side-effect.
2018-08-20 19:57:47 +02:00
Gabriel Scherer 85785b173a parsetree: make sure that all nodes that store attributes also store a location
Florian Angeletti and myself ran into a problem when trying to use attributes
for ellision of parts of manual example. We wanted to be turn any ast-node
marked with the [@ellipsis] attribute into "..." in the rendering of the
corresponding code block, but for this we need the location of the
attributed node, and it turns out that some constructions supported
attributes without carrying a location:
- Rtag in row_field
- Otag in object_field
- type_exception record
- type_extension record

We added locations in all those positions, guaranteeing the invariant
that all nodes to which attributes can be attached have a precise
position.
2018-08-20 19:57:47 +02:00
Armaël Guéneau 48201e1eeb Trivial refactor: use Format.asprintf instead of manually creating a formatter 2018-08-12 21:38:44 +02:00
Armaël Guéneau c0820e30cb Location: significantly rework the code printing errors and warnings 2018-08-08 17:42:08 +02:00
Hugo Heuzard 8043144494 Add locations to attributes
Changes

fix typo
2018-08-06 13:19:28 +01:00
Gabriel Radanne 1be47bf7ab Just some tbl things. (#1699) 2018-07-23 13:19:41 +01:00
Gabriel Scherer 7c211110da PpxContext: store type-checking related flags
It is a bug of the current PpxContext that -rectypes is not passed as
part of the context: any ppx extension that would like to be able to
load .cmi files in the same initial environment as the user code would
break because loading -rectypes-using .cmi is disallowed if
Clflags.recursive_types is not set.

(I found this issue while debugging a ppx_import user that compiles
with -rectypes -- https://github.com/ocaml-ppx/ppx_import/pull/25 )

I tried to add all the other Clflags that seem related to
type-checking and might cause a program to not-type-check if they
are not correctly passed:

- recursive_types
- principal
- transparent_modules
- unboxed_types
- unsafe_string
2018-07-20 13:38:24 +02:00
David Allsopp b5d1929e87 Whitespace and overlong line fixes. 2018-06-14 15:15:34 +01:00
Hugo Heuzard 7835cbb9bd Add tests for attributes
fix style
2018-04-09 22:29:46 +01:00
Hugo Heuzard 002815c4bb allow to attach @@ attributes on exceptions 2018-04-09 22:29:46 +01:00
camlspotter 89355a41b6 added -threads and -vmthreads option information to the ppx context (#1336) 2017-09-15 18:14:14 +01:00
Leo White 5cb27d8ebb Merge pull request #792 from sliquister/generalize-destr-subst2
Fixing the limitations on destructive substitutions
2017-09-15 09:29:29 +01:00
Fourchaux 72cfdd56e9 Typos and basic grammar error fixing (#1280) 2017-08-10 11:59:23 +01:00
Valentin Gatien-Baron f29cd5ab6d Support syntax: S with M.N.t := ... 2017-08-01 07:32:08 -04:00
Runhang Li c39b975d43 merge trunk and update test 2017-07-23 09:31:58 +08:00
Alain Frisch fd47ba9649 Support 'let open' in class and class type expressions (#1249)
* Support 'let open' in class and class type expressions.

* Adapt ocamlprof.

* Adapt ocamldoc.

* Add tests.

* Changelog.

* Manual.
2017-07-20 08:17:30 +02:00
Runhang Li 864b3b735e
Merge branch 'trunk' into object-inherit 2017-03-22 22:13:06 -07:00
Mark Li 9dc86f8417
Support inherited field in object type expression.
Also add location on object field label and polymorphic variant tags.
2017-03-22 21:47:34 -07:00
sliquister 356d8a9c0c Changing the display of fatal warnings (#948) 2017-03-08 09:16:01 +00:00
Fabrice Le Fessant a424f0aae1 Add missing locations in the parsetree (#749)
They are not propagated to the typedtree yet.
2016-08-29 16:21:38 +02:00
octachron 96806cf633 GPR#187: local open for patterns
This commits extends the pattern syntax to support local open in
patterns. Four new constructions mirroring the expression constructions
are added

    * `M.(pattern)`
    * `M.[pattern_list]` ⟺ M.([pattern_list])
    * `M.{labeled_pattern_list}` ⟺ M.({label_pattern_list})
    * `M.[| .. |] ⟺ M.( [| .. |] )

At the typing phase, the construction `M.(pattern)` brings all
identifiers defined within M inside the scope and then proceed with the
typing of `pattern`. All others constructions are desugared to the
`M.(..)` construction during parsing.

Questionable implementation details:
* Currently, the local pattern open use the `type_open` function like
the local expression pattern. However, this implies that values defined
inside `M` are also brought to the scope. A specialized
`type_open_for_pattern` would be more efficient.
2016-05-09 09:35:05 -04:00
alainfrisch 502e4f9336 More warnings when compiling the compiler. 2016-03-15 22:46:35 +01:00
alainfrisch 43f90e9f58 Local let exceptions. 2016-03-15 22:02:55 +01:00
Damien Doligez 5401ce8473 Update headers for the new license.
Remains to be done: remove all headers in testsuite/tests.
2016-02-18 16:59:16 +01:00
Drup 6095df954e Rename parsetree constants.
PConst -> Pconst
int -> integer
2016-01-18 00:12:38 +01:00
alainfrisch 713447b9e4 Fix #7098 (loss of ppx context in toplevel after an exception)
When a ppx raised an exception, it was returned as an error "extension node" to
the caller, without including the "ppx context" which includes in particular ppx
cookies.  This was fine when only one ppx was used, since in that case, the
missing context was not restored.

When multiple ppx are chained, however, the second ppx sees the result of the
first one, and it it does not contains a context, an empty one is created and
returned to the caller, which has the effect of destroying the context for the
next invocation of ppxs.

The current fix is to ensure that when a "error extension node" is returned, the
context is correctly added to it.  In addition to fixing the reported bug, it also
allow ppx to update their cookies before raising an exception, which can be
useful.
2015-12-17 14:59:33 +01:00
Drup 4f6e4144ff Add signature payloads for extension and attributes. 2015-12-09 14:26:06 +01:00
Hugo Heuzard 9eca3e4519 Parse arbitrary precision integers ..
.. and allow any letter in [g-zG-Z] as modifier (previously 'l','L','n')
Also allow modifier for floats
This give more freedom to ppx rewritters (what about a ppx for zarith)

Checks are performed when translating from Parsetree to Typedtree.
Invalid_literal is raised if the modifier is not recognized ([lLn]?)
Integer_overflow is raised as before.

Lexer: use g-zG-Z for integer literal modifier

Lexer: Allow modifier on float

Clean wrt previous commits

Lexer: use named substring

Cleanup

typo

doc

fix after rebase

rebase on  trunk

Update typecore.ml

Fix printast.ml
2015-12-03 17:20:48 +01:00
Jacques Garrigue a335b18a45 merge branches/gadt-warnings
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16532 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-23 08:33:44 +00:00
Jacques Garrigue e34f40ad87 switch to 'pat -> .' and add P/Texp_unreachable
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadt-warnings@16507 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-16 00:13:40 +00:00
Jacques Garrigue a09fb037ac add refuted cases, syntax is 'pat -> _'
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadt-warnings@16500 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-15 01:55:52 +00:00
Damien Doligez b860d63145 whitespace cleanup, cut long lines, add some missing headers
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16415 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-09-11 11:58:31 +00:00
Damien Doligez 860c670848 merge branch 4.02 from 4.02.1 (rev 15540) to a few fixes after 4.02.2 (rev 16205)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16214 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-07-17 14:31:05 +00:00
Jérémie Dimino 7ae6f92e5d Add the "nonrec" keyword and allow it on type
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15919 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-03-13 11:07:57 +00:00
Gabriel Scherer e88e2bb744 remove unnecessary Obj.magic (Grégoire Henry)
From: Gabriel Scherer <gabriel.scherer@gmail.com>

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15664 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-12-13 22:35:55 +00:00
Alain Frisch e3ad818fb5 Reintegrate-merge constructors_with_record5 branch.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15556 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-10-14 15:51:30 +00:00
Alain Frisch 44c2066055 #5904: improve support for ppx in the toplevel by allowing ppx processors to keep information across calls (through the use of persistent cookies). Also change Ast_mapper.register so that the function that creates the mapper from arguments is executed once the context has been restored.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15314 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-09-23 14:54:01 +00:00
Alain Frisch 047e09748c Cherry-pick 15062,15063,15064 from 4.02 (#6497).
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15068 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-08-07 09:46:34 +00:00
Alain Frisch cc9cbfc755 Cherry pick commit 14900 from 4.02 (fix some whitespace and add a few copyright headers), only the in parsing/ subdirectory (it creates conflicts elsewhere).
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15067 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-08-07 09:44:18 +00:00