Commit Graph

199 Commits (master)

Author SHA1 Message Date
Gabriel Scherer 89d6a2094b change or-pattern printing to use spaces instead of cuts
(A p1 | B p2 | C p3) instead of (A p1|B p2|C p3)
2020-11-03 22:17:16 +01:00
Gabriel Scherer bdcd9baa03 fix -dsource printing of the pattern (A as x | (B as x))
fixes #9999
2020-11-03 22:17:16 +01:00
Leo White 44fff5c92a Add ppx-only unary operators 2020-09-18 10:33:16 +01:00
Chet Murthy 0d46b5206d redo: This little patch fixes the pretty-printing of "rebind" extension-constructors (and also rebind exceptions) so that it matches the parser. With tests. a rebind extension like
type t  += A = M.A [@a]
was pretty-printed as

type t += A[@a] = M.A
[obviously wrong, also not accepted by parser]

With tests for extension-constructors and exceptions.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch pr-extension-constructor-rebind-pprint-4.11
# Changes to be committed:
#	modified:   Changes
#	modified:   parsing/pprintast.ml
#	modified:   testsuite/tests/parsetree/source.ml
#
# Untracked files:
#	Changes.orig
#	parsing/pprintast.ml.orig
#	testsuite/tests/parsetree/source.ml.orig
#	testsuite/tests/parsetree/source.ml.rej
#
2020-09-10 11:09:06 -07:00
Chet Murthy e2ec81fe56 re-do of print polyvariants that start with a core_type,closed, not low with leading bar ("|").
a type "[ | w ]" must be printed with the "|", or it won't be
reparseable.

with tests, Changes entry.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch pr-polyvariant-pprint
# Changes to be committed:
#	modified:   Changes
#	modified:   parsing/parsetree.mli
#	modified:   parsing/pprintast.ml
#	modified:   testsuite/tests/parsetree/source.ml
#
# Untracked files:
#	Changes.orig
#	parsing/pprintast.ml.orig
#	testsuite/tests/parsetree/source.ml.orig
#	testsuite/tests/parsetree/source.ml.rej
#
2020-09-09 13:37:36 -07:00
Matthew Ryan dd7ddf9e71
Fix printing of bindings with polymorphic type annotations and attributes (#9778) 2020-07-20 06:10:13 +02:00
Jacques Garrigue 603506aa34
Add injectivity annotations (#9500) 2020-06-15 13:51:50 +02: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
Damien Doligez 454ee52984 Fix #8789 2019-10-04 15:25:26 +02:00
Leo White acd06f1eff Remove Misc.may_map and similar 2019-05-23 16:27:58 +01:00
octachron e7c72ed709 multi-indices for extended indexing operators 2019-05-13 15:26:49 +02:00
Nicolás Ojeda Bär 6bf02e0477 Pprintast: add parentheses around (lazy ...) pattern 2019-04-10 17:28:27 +02:00
Nicolás Ojeda Bär fdd015dcdc Pprintast: add parenthesis when printing Pexp_newtype 2019-04-10 17:28:27 +02: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
alainfrisch 0d968e357b Move variable printer to Pprintast
- The code responsible for printing Syntaxerr errors is moved to the
  Parse module (so that it can depend on the variable printer in
  Pprintast).

- Pprintast becomes a dependency for a few tools that link some
  compiler modules in an ad hoc way (they would better be implemented
  in terms of compiler-libs).
2018-11-06 13:12:54 +01:00
alainfrisch 74b24580ca Fix printing of type variables with a quote on 2nd character
Type variables whose name has a single quote as the second character
(such as ' a' or ' a'b) need to be printed with a whitespace after the
initial quote symbol, in order not to be confused with a character
literal.
2018-11-06 13:12:54 +01:00
Hugo Heuzard 0814a7261f The parser keeps previous location when relocating ast node 2018-09-06 16:12:00 +01:00
Gabriel Scherer a62ac34936 Pprintast: protect against empty strings in the AST 2018-08-23 21:09:48 +02: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 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
Hugo Heuzard 8043144494 Add locations to attributes
Changes

fix typo
2018-08-06 13:19:28 +01:00
Hugo Heuzard c4dd1e67b5 Add locations to toplevel directives 2018-08-06 11:06:30 +01:00
David Allsopp b5d1929e87 Whitespace and overlong line fixes. 2018-06-14 15:15:34 +01:00
Pieter Goetschalckx 5633c84644 Fix printing of functor types 2018-05-29 10:52:18 +02:00
Hugo Heuzard 002815c4bb allow to attach @@ attributes on exceptions 2018-04-09 22:29:46 +01:00
objmagic 0993cd9ba9 Support empty variants (#1546)
* Allow empty variants.
* Update manual and ocamldoc.
2018-03-06 10:48:16 +09:00
octachron 28e53d1305 Add support for qualified indexing operators
aka `x.Module.Path.!(y)` and friends
2017-09-16 23:05:35 +02:00
Florian Angeletti 201ee17fe0 Extended indexing operators (#1064)
* Extended indexing operators

This commit adds extended indexing operators to the parser.
For instance,

```
let (.%()) p (x,y) = p.( x ).( y )
;; p.%(0,0)

```
Extended indexing operators name starts with a leading
dot "." followed by an operator symbol, except "." or "<"
and a sequence of any operators and must be closes with a
couple of enclosing parentheses ( i.e. "()", "[]", "{}" )
and then an optional assignment operator "<-":

  * '.' dotsymbolchar symbolchar* '(' ')' ['<-']
  * '.' dotsymbolchar symbolchar* '[' ']' ['<-']
  * '.' dotsymbolchar symbolchar* '{' '}' ['<-']

Similarly, expressions of the form

* expr_1 '.' dotsymbolchar symbolchar* '(' expr_2 ')'
* expr_1 '.' dotsymbolchar symbolchar* '[' expr_2 ']'
* expr_1 '.' dotsymbolchar symbolchar* '{' expr_2 '}'

and

* expr_1 '.' dotsymbolchar symbolchar* '(' expr_2 ')' '<-' expr_3
* expr_1 '.' dotsymbolchar symbolchar* '[' expr_2 ']' '<-' expr_3
* expr_1 '.' dotsymbolchar symbolchar* '{' expr_2 '}' '<-' expr_3

are desugared to

* ('.' dotsymbolchar symbolchar* '(' ')' ) expr_1 expr_2
* ('.' dotsymbolchar symbolchar* '[' ']' ) expr_1 expr_2
* ('.' dotsymbolchar symbolchar* '{' '}' ) expr_1 expr_2

and

* ('.' dotsymbolchar symbolchar* '(' ')' '<-' ) expr_1 expr_2 expr_3
* ('.' dotsymbolchar symbolchar* '[' ']' ) expr_1 expr_2 expr_3
* ('.' dotsymbolchar symbolchar* '{' '}' '<-' ) expr_1 expr_2 expr_3
2017-09-15 18:47:05 +02: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
Florian Angeletti 7d671fc1d1 M.(::) syntax and printing exotic lists in the toplevel. (#1247) 2017-08-11 10:10:39 +01:00
Fourchaux 72cfdd56e9 Typos and basic grammar error fixing (#1280) 2017-08-10 11:59:23 +01:00
Valentin Gatien-Baron ff05023fde Support syntax: S with module M.N := .. 2017-08-01 07:40:01 -04: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
Alain Frisch 61e262ff92 Fix pprintast for infix operators starting with #. 2017-07-13 17:24:43 +02:00
Ethan Aubin 0439c58cd8 Pretty-printing formatting cleanup in pprintast 2017-06-12 19:55:40 -04:00
Runhang Li bc32e7a52d
Merge branch 'trunk' into object-inherit 2017-05-22 16:32:24 -07:00
alainfrisch d26c29851c More fixes for PR#7506. 2017-04-10 18:22:25 +02:00
alainfrisch 73227bad1a Fix PR#7506: pprintast ignores attributes in tails of a list 2017-04-10 15:05:26 +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
Jacques Garrigue c15ad73e56 Fix pprintast.ml after fixing PR#7344 2017-03-15 12:13:24 +09:00
Jeremie Dimino f936036fdc MPR#7466: fix two bugs in pprintast.ml 2017-02-01 12:15:39 +00:00
Runhang Li 6f51424a9b
Fix corner case GADT exp bug. 2016-11-15 09:08:16 -08:00
Runhang Li 11f31fb999
Fix pprintast bug in ``Pexp_poly``. 2016-11-15 09:08:09 -08: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