Commit Graph

648 Commits (ec8203077a47324195d33d65189402e69a2e66dc)

Author SHA1 Message Date
Drup 4f6e4144ff Add signature payloads for extension and attributes. 2015-12-09 14:26:06 +01:00
Gabriel Scherer c6b5a28d77 Merge pull request #320 from gasche/revert-user-defined-indexing-operators
Revert user defined indexing operators
2015-12-06 17:56:40 +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
alainfrisch 110835872c This also reserves the use of '_' as a valid expression (i.e. other
changes to the grammar that would introduce a conflict with it will now
be detected) for possible later use.
2015-12-03 13:42:24 +01:00
alainfrisch 01bf671f33 PR#6865: remove special case for "let _ = expr" structure items.
This form used to produce Pstr_eval instead of Pstr_let.  This would
probably come as a suprise for people matching on the Parsetree (e.g.
for a ppx).  This special case is now removed.

To avoid a (probably harmless) regression in bytecode, the compilation
of "let _ = ..." bindings (including local ones) is optimized to remove
a useless introduction of a variable (which would occupy a stack slot
otherwise).

The source code printer (-dsource) now prints Pstr_eval as ";;expr",
which should always be ok.  One could avoid ";;" at the beginning of
the structure, but since it is allowed, it is probably not worth adding
complexity here.
2015-12-02 23:39:19 +01:00
alainfrisch 6b9d72d532 A new builtin attribute ocaml.deprecated_mutable; can be applied to a record label so as to trigger a Deprecated warning if the field is mutated. 2015-12-02 18:20:24 +01:00
alainfrisch c9a44eef22 Move detection of more builtin attributes to new module. 2015-12-02 15:52:04 +01:00
Alain Frisch 22586504ee Fix EOL convention. 2015-12-02 14:51:59 +01:00
alainfrisch 7ad212045f Add module to deal with 'front-end' built-in attributes. 2015-12-02 14:46:14 +01:00
Jeremie Dimino 07f5fa92a1 Revert "Update printing of custom index operators"
This reverts commit 7a318f1a64.

(This patch was hand-written to keep some refactoring done in the
reverted patch.)
2015-11-30 16:06:30 +01:00
Gabriel Scherer 1552d30d16 Revert "Add a special syntax for index operators"
This reverts commit 16bc43219c.

(Conflict resolution: bytecomp/translcore.ml:prim_makearray was
dead code and has since been removed)
2015-11-29 21:01:30 +01:00
Gabriel Scherer 1b8909d332 Revert "Simplify the use of custom .() and .[]"
This reverts commit 7e47735db8.

(Again, this required manual conflict resolution in parsing/parser.mly,
due to the change in argument label type)
2015-11-29 21:01:29 +01:00
Gabriel Scherer cca2eed653 Revert "Simplify the definition of custom .{} operators"
This reverts commit 4a80e9da11.

(The revert required some manual conflict resolution because of use of
function argument labels in the parser.)
2015-11-29 21:01:27 +01:00
Frederic Bour 9107f14afc Comment [Types] 2015-11-25 17:32:55 +00:00
Xavier Leroy 0c5e862a3e GPR#268: Hexadecimal notation for floating-point numbers
Merge of branch 'hex-float'.

- Add support in byterun/floats.c for conversions between floats and strings in hex notation. We cannot rely on the C standard library here because Microsoft consistently fails at supporting hex notation as standardized in C99. Instead, the conversions are implemented from scratch.
- Add support in the lexer so that hex float literals are recognized in OCaml sources.
- Add support in formats. The ISO C99 format letters for hex floats are %a and %A, but %a is already taken. I chose %h and %H, which are rejected today as bad formats (hence no backward incompatibility) and don't mean anything in C either (h is a modifier, not a format letter).
- Add support in printf. All the trimmings are there in the implementation of %h and %H, including sign modifier and fixed precision.
- Benoit Vaugon contributed support in scanf.

Resolved conflicts:
	boot/ocamlc
	boot/ocamldep
	boot/ocamllex
	parsing/lexer.mll
2015-11-19 10:37:20 +01:00
Damien Doligez 7cb9a80744 simplify .gitignore; remove .ignore files and tools/setignore; adjust tools/check-typo 2015-11-06 16:25:05 +01:00
Jeremie Dimino 6676784f63 PR#6806: Allow type annotations before the "->" in "fun <args> -> <expr>"
Patch by Valentin Gatien-Baron
2015-11-05 10:41:13 +00:00
Jeremie Dimino 26657d5736 PR#6806: Syntactic sugar for type annotations on record fields
Add the following syntactic sugars, in both expressions and patterns:
- { f : typ = x } to mean { f = (x : typ) }
- { f : typ     } to mean { f = (f : typ) }

In expressions, the type annotation can also be a coercion. For
instance: { f :> typ } to mean { f = (f :> typ) }.

Patch by Valentin Gatien-Baron
2015-11-05 10:41:13 +00:00
Leo White bbce6c5768 Put the * back on the doc comments 2015-11-03 12:51:01 +00:00
Jeremie Dimino 7a318f1a64 Update printing of custom index operators 2015-10-28 14:36:10 +00:00
Gabriel Scherer 54e039901e GPR#42: Add simpler functor type syntax
(Leo White)

Add support for simple functor types of the form:

    S -> T

equivalent to:

    functor (_ : S) -> T

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16546 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-25 16:24:47 +00: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
Alain Frisch 923ad0ec47 Remove or comment-out dead code.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16515 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-16 16:08:12 +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
Jérémie Dimino 95802fe702 Accept unboxed, untagged and noalloc prefixed by "ocaml."
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16459 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-06 10:58:27 +00:00
Jérémie Dimino 695a592d48 Support [@@noalloc] on external declarations
This is to replace the "noalloc" annotation.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16454 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-06 10:58:20 +00:00
Jérémie Dimino f78f46bcce Add parsing/Attr_helper
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16451 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-06 10:58:17 +00:00
Pierre Weis bdc8e004de Consistently quoting quote and doublequote into string and character litterals.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16434 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-09-21 17:39:27 +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
Gabriel Scherer c508c47101 colorize error and warning messages, refactor Location
(Simon Cruanes)

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16349 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-08-15 15:57:53 +00:00
Gabriel Scherer 60314e38c5 fix -dsource error on recursive modules
(Hongbo Zhang)

when printing recursive module the old version would print no space
before 'and':
  A : ... = struct
    ...
  endand B : ... = ...

this tiny PR fixes such problem

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16307 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-08-02 13:05:53 +00:00
Gabriel Scherer 235ee2ddef GPR#26: support for "(type a b ..)" as sugar for "(type a) (type b) .."
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16258 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-07-26 19:01:42 +00:00
Xavier Leroy bb86f5b545 Preliminary support for hexadecimal notation for FP numbers.
- Primitives:
     caml_float_of_string  extended to recognize "0x" hexa notation
     caml_hexstring_of_float  new primitive
  We do not assume hex floats are supported by the C standard library.
  Instead, conversions hex string <-> float are implemented manually.
- Printf: hex FP output supported with formats %h / %H
- Scanf: remains to be updated (see TODO in stdlib/scanf.ml)


git-svn-id: http://caml.inria.fr/svn/ocaml/branches/hex-float@16257 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-07-26 09:29:33 +00:00
Alain Frisch 63ba313843 Fix merge issue.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16216 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-07-17 15:48:36 +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
Alain Frisch 7fdba8f533 GPR214: remove duplicate productions in the parser (patch by Jeremy Yallop).
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16213 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-07-17 11:51:17 +00:00
Jérémie Dimino 19c45e683a PR6865: Fix parsing of toplevel [let%foo _ = expr]
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16199 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-07-13 10:47:54 +00:00
Alain Frisch 5b7552b652 Fix bootstrap (broken by ambiguous ocamldoc comments).
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16191 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-06-29 17:04:13 +00:00
Leo White 5c55e4cc08 Attach documentation comments to Parsetree
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16189 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-06-28 13:11:50 +00:00
Jérémie Dimino a90f0e4c63 add 'nonrec' as a possible attribute id
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16188 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-06-24 10:15:08 +00:00
Damien Doligez a2c6ac8110 fix small bug in commit 16075
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16076 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-05-04 19:46:51 +00:00
Damien Doligez ea845ce074 GPR#159: Better locations for structure/signature items
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16075 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-05-04 18:44:11 +00:00
Gabriel Scherer f9ea209cb7 GPR#171: allow custom warning printers / catchers
(Benjamin Canou, review by Damien Doligez)

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16049 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-04-26 21:05:26 +00:00
Gabriel Scherer bbb896f4b1 PR#6816: lexer raise for literal number followed by alphanum
(Hugo Heuzard)

The following were previously accepted and are now (rightly) rejected:
  (fun x y -> x,y) 0O56789;;
  (fun x y z t a b -> x,y,z,t,a,b) 0b0l0l0O10l0O6789l0e2;;

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16003 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-04-12 10:31:14 +00:00
Gabriel Scherer 3376907929 PR#6635: Support M.[], M.(), M.{< >} and M.[| |].
(Jeremy Yallop)

A small follow-up to PR#6054, which added support for the forms

  M.[e1; e2; ... en]
  M.[|e1; e2; ...; en|]
  M.{l1=e1; l2=e2; ... ln=en}
  M.{<e1; e2; ... en>}

This patch adds support for the empty cases:

  M.[]
  M.[||]
  M.()
  M.{<>}

The empty forms aren't particularly useful in themselves, of course,
but the uniformity is convenient.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16002 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-04-12 09:54:41 +00:00
Alain Frisch b567e4d0b4 #6583: custom # operators are left associative. (Cherry-picked from version/4.02, commit 15952.)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15953 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-03-24 13:09:02 +00:00
Jérémie Dimino 050a57649a Fix pretty-printing of extensions in patterns
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15945 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-03-16 18:15:03 +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
Jérémie Dimino 51ba396328 Add rec_flag to type items in the parsetree and typedtree
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15918 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-03-13 11:07:29 +00:00