Skip to content

Commit eb10796

Browse files
committed
test 'Char -> 'T
1 parent 1c73196 commit eb10796

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/Compiler/Facilities/prim-lexing.fs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ type internal Position =
241241

242242
static member FirstLine fileIdx = Position(fileIdx, 1, 0, 0)
243243

244-
type internal LexBufferFiller<'Char> = LexBuffer<'Char> -> unit
244+
type internal LexBufferFiller<'T> = LexBuffer<'T> -> unit
245245

246-
and [<Sealed>] internal LexBuffer<'Char>
247-
(filler: LexBufferFiller<'Char>, reportLibraryOnlyFeatures: bool, langVersion: LanguageVersion, strictIndentation: bool option) =
246+
and [<Sealed>] internal LexBuffer<'T>
247+
(filler: LexBufferFiller<'T>, reportLibraryOnlyFeatures: bool, langVersion: LanguageVersion, strictIndentation: bool option) =
248248
let context = Dictionary<string, obj>(1)
249249
let mutable buffer = [||]
250250
/// number of valid characters beyond bufferScanStart.
@@ -287,11 +287,11 @@ and [<Sealed>] internal LexBuffer<'Char>
287287
and set b = endPos <- b
288288

289289
member lexbuf.LexemeView =
290-
System.ReadOnlySpan<'Char>(buffer, bufferScanStart, lexemeLength)
290+
System.ReadOnlySpan<'T>(buffer, bufferScanStart, lexemeLength)
291291

292292
member lexbuf.LexemeChar n = buffer[n + bufferScanStart]
293293

294-
member lexbuf.LexemeContains(c: 'Char) =
294+
member lexbuf.LexemeContains(c: 'T) =
295295
array.IndexOf(buffer, c, bufferScanStart, lexemeLength) >= 0
296296

297297
member lexbuf.BufferLocalStore = (context :> IDictionary<_, _>)
@@ -301,7 +301,7 @@ and [<Sealed>] internal LexBuffer<'Char>
301301
and set v = lexemeLength <- v
302302

303303
member lexbuf.Buffer
304-
with get (): 'Char[] = buffer
304+
with get (): 'T[] = buffer
305305
and set v = buffer <- v
306306

307307
member lexbuf.BufferMaxScanLength
@@ -351,32 +351,32 @@ and [<Sealed>] internal LexBuffer<'Char>
351351
FSharp.Compiler.DiagnosticsLogger.checkLanguageFeatureAndRecover langVersion featureId range
352352

353353
static member FromFunction
354-
(reportLibraryOnlyFeatures, langVersion, strictIndentation, f: 'Char[] * int * int -> int)
355-
: LexBuffer<'Char> =
354+
(reportLibraryOnlyFeatures, langVersion, strictIndentation, f: 'T[] * int * int -> int)
355+
: LexBuffer<'T> =
356356
let extension = Array.zeroCreate 4096
357357

358-
let filler (lexBuffer: LexBuffer<'Char>) =
358+
let filler (lexBuffer: LexBuffer<'T>) =
359359
let n = f (extension, 0, extension.Length)
360360
lexBuffer.EnsureBufferSize n
361361
Array.blit extension 0 lexBuffer.Buffer lexBuffer.BufferScanPos n
362362
lexBuffer.BufferMaxScanLength <- lexBuffer.BufferScanLength + n
363363

364-
new LexBuffer<'Char>(filler, reportLibraryOnlyFeatures, langVersion, strictIndentation)
364+
new LexBuffer<'T>(filler, reportLibraryOnlyFeatures, langVersion, strictIndentation)
365365

366366
// Important: This method takes ownership of the array
367-
static member FromArrayNoCopy(reportLibraryOnlyFeatures, langVersion, strictIndentation, buffer: 'Char[]) : LexBuffer<'Char> =
367+
static member FromArrayNoCopy(reportLibraryOnlyFeatures, langVersion, strictIndentation, buffer: 'T[]) : LexBuffer<'T> =
368368
let lexBuffer =
369-
new LexBuffer<'Char>((fun _ -> ()), reportLibraryOnlyFeatures, langVersion, strictIndentation)
369+
new LexBuffer<'T>((fun _ -> ()), reportLibraryOnlyFeatures, langVersion, strictIndentation)
370370

371371
lexBuffer.Buffer <- buffer
372372
lexBuffer.BufferMaxScanLength <- buffer.Length
373373
lexBuffer
374374

375375
// Important: this method does copy the array
376-
static member FromArray(reportLibraryOnlyFeatures, langVersion, strictIndentation, s: 'Char[]) : LexBuffer<'Char> =
376+
static member FromArray(reportLibraryOnlyFeatures, langVersion, strictIndentation, s: 'T[]) : LexBuffer<'T> =
377377
let buffer = Array.copy s
378378

379-
LexBuffer<'Char>.FromArrayNoCopy(reportLibraryOnlyFeatures, langVersion, strictIndentation, buffer)
379+
LexBuffer<'T>.FromArrayNoCopy(reportLibraryOnlyFeatures, langVersion, strictIndentation, buffer)
380380

381381
// Important: This method takes ownership of the array
382382
static member FromChars(reportLibraryOnlyFeatures, langVersion, strictIndentation, arr: char[]) =

src/Compiler/Facilities/prim-lexing.fsi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,21 @@ type internal Position =
107107
/// The type must be generic to match the code generated by FsLex and FsYacc (if you would like to
108108
/// fix this, please submit a PR to the FsLexYacc repository allowing for optional emit of a non-generic type reference).
109109
[<Sealed>]
110-
type internal LexBuffer<'Char> =
110+
type internal LexBuffer<'T> =
111111
/// The start position for the lexeme.
112112
member StartPos: Position with get, set
113113

114114
/// The end position for the lexeme.
115115
member EndPos: Position with get, set
116116

117117
/// The currently matched text as a Span, it is only valid until the lexer is advanced
118-
member LexemeView: System.ReadOnlySpan<'Char>
118+
member LexemeView: System.ReadOnlySpan<'T>
119119

120120
/// Get single character of matched string
121-
member LexemeChar: int -> 'Char
121+
member LexemeChar: int -> 'T
122122

123123
/// Determine if Lexeme contains a specific character
124-
member LexemeContains: 'Char -> bool
124+
member LexemeContains: 'T -> bool
125125

126126
/// Fast helper to turn the matched characters into a string, avoiding an intermediate array.
127127
static member LexemeString: LexBuffer<char> -> string
@@ -157,8 +157,8 @@ type internal LexBuffer<'Char> =
157157
reportLibraryOnlyFeatures: bool *
158158
langVersion: LanguageVersion *
159159
strictIndentation: bool option *
160-
('Char[] * int * int -> int) ->
161-
LexBuffer<'Char>
160+
('T[] * int * int -> int) ->
161+
LexBuffer<'T>
162162

163163
/// Create a lex buffer backed by source text.
164164
static member FromSourceText:

0 commit comments

Comments
 (0)