package cairn

  1. Overview
  2. Docs

Module Parsing.MakeWithDefaultMessageSource

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

module T : sig ... end
module Lexer : sig ... end

Signature

Sourceval 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.

Sourceval 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.

Sourceval 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.
Sourceval 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.

Sourceval 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.