Is there a way to export more things when I generate a parser with menhir?

廉价感情. 提交于 2020-01-06 03:39:07

问题


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.

来源:https://stackoverflow.com/questions/38514226/is-there-a-way-to-export-more-things-when-i-generate-a-parser-with-menhir

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!