package archetype

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Archetype.PositionSource

Extension of standard library's positions.

Extended lexing positions

Sourcetype t

Abstract type for pairs of positions in the lexing stream.

Sourcetype position = t
Sourcetype 'a located = {
  1. value : 'a;
  2. position : t;
}

Decoration of a value with a position.

Sourceval value : 'a located -> 'a

value dv returns the raw value that underlies the decorated value dv.

Sourceval position : 'a located -> t

position dv returns the position that decorates the decorated value dv.

Sourceval destruct : 'a located -> 'a * t

destruct dv returns the couple of position and value of a decorated value dv.

Sourceval located : ('a -> 'b) -> 'a located -> 'b

located f x applies f to the value of x.

Sourceval with_pos : t -> 'a -> 'a located

with_pos p v decorates v with a position p.

Sourceval with_cpos : Lexing.lexbuf -> 'a -> 'a located

with_cpos p v decorates v with a lexical position p.

Sourceval with_poss : Lexing.position -> Lexing.position -> 'a -> 'a located

with_poss start stop v decorates v with a position (start, stop).

Sourceval unknown_pos : 'a -> 'a located

unknown_pos x decorates v with an unknown position.

Sourceval dummy : t

This value is used when an object does not come from a particular input location.

Sourceval map : ('a -> 'b) -> 'a located -> 'b located

map f v extends the decoration from v to f v.

Sourceval iter : ('a -> unit) -> 'a located -> unit

iter f dv applies f to the value inside dv.

Sourceval mapd : ('a -> 'b1 * 'b2) -> 'a located -> 'b1 located * 'b2 located

mapd f v extends the decoration from v to both members of the pair f v.

Accessors

Sourceval column : Lexing.position -> int

column p returns the number of characters from the beginning of the line of the Lexing.position p.

Sourceval line : Lexing.position -> int

column p returns the line number of to the Lexing.position p.

Sourceval characters : Lexing.position -> Lexing.position -> int * int

characters p1 p2 returns the character interval between p1 and p2 assuming they are located in the same line.

Sourceval start_of_position : t -> Lexing.position

start_of_position p returns the beginning of a position p.

Sourceval end_of_position : t -> Lexing.position

end_of_position p returns the end of a position p.

Sourceval filename_of_position : t -> string

filename_of_position p returns the filename of a position p.

Position handling

Sourceval join : t -> t -> t

join p1 p2 returns a position that starts where p1 starts and stops where p2 stops.

lex_join l1 l2 returns a position that starts at l1 and stops at l2.

Sourceval string_of_lex_pos : Lexing.position -> string

string_of_lex_pos p returns a string representation for the lexing position p.

Sourceval string_of_pos : t -> string

string_of_pos p returns the standard (Emacs-like) representation of the position p.

Sourceval pos_or_undef : t option -> t

pos_or_undef po is the identity function except if po = None, in that case, it returns undefined_position.

Interaction with the lexer runtime

Sourceval cpos : Lexing.lexbuf -> t

cpos lexbuf returns the current position of the lexer.

Sourceval string_of_cpos : Lexing.lexbuf -> string

string_of_cpos p returns a string representation of the lexer's current position.

Sourceval mk_position : string -> (int * int * int) -> (int * int * int) -> t
OCaml

Innovation. Community. Security.