package cairn

  1. Overview
  2. Docs

Same as Make, but provides defaults error messages of the form "Error on state x" where x is the state where the parser encountered the message. Useful if you do not want to generate messages with menhir (yet).

Parameters

Signature

module Parser = Parser
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 : string -> Lexing.lexbuf -> Parser.value_parsed option * ParserLog.configuration list * (string * string * string) list

parse 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).
val parse_interactive : string -> Lexing.lexbuf -> Parser.value_parsed option

parse_interactive text lexbuf parses an input pointed by lexbuf, whose content is text. Displays a terminal user interface allowing to navigate the log of the parser. Then returns the parsed value (if no error was encountered, None otherwise).

val parse_log : string -> Lexing.lexbuf -> string -> string -> Parser.value_parsed option

parse_log text lexbuf log_file error_file parses an input pointed by lexbuf, whose content is text. Writes a log of the parser execution in the file of name log_file and an error log in the file of name error_file. Returns the parsed value (if no error was encountered, None otherwise)

val parse_interactive_or_log : string -> Lexing.lexbuf -> bool -> string option -> string option -> Parser.value_parsed option

parse_log text lexbuf interactive log_file error_file parses an input pointed by lexbuf, whose content is text. Displays a terminal user interface allowing to navigate the log of the parser if interactive is true. Writes a log of the parser execution in the file of name log_file if it is not None and an error log in the file of name error_file if it is not None. Returns the parsed value (if no error was encountered, None otherwise)

OCaml

Innovation. Community. Security.