package cairn

  1. Overview
  2. Docs

Module type P.parser_loggerSource

Signature of the modules produced by this library. Common to Make and MakeWithDefaultMessage. Contains functions to get a log of the execution of the parser, as long with a graphical explorer of this log.

In most use cases, parse_string and parse_file should be the most useful functions ; parse being useful if you want to generate your own buffer. parse_to_derivation is exposed so that it is possible to get the abstract log of the parser (in case one want to use it without using ParserLog module).

val state_to_lr0_list : int -> string list

Function that associates to a lr1 state number a list of string representing the lr0 items it contains.

val parse_to_derivation : ?strategy:error_strategy -> string -> Lexing.lexbuf -> T.value_parsed option * ParserLog.configuration list * (string * string * string) list

parse_to_derivation text lexbuf parses an input pointed by lexbuf whose content is text. text and lexbuf might be obtained with MenhirLib.LexerUtil. It returns (value,log,errors), where:

  • value is either Some value if the parser produced a semantical value or None.
  • log is a configuration list that represents the execution of the parser (to be used with functions from ParserLog alongside state_to_lr0_list).
  • errors is a list of error messages encountered along the execution, in order to which they appeared. If this list is not empty, value should probably not be trusted. The first string is the position of the error, the second the two tokens between which the error occured, and the last an explanation (from the ParserMessages provided).

The optional argument ?strategy controls which error_strategy is used if an error is encountered. Defaults to Stop.

val parse : ?strategy:error_strategy -> ?interactive:bool -> ?log_file:string -> ?error_file:string -> string -> Lexing.lexbuf -> T.value_parsed option

parse text lexbuf parses an input pointed by lexbuf, whose content is text, computes the log of its derivation, and depending of its optional arguments, can display a terminal user interface allowing to navigate the log of the parser, and save the log and error log into external files. Then returns the parsed value (if no error was encountered, None otherwise).

  • ?strategy controls which error_strategy is used if an error is encountered. Defaults to Stop.
  • ?interactive controls whether the terminal user interface is displayed or not. Defaults to true.
  • if ?log_file is provided, the log of the derivation will be saved in a file of that name.
  • if ?error_file is provided, the error log will be saved in a file of that name.
val parse_string : ?strategy:error_strategy -> ?interactive:bool -> ?log_file:string -> ?error_file:string -> string -> T.value_parsed option

parse_string string parses the string string, and has the same functionalities as parse. It simply wraps the creation of the buffer.

val parse_file : ?strategy:error_strategy -> ?interactive:bool -> ?log_file:string -> ?error_file:string -> string -> T.value_parsed option

parse_file file parses the content of the file file, and has the same functionalities as parse. It simply wraps the creation of the buffer.