Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Parse.module_type and Parse.module_expr #10692

Merged
merged 2 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -243,6 +243,9 @@ Working version
- #10678: Expose descriptions in Warnings module
(Leo White, review by Gabriel Scherer and Alain Frisch)

- #10692: Expose Parse.module_type and Parse.module_expr
(Guillaume Petiot, review by Gabriel Scherer)

### Build system:

### Bug fixes:
Expand Down
7,054 changes: 3,567 additions & 3,487 deletions boot/menhir/parser.ml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions boot/menhir/parser.mli
Expand Up @@ -142,6 +142,10 @@ val parse_pattern: (Lexing.lexbuf -> token) -> Lexing.lexbuf -> (Parsetree.patte

val parse_mty_longident: (Lexing.lexbuf -> token) -> Lexing.lexbuf -> (Longident.t)

val parse_module_type: (Lexing.lexbuf -> token) -> Lexing.lexbuf -> (Parsetree.module_type)
gasche marked this conversation as resolved.
Show resolved Hide resolved

val parse_module_expr: (Lexing.lexbuf -> token) -> Lexing.lexbuf -> (Parsetree.module_expr)

val parse_mod_longident: (Lexing.lexbuf -> token) -> Lexing.lexbuf -> (Longident.t)

val parse_mod_ext_longident: (Lexing.lexbuf -> token) -> Lexing.lexbuf -> (Longident.t)
Expand Down Expand Up @@ -181,6 +185,10 @@ module Incremental : sig

val parse_mty_longident: Lexing.position -> (Longident.t) MenhirInterpreter.checkpoint

val parse_module_type: Lexing.position -> (Parsetree.module_type) MenhirInterpreter.checkpoint

val parse_module_expr: Lexing.position -> (Parsetree.module_expr) MenhirInterpreter.checkpoint

val parse_mod_longident: Lexing.position -> (Longident.t) MenhirInterpreter.checkpoint

val parse_mod_ext_longident: Lexing.position -> (Longident.t) MenhirInterpreter.checkpoint
Expand Down
2 changes: 2 additions & 0 deletions parsing/parse.ml
Expand Up @@ -95,6 +95,8 @@ and use_file = wrap Parser.use_file
and core_type = wrap Parser.parse_core_type
and expression = wrap Parser.parse_expression
and pattern = wrap Parser.parse_pattern
let module_type = wrap Parser.parse_module_type
let module_expr = wrap Parser.parse_module_expr

let longident = wrap Parser.parse_any_longident
let val_ident = wrap Parser.parse_val_longident
Expand Down
2 changes: 2 additions & 0 deletions parsing/parse.mli
Expand Up @@ -27,6 +27,8 @@ val use_file : Lexing.lexbuf -> Parsetree.toplevel_phrase list
val core_type : Lexing.lexbuf -> Parsetree.core_type
val expression : Lexing.lexbuf -> Parsetree.expression
val pattern : Lexing.lexbuf -> Parsetree.pattern
val module_type : Lexing.lexbuf -> Parsetree.module_type
val module_expr : Lexing.lexbuf -> Parsetree.module_expr

(** The functions below can be used to parse Longident safely. *)

Expand Down
14 changes: 14 additions & 0 deletions parsing/parser.mly
Expand Up @@ -849,6 +849,10 @@ The precedences must be listed from low to high.
%start use_file /* for the #use directive */
%type <Parsetree.toplevel_phrase list> use_file
/* BEGIN AVOID */
%start parse_module_type
%type <Parsetree.module_type> parse_module_type
%start parse_module_expr
%type <Parsetree.module_expr> parse_module_expr
%start parse_core_type
%type <Parsetree.core_type> parse_core_type
%start parse_expression
Expand Down Expand Up @@ -1198,6 +1202,16 @@ use_file:
;

/* BEGIN AVOID */
parse_module_type:
module_type EOF
{ $1 }
;

parse_module_expr:
module_expr EOF
{ $1 }
;

parse_core_type:
core_type EOF
{ $1 }
Expand Down