Commit Graph

17970 Commits (70efc8555ab42427807b5351859653e1fe37414a)

Author SHA1 Message Date
François Pottier 8c73e4bb29 Eliminate the duplication between `constructor_declaration` and
`bar_constructor_declaration`. The trick is to parameterize
`constructor_declaration` with an `opening` which can be
instantiated either with `epsilon` or with `BAR`. I am quite
proud of this one!
2018-11-20 12:28:18 +01:00
François Pottier a4419a8f87 New entry `make interpret-menhir`, to help understand and debug the parser. 2018-11-20 12:28:18 +01:00
François Pottier fe0b3f3dfb In `Makefile.menhir`, request the production of `parser.automaton`. 2018-11-20 12:28:18 +01:00
François Pottier a6000fbf48 Inline `type_variable` and `anonymous_type_variable` back into
`optional_type_variable`.
2018-11-20 12:28:16 +01:00
François Pottier 0d328a7c83 Changed the definition of `formal_class_parameters` to allow the use
of an anonymous type variable as a formal parameter to a class.
This enlarges the language, and can be considered a bug fix, as
the printer (`ocamlc -i`) could actually produce this form.
Added a test case.
2018-11-20 11:52:47 +01:00
François Pottier a8edab5857 Introduce `anonymous_type_variable`.
Simplify the definition of `optional_type_variable`.
2018-11-20 11:52:47 +01:00
François Pottier 8db0892294 Mark `type_variable` as `%inline`. 2018-11-20 11:52:47 +01:00
François Pottier ea77a2739f Inline `optional_type_parameter_list` at its single use site. 2018-11-20 11:52:47 +01:00
François Pottier f25bc5215d Renamed `class_type_parameters` to `formal_class_parameters`.
Introduced `class_parameters(parameter)` so as to improve sharing
between `formal_class_parameters` and `actual_class_parameters`.
2018-11-20 11:52:47 +01:00
François Pottier 02ac26414c Inline `type_parameter_list` at its single use site in `class_type_parameters`. 2018-11-20 11:52:47 +01:00
François Pottier 6334a7e2f7 Relax the definition of `row_field` by replacing `atomic_type` with
`core_type`. This allows, e.g., removing the parentheses in the
variant type `[ | (foo [@hello]) ]`. This change is somewhat pointless,
but requiring parentheses here was pointless, too.
2018-11-20 11:52:47 +01:00
François Pottier e55707fd13 Remove an inaccurate comment. Add a CONFLICTS file with explanations. 2018-11-20 11:52:47 +01:00
François Pottier e942542311 Comments. 2018-11-20 11:52:47 +01:00
François Pottier 89e70c1b22 Simplified definition of `post_item_attributes`. 2018-11-20 11:52:47 +01:00
François Pottier cd36487fa0 Simplified definition of `attributes`. 2018-11-20 11:52:47 +01:00
François Pottier 60f67fb500 Introduce `alias_type` as an internal name for `core_type_no_attr`,
an external concept (a core type without attributes).
2018-11-20 11:52:47 +01:00
François Pottier 18fc9477ef Change `function_type` to `core_type_no_attr` in the definition
of `core_type_no_attr`. This means that `int as 'a as 'b` is now
accepted as a valid core type, whereas it was previously rejected.
2018-11-20 11:52:47 +01:00
François Pottier 1152ef1c7f New symbol `arg_label`, for improved sharing and clarity. 2018-11-20 11:52:47 +01:00
François Pottier 737e79d8be Change the domain of function types from `function_type` to `tuple_type`.
This reduces the number of conflicts. A `%prec` annotation must be moved.
2018-11-20 11:52:47 +01:00
François Pottier fc5619eb60 Add a new test, which exercises the resolution of a shift/reduce
conflict on the symbol MINUSGREATER.
2018-11-20 11:52:47 +01:00
François Pottier be2d62e3ee `optlabel` does not need to be marked `%inline`. 2018-11-20 11:52:47 +01:00
François Pottier 8c083b3e60 Improve sharing by introducing `optlabel`. 2018-11-20 11:52:47 +01:00
François Pottier 9ee30e8e9e Rename `core_type2` to `function_type`. Add a comment. 2018-11-20 11:52:47 +01:00
François Pottier 886c952e44 Inline away `core_type2_`. 2018-11-20 11:52:47 +01:00
François Pottier fe07c6d3ba Define the auxiliary symbol `extra_rhs`. Inline away `extra_core_type2`. 2018-11-20 11:52:47 +01:00
François Pottier 74307436b1 Rename `atomic_type_or_tuple` to `tuple_type`. Add a comment. 2018-11-20 11:52:47 +01:00
François Pottier 8abc20e64e Changed the definition of `atomic_type_or_tuple`
so as to use `separated_nontrivial_llist`.
As a result, `atomic_type_star_list` is used only in one place
and can be manually inlined into `constructor_arguments`.
2018-11-20 11:52:47 +01:00
François Pottier 814ca1a636 Remove `core_type_comma_list`, which was used in only one place
and therefore can be manually inlined.
2018-11-20 11:52:47 +01:00
François Pottier 78d079db3e Improve sharing by introducing `actual_class_parameters`. 2018-11-20 11:52:47 +01:00
François Pottier dc0029c8fe Reformulate the definition of `actual_type_parameters`
to use `separated_nontrivial_llist`. Although this makes
the automaton slightly larger, it is a higher-level
definition. Added a comment.
2018-11-20 11:52:47 +01:00
François Pottier 5de77f8dc2 Rename `core_type_list` to `atomic_type_star_list`. 2018-11-20 11:52:47 +01:00
François Pottier 8de2d64250 Merged `simple_core_type`and `simple_core_type2`,
and renamed the resulting symbol `atomic_type`.
This is made possible by using a list of *two* or more
core types in the definition of `actual_type_parameters`.
As a result, `inline_core_type_comma_list` is no longer
useful and disappears.
Some directives of the form `%prec below_HASH` must be
moved as a result of this change.
2018-11-20 11:52:47 +01:00
François Pottier 8abe28dbfd Add a test in `tests/parsing` which exercises the resolution of
(some of) the shift/reduce conflicts involving the token HASH.
2018-11-20 11:52:47 +01:00
François Pottier cc85be6e1b Renamed `simple_core_type2` to `atomic_type`. Added a comment. 2018-11-20 11:52:47 +01:00
François Pottier 88c29fb401 Turn `simple_core_type2_` into an anonymous symbol.
This is equivalent to marking it `%inline`, but is more readable.
2018-11-20 11:52:47 +01:00
François Pottier 96883a1af1 Introduce the nonterminal symbol `actual_type_parameters` so as
to improve sharing in the definition of `simple_core_type2_`.
2018-11-20 11:52:47 +01:00
François Pottier 8e99cefb28 Update the definitions of `core_type_comma_list` and
`inline_core_type_comma_list` so as to remove the need
for explicit calls to `List.rev`.
2018-11-20 11:52:47 +01:00
François Pottier b0770b6d5a Add a definition of `inline_separated_nonempty_llist`. 2018-11-20 11:52:47 +01:00
François Pottier de8df5dbb0 Exclude `boot/menhir/parser.{ml,mli}` from the list of source files
used by `make build-all-asts` and related commands.

Indeed, the idea is to check that the ASTs do not change when the parser is
modified -- the parser's source itself, if included, would always produce a
false positive.
2018-11-20 11:52:47 +01:00
François Pottier 83430b0434 Parser: introduce `virtual_with_mutable_flag` and `virtual_with_private_flag`
in order to eliminate a redundancy between productions in two places.
This removes two TODO markers.
2018-11-20 11:52:47 +01:00
François Pottier de4915e715 Parser: remove several uses of `syntax_error()` by explicitly using
`no_override_flag` instead of `override_flag` when this flag is disallowed.
A conflict is avoided by decorating `override_flag` with `%inline`.
2018-11-20 11:52:47 +01:00
François Pottier e987491bcb Make the grammar more precise by explicitly disallowing `NONREC`
inside `str_type_extension` and `sig_type_extension`. This removes
the need for post-hoc checks, and isolates two calls to `not_expecting`.
2018-11-20 11:52:47 +01:00
François Pottier 87883b6f92 Parser: parameterize `let_binding` and `let_bindings` with `EXT`.
`EXT` can be instantiated with either `ext` of `no_ext`.
This allows getting rid of one use of `not_expecting`
in the auxiliary function `class_of_let_bindings`.
This use of `not_expecting` is now clearly isolated
in the definition of `no_ext`.
2018-11-20 11:52:47 +01:00
François Pottier 4db3221aad Inline `ext_attributes` into `let_binding`. 2018-11-20 11:52:47 +01:00
François Pottier de3dcf1e2e Create [make demote-menhir] to undo the effect of [make promote-menhir]. 2018-11-20 11:52:47 +01:00
François Pottier f27c1de1df Parser: A simpler definition of `ext_attributes`.
(Not sure why a complicated definition was used.)
2018-11-20 11:52:47 +01:00
David Allsopp 78590941b9 Convert ephe-c-api tests (GPR#676) to ocamltest 2018-11-18 22:46:28 +00:00
Armaël Guéneau de99636e8a
Merge pull request #2152 from gasche/typedecl-split-fixpoints
typing/typedecl: split and factorize fixpoint computations for variance and immediacy
2018-11-18 18:55:13 +01:00
Gabriel Scherer 7b29c553fd typedecl: refactor variance requirements to present a unified pipable interface 2018-11-18 15:59:34 +01:00
Gabriel Scherer 1128d66c8a typedecl: remove the location from variance requirements
The location can always be reconstructed from `decl.type_loc`. Note
however that variance-computation functions, in particular
`compute_variance_extension` and its callee (`compute_variance_gadt`,
etc.) need to be passed both the requirement and the location, despite
the fact that they also take a `decl` parameter: there are other
use-cases where the location is not the location of the type
declaration -- when processing an extension to an existing type
declaration.
2018-11-18 15:42:14 +01:00