csharpfftfsharpintegrationinterpolationlinear-algebramathdifferentiationmatrixnumericsrandomregressionstatisticsmathnet
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
4.9 KiB
115 lines
4.9 KiB
//==========================================================================
|
|
// 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
|
|
[<System.ObsoleteAttribute("Use the AbsoluteOffset property instead")>]
|
|
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
|
|
|
|
[<System.ObsoleteAttribute("Consider using the NextLine property instead")>]
|
|
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
|
|
|
|
[<Sealed>]
|
|
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<char> -> 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<string,obj>
|
|
|
|
/// 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<byte>
|
|
static member FromChars: char[] -> LexBuffer<char>
|
|
static member FromFunction: ('char[] * int * int -> int) -> LexBuffer<'char>
|
|
static member FromAsyncFunction: ('char[] * int * int -> Async<int>) -> LexBuffer<'char>
|
|
|
|
|
|
[<System.Obsolete("Use LexBuffer<char>.FromFunction instead")>]
|
|
static member FromCharFunction: (char[] -> int -> int) -> LexBuffer<char>
|
|
[<System.Obsolete("Use LexBuffer<byte>.FromFunction instead")>]
|
|
static member FromByteFunction: (byte[] -> int -> int) -> LexBuffer<byte>
|
|
|
|
static member FromTextReader: System.IO.TextReader -> LexBuffer<char>
|
|
static member FromBinaryReader: System.IO.BinaryReader -> LexBuffer<byte>
|
|
|
|
|
|
/// The type of tables for an ascii lexer generated by fslex.
|
|
[<Sealed>]
|
|
type AsciiTables =
|
|
static member Create : uint16[] array * uint16[] -> AsciiTables
|
|
/// Interpret tables for an ascii lexer generated by fslex.
|
|
member Interpret: initialState:int * LexBuffer<byte> -> int
|
|
/// Interpret tables for an ascii lexer generated by fslex, processing input asynchronously
|
|
member AsyncInterpret: initialState:int * LexBuffer<byte> -> Async<int>
|
|
|
|
|
|
/// The type of tables for an unicode lexer generated by fslex.
|
|
[<Sealed>]
|
|
type UnicodeTables =
|
|
static member Create : uint16[] array * uint16[] -> UnicodeTables
|
|
/// Interpret tables for a unicode lexer generated by fslex.
|
|
member Interpret: initialState:int * LexBuffer<char> -> int
|
|
|
|
/// Interpret tables for a unicode lexer generated by fslex, processing input asynchronously
|
|
member AsyncInterpret: initialState:int * LexBuffer<char> -> Async<int>
|
|
|
|
|