[Home] Module Microsoft.FSharp.MLLib.Lexing


Lexing: ML-like lexing support This file maintains rough compatibility for lexbuffers used by some ML laxer generators. The lexbuf carries an associated pair of positions. Beware that only the "cnum" (absolute character number) field is automatically updated as each lexeme is matched. Upon each successful match the prior end position is transferred to be the start position and a new start position is allocated with an updated pos_cnum field.

Types

TypeDescription
type lexbuf The type "lexbuf" is opaque, but has an internal position information field that can be updated using "lexbuf_set_curr_p", for example if you wish to update the other fields in that position data before or during lexing. You will need to do this if you wish to maintain accurate line-count information. If you do this and wish to maintain strict cross-compiling compatibility with other langauges you may need code to conditionally use lexbuf_set_curr_p when compiling F# code. Note: an abbreviation for (position,byte) LexBuffer
type position Position information stored for lexing tokens

Values

ValueDescription
val flush_input : lexbuf -> unit
Remove all input, though don't discard the except the current lexeme
val from_bytearray : byte [] -> lexbuf
Fuel a lexer from an array of bytes
val from_channel : in_channel -> lexbuf
Fuel a lexer using the given in_channel. The bytes are read using Pervasives.input, which in the case of a TextReader presents the bytes to the lexer using the default encoding (System.Text.Encoding.Default)
val from_function : (byte [] -> int -> int) -> lexbuf
Fuel a lexer from function that fills an array of bytes up to the given length, returning the number of bytes filled.
val from_stream_reader : StreamReader -> lexbuf
Fuel a lexer using the given StreamReader.
val from_string : string -> lexbuf
Fuel a lexer from a string, converted to ascii using [[System.Text.Encoding.ASCII.GetBytes]]
val from_text_reader : #Encoding -> TextReader -> lexbuf
Fuel a lexer using the given TextReader (e.g. System.Console.In), presenting the Unicode bytes read off the stream to the lexer in the given encoding (e.g. System.Text.Encoding.UTF8)
val lexbuf_curr_p : lexbuf -> position
same as lexeme_start_p
val lexbuf_set_curr_p : lexbuf -> position -> unit
val lexeme : lexbuf -> string
Return the matched string
val lexeme_char : lexbuf -> int -> char
Return a character from the matched string
val lexeme_end : lexbuf -> int
Return absolute positions into the entire stream of characters
val lexeme_end_p : lexbuf -> position
Return the positions stored in the lexbuf for the matched string
val lexeme_start : lexbuf -> int
Return absolute positions into the entire stream of characters
val lexeme_start_p : lexbuf -> position
Return the positions stored in the lexbuf for the matched string

See Also

Microsoft.FSharp.MLLib


Documentation for assembly mllib, version 1.1.10.1, generated using F# version 1.1.10.1