module Lexing:The run-time library for lexers generated bysig
..end
ocamllex
.type
position = {
|
pos_fname : |
|
pos_lnum : |
|
pos_bol : |
|
pos_cnum : |
position
describes a point in a source file.
pos_fname
is the file name; pos_lnum
is the line number;
pos_bol
is the offset of the beginning of the line (number
of characters between the beginning of the file and the beginning
of the line); pos_cnum
is the offset of the position (number of
characters between the beginning of the file and the position).
See the documentation of type lexbuf
for information about
how the lexing engine will manage positions.
val dummy_pos : position
position
, guaranteed to be different from any
valid position.type
lexbuf = {
|
refill_buff : |
|
mutable lex_buffer : |
|
mutable lex_buffer_len : |
|
mutable lex_abs_pos : |
|
mutable lex_start_pos : |
|
mutable lex_curr_pos : |
|
mutable lex_last_pos : |
|
mutable lex_last_action : |
|
mutable lex_eof_reached : |
|
mutable lex_mem : |
|
mutable lex_start_p : |
|
mutable lex_curr_p : |
Note that the lexing engine will only change the pos_cnum
field
of lex_curr_p
by updating it with the number of characters read
since the start of the lexbuf
. The other fields are copied
without change by the lexing engine. In order to keep them
accurate, they must be initialised before the first use of the
lexbuf, and updated by the relevant lexer actions (i.e. at each
end of line).
val from_channel : Pervasives.in_channel -> lexbuf
Lexing.from_channel inchan
returns a lexer buffer which reads
from the input channel inchan
, at the current reading position.val from_string : string -> lexbuf
val from_function : (string -> int -> int) -> lexbuf
s
and a character
count n
. The function should put n
characters or less in s
,
starting at character number 0, and return the number of characters
provided. A return value of 0 means end of input.lexbuf
, which, in the code generated by
ocamllex
, is bound to the lexer buffer passed to the parsing
function.val lexeme : lexbuf -> string
Lexing.lexeme lexbuf
returns the string matched by
the regular expression.val lexeme_char : lexbuf -> int -> char
Lexing.lexeme_char lexbuf i
returns character number i
in
the matched string.val lexeme_start : lexbuf -> int
Lexing.lexeme_start lexbuf
returns the offset in the
input stream of the first character of the matched string.
The first character of the stream has offset 0.val lexeme_end : lexbuf -> int
Lexing.lexeme_end lexbuf
returns the offset in the input stream
of the character following the last character of the matched
string. The first character of the stream has offset 0.val lexeme_start_p : lexbuf -> position
lexeme_start
, but return a complete position
instead
of an offset.val lexeme_end_p : lexbuf -> position
lexeme_end
, but return a complete position
instead
of an offset.val flush_input : lexbuf -> unit