package fmlib_parse
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
sha256=ceeef0fc034eaf510ef2d8decda4ea500d4855202e39f03132385153d3c0adf7
    
    
  md5=b1c666fde2efc94be7a17d3fa986251e
    
    
  doc/fmlib_parse/Fmlib_parse/Error_reporter/Make/index.html
Module Error_reporter.Make
Generate the error reporter from a failed parser.
The Parser has to be a failed parser i.e. a parser which has ended either with a syntax error or a semantic error.
Parameters
module Parser : FAILED_PARSERSignature
Types
type semantic = Parser.semanticType of the semantic error.
Make an error reporter
Make an error reported for a parser which has failed with a syntax error.
Precondition: Parser.has_failed_syntax p
val make : 
  (semantic -> Position.range) ->
  (semantic -> Fmlib_pretty.Print.doc) ->
  Parser.t ->
  tmake semantic_range semantic_doc p
Generate an error reporter from
semantic_range: Function which computes from a semantic error a range in the source file where the error occurred.semantic_doc: Function which computes from a semantic error a pretty print document.p: The parser which ended in an error state
The functions for semantic errors have to be provided by the user because semantic errors are transparent to the parser. In case the parser cannot end in a semantic error (i.e. no fail combinator has been used), then use make_syntax.
Run the error reporter
In order to run the error reporter some kind of a stream is needed which represents the source code where an error has occurred. The reporter extracts a source snippet which contains the error and marks the error position. After the code snippet it adds an error message describing the error.
val run_on_string : string -> t -> Fmlib_pretty.Print.docrun the reporter on a string which represents the source code.
val run_on_channel : in_channel -> t -> Fmlib_pretty.Print.docrun the reporter on an input channel which represents the source code. Note that the input channel must be positioned at the start.
val run_on_channels : in_channel -> int -> out_channel -> t -> unitrun_on_channels ic width oc r
Run the reporter on an input channel which represents the source code. Note that the input channel must be positioned at the start.
Then write the error report with the text width width to the output channel oc.
Run with inverted control
This type makes the error reporter an instance of Fmlib_std.Interfaces.SINK.
val needs_more : t -> boolDoes the reporter need more characters from the source file?
val document : t -> Fmlib_pretty.Print.docThe document containing a source snippet which contains the marked error and the error message.