//========================================================================== // LexBuffers are for use with automatically generated lexical analyzers, // in particular those produced by 'fslex'. // // (c) Microsoft Corporation 2005-2008. //=========================================================================== #if INTERNALIZED_POWER_PACK namespace Internal.Utilities.Text.Lexing #else namespace Microsoft.FSharp.Text.Lexing #endif open System.Collections.Generic open Microsoft.FSharp.Core open Microsoft.FSharp.Control /// Position information stored for lexing tokens type Position = { pos_fname: string; pos_lnum: int; pos_bol: int; pos_cnum: int; } /// The file name associated with the input stream. member FileName : string /// The line number in the input stream, assuming fresh positions have been updated /// using AsNewLinePos() and by modifying the EndPos property of the LexBuffer. member Line : int [] member Char : int /// The character number in the input stream member AbsoluteOffset : int /// Return absolute offset of the start of the line marked by the position member StartOfLineAbsoluteOffset : int /// Return the column number marked by the position, i.e. the difference between the AbsoluteOffset and the StartOfLineAbsoluteOffset member Column : int // Given a position just beyond the end of a line, return a position at the start of the next line member NextLine : Position /// Given a position at the start of a token of length n, return a position just beyond the end of the token member EndOfToken: n:int -> Position /// Gives a position shifted by specified number of characters member ShiftColumnBy: by:int -> Position [] member AsNewLinePos : unit -> Position /// Get an arbitrary position, with the empty string as filename, and static member Empty : Position /// Get a position corresponding to the first line (line number 1) in a given file static member FirstLine : filename:string -> Position [] type LexBuffer<'char> = /// The start position for the lexeme member StartPos: Position with get,set /// The end position for the lexeme member EndPos: Position with get,set /// The matched string member Lexeme: 'char array /// Fast helper to turn the matched characters into a string, avoiding an intermediate array static member LexemeString : LexBuffer -> string /// The length of the matched string member LexemeLength: int /// Fetch a particular character in the matched string member LexemeChar: int -> 'char /// Dynamically typed, non-lexically scoped parameter table member BufferLocalStore : IDictionary /// True if the refill of the buffer ever failed , or if explicitly set to true. member IsPastEndOfStream: bool with get,set /// Remove all input, though don't discard the current lexeme member DiscardInput: unit -> unit /// Adjust the start position associated with the lexbuf // Create implementations of lexbufs static member FromBytes: byte[] -> LexBuffer static member FromChars: char[] -> LexBuffer static member FromFunction: ('char[] * int * int -> int) -> LexBuffer<'char> static member FromAsyncFunction: ('char[] * int * int -> Async) -> LexBuffer<'char> [.FromFunction instead")>] static member FromCharFunction: (char[] -> int -> int) -> LexBuffer [.FromFunction instead")>] static member FromByteFunction: (byte[] -> int -> int) -> LexBuffer static member FromTextReader: System.IO.TextReader -> LexBuffer static member FromBinaryReader: System.IO.BinaryReader -> LexBuffer /// The type of tables for an ascii lexer generated by fslex. [] type AsciiTables = static member Create : uint16[] array * uint16[] -> AsciiTables /// Interpret tables for an ascii lexer generated by fslex. member Interpret: initialState:int * LexBuffer -> int /// Interpret tables for an ascii lexer generated by fslex, processing input asynchronously member AsyncInterpret: initialState:int * LexBuffer -> Async /// The type of tables for an unicode lexer generated by fslex. [] type UnicodeTables = static member Create : uint16[] array * uint16[] -> UnicodeTables /// Interpret tables for a unicode lexer generated by fslex. member Interpret: initialState:int * LexBuffer -> int /// Interpret tables for a unicode lexer generated by fslex, processing input asynchronously member AsyncInterpret: initialState:int * LexBuffer -> Async