Is there a way to export more things when I genera

2019-08-05 03:44发布

问题:

I'm using menhir to generate a parser and right now, the parser.mli file that it generated from my parser.mly file looks like this:

(* The type of tokens. *)

type token = 
  (* ... huge ADT definition goes here ... *)

(* This exception is raised by the monolithic API functions. *)

exception Error

(* The monolithic API. *)

val start: (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Types.ast

Is there a way to include more stuff in my parser's interface? In particular, I would like to be able to also export the datatype for my AST (which is currently in a separate Types module) and some functions that work with the token datatype (for example, a function to convert them back to strings).

I tried putting some Ocaml code after the %% in parser.mly but while that code shows up in parser.ml none of the functions I declared appear in parser.mli.

标签: ocaml menhir