From 3cf920e8752fcd353e62d432bc62344bcd64ca19 Mon Sep 17 00:00:00 2001 From: dawe Date: Sun, 7 Apr 2024 17:39:23 +0200 Subject: [PATCH] Silence warnings about obsolete ref cell handling and wrongly placed xml comments --- src/Common/Arg.fs | 38 ++++++++++---------- src/Common/Arg.fsi | 2 +- src/FsLex.Core/fslexast.fs | 4 +-- src/FsLexYacc.Runtime/Lexing.fsi | 6 ++-- src/FsLexYacc.Runtime/Parsing.fsi | 2 +- src/FsYacc.Core/fsyaccast.fs | 60 +++++++++++++++---------------- src/FsYacc.Core/fsyaccdriver.fs | 26 +++++++------- src/FsYacc.Core/fsyacclex.fs | 10 +++--- src/FsYacc.Core/fsyacclex.fsl | 10 +++--- 9 files changed, 79 insertions(+), 79 deletions(-) diff --git a/src/Common/Arg.fs b/src/Common/Arg.fs index 1af85e2..bc96f69 100644 --- a/src/Common/Arg.fs +++ b/src/Common/Arg.fs @@ -79,40 +79,40 @@ type ArgParser() = pendline "display this list of options" sbuf.ToString() - static member ParsePartial(cursor, argv, arguments: seq, ?otherArgs, ?usageText) = + static member ParsePartial(cursor: ref, argv, arguments: seq, ?otherArgs, ?usageText) = let other = defaultArg otherArgs (fun _ -> ()) let usageText = defaultArg usageText "" let nargs = Array.length argv - incr cursor + cursor.Value <- cursor.Value + 1 let argSpecs = arguments |> Seq.toList let specs = argSpecs |> List.map (fun (arg: ArgInfo) -> arg.Name, arg.ArgType) - while !cursor < nargs do - let arg = argv.[!cursor] + while cursor.Value < nargs do + let arg = argv.[cursor.Value] let rec findMatchingArg args = match args with | (s, action) :: _ when s = arg -> let getSecondArg () = - if !cursor + 1 >= nargs then + if cursor.Value + 1 >= nargs then raise (Bad("option " + s + " needs an argument.\n" + getUsage argSpecs usageText)) - argv.[!cursor + 1] + argv.[cursor.Value + 1] match action with | UnitArg f -> f () - incr cursor + cursor.Value <- cursor.Value + 1 | SetArg f -> - f := true - incr cursor + f.Value <- true + cursor.Value <- cursor.Value + 1 | ClearArg f -> - f := false - incr cursor + f.Value <- false + cursor.Value <- cursor.Value + 1 | StringArg f -> let arg2 = getSecondArg () f arg2 - cursor := !cursor + 2 + cursor.Value <- cursor.Value + 2 | IntArg f -> let arg2 = getSecondArg () @@ -123,7 +123,7 @@ type ArgParser() = raise (Bad(getUsage argSpecs usageText)) in f arg2 - cursor := !cursor + 2 + cursor.Value <- cursor.Value + 2 | FloatArg f -> let arg2 = getSecondArg () @@ -134,13 +134,13 @@ type ArgParser() = raise (Bad(getUsage argSpecs usageText)) in f arg2 - cursor := !cursor + 2 + cursor.Value <- cursor.Value + 2 | RestArg f -> - incr cursor + cursor.Value <- cursor.Value + 1 - while !cursor < nargs do - f argv.[!cursor] - incr cursor + while cursor.Value < nargs do + f argv.[cursor.Value] + cursor.Value <- cursor.Value + 1 | _ :: more -> findMatchingArg more | [] -> @@ -156,7 +156,7 @@ type ArgParser() = raise (Bad("unrecognized argument: " + arg + "\n" + getUsage argSpecs usageText)) else other arg - incr cursor + cursor.Value <- cursor.Value + 1 findMatchingArg specs diff --git a/src/Common/Arg.fsi b/src/Common/Arg.fsi index 4aa7669..38c8cd2 100644 --- a/src/Common/Arg.fsi +++ b/src/Common/Arg.fsi @@ -1,6 +1,6 @@ // (c) Microsoft Corporation 2005-2009. -/// A simple command-line argument processor. +// A simple command-line argument processor. namespace FSharp.Text /// The spec value describes the action of the argument, diff --git a/src/FsLex.Core/fslexast.fs b/src/FsLex.Core/fslexast.fs index 0387811..67ad090 100644 --- a/src/FsLex.Core/fslexast.fs +++ b/src/FsLex.Core/fslexast.fs @@ -430,8 +430,8 @@ let newDfaNodeId = let i = ref 0 fun () -> - let res = !i in - incr i + let res = i.Value in + i.Value <- i.Value + 1 res let NfaToDfa (nfaNodeMap: NfaNodeMap) nfaStartNode = diff --git a/src/FsLexYacc.Runtime/Lexing.fsi b/src/FsLexYacc.Runtime/Lexing.fsi index 850224c..2ecda86 100644 --- a/src/FsLexYacc.Runtime/Lexing.fsi +++ b/src/FsLexYacc.Runtime/Lexing.fsi @@ -70,8 +70,8 @@ type Position = /// Get a position corresponding to the first line (line number 1) in a given file static member FirstLine: filename: string -> Position -[] /// Input buffers consumed by lexers generated by fslex.exe +[] type LexBuffer<'char> = /// The start position for the lexeme member StartPos: Position with get, set @@ -135,8 +135,8 @@ type 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. @@ -148,8 +148,8 @@ type 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 /// Standard utility to create a Unicode LexBuffer diff --git a/src/FsLexYacc.Runtime/Parsing.fsi b/src/FsLexYacc.Runtime/Parsing.fsi index c3f7d35..9cf7720 100644 --- a/src/FsLexYacc.Runtime/Parsing.fsi +++ b/src/FsLexYacc.Runtime/Parsing.fsi @@ -32,8 +32,8 @@ type IParseState = /// Raise an error in this parse context abstract RaiseError<'b> : unit -> 'b -[] /// The context provided when a parse error occurs +[] type ParseErrorContext<'tok> = /// The stack of state indexes active at the parse error member StateStack: int list diff --git a/src/FsYacc.Core/fsyaccast.fs b/src/FsYacc.Core/fsyaccast.fs index 1fe71b4..1af148e 100644 --- a/src/FsYacc.Core/fsyaccast.fs +++ b/src/FsYacc.Core/fsyaccast.fs @@ -249,13 +249,13 @@ let (|GotoItemIdx|) (i64: uint64) = /// to the worker function let ProcessWorkList start f = let work = ref (start: 'a list) - let queueWork = (fun x -> work := x :: !work) + let queueWork = (fun x -> work.Value <- x :: work.Value) let rec loop () = - match !work with + match work.Value with | [] -> () | x :: t -> - work := t + work.Value <- t f queueWork x loop () @@ -268,11 +268,11 @@ let LeastFixedPoint f set = ProcessWorkList (Set.toList set) (fun queueWork item -> f (item) |> List.iter (fun i2 -> - if not (Set.contains i2 !acc) then - (acc := Set.add i2 !acc + if not (Set.contains i2 acc.Value) then + (acc.Value <- Set.add i2 acc.Value queueWork i2))) - !acc + acc.Value /// A general standard memoization utility. Be sure to apply to only one (function) argument to build the /// residue function! @@ -508,13 +508,13 @@ let CompilerLalrParserSpec logf (spec: ProcessedParserSpec) : CompiledSpec = Set.empty) ] - let add changed ss (x, y) = + let add (changed: ref) ss (x, y) = let s = Map.find x ss if Set.contains y s then ss else - (changed := true + (changed.Value <- true Map.add x (Set.add y s) ss) let oneRound (ss: Map<_, _>) = @@ -530,24 +530,24 @@ let CompilerLalrParserSpec logf (spec: ProcessedParserSpec) : CompiledSpec = let rec place l = match l with | yi :: t -> - res - := List.choose - (function - | None -> None - | Some a -> Some(PNonTerminal nonTermX, Some a)) - (Set.toList ss.[yi]) - @ !res + res.Value <- + List.choose + (function + | None -> None + | Some a -> Some(PNonTerminal nonTermX, Some a)) + (Set.toList ss.[yi]) + @ res.Value if ss.[yi].Contains(None) then place t - | [] -> res := (PNonTerminal nonTermX, None) :: !res + | [] -> res.Value <- (PNonTerminal nonTermX, None) :: res.Value place rhs - !res + res.Value let ss' = List.fold (add changed) ss frontier - !changed, ss' + changed.Value, ss' let rec loop ss = let changed, ss' = oneRound ss @@ -781,15 +781,15 @@ let CompilerLalrParserSpec logf (spec: ProcessedParserSpec) : CompiledSpec = let acc = ref Set.empty ProcessWorkList startKernels (fun addToWorkList kernel -> - if not ((!acc).Contains(kernel)) then - acc := (!acc).Add(kernel) + if not ((acc.Value).Contains(kernel)) then + acc.Value <- (acc.Value).Add(kernel) for csym in RelevantSymbolsOfKernel kernel do let gotoKernel = ComputeGotosOfKernel kernel csym assert (gotoKernel.Count > 0) addToWorkList gotoKernel) - !acc |> Seq.toList |> List.map (Set.filter IsKernelItem) + acc.Value |> Seq.toList |> List.map (Set.filter IsKernelItem) reportTime () printf "building kernel table..." @@ -887,7 +887,7 @@ let CompilerLalrParserSpec logf (spec: ProcessedParserSpec) : CompiledSpec = let jset = closure1OfItem0WithDummy item0 //printf "#jset = %d\n" jset.Count; stdout.Flush(); for KeyValue(closureItem0, lookaheadTokens) in jset.IEnumerable do - incr count + count.Value <- count.Value + 1 match rsym_of_item0 closureItem0 with | None -> () @@ -1026,11 +1026,11 @@ let CompilerLalrParserSpec logf (spec: ProcessedParserSpec) : CompiledSpec = | RightAssoc -> shiftItem | NonAssoc -> reportConflict shiftItem reduceItem "we prefer shift on equal precedences" - incr shiftReduceConflicts + shiftReduceConflicts.Value <- shiftReduceConflicts.Value + 1 shiftItem | _ -> reportConflict shiftItem reduceItem "we prefer shift when unable to compare precedences" - incr shiftReduceConflicts + shiftReduceConflicts.Value <- shiftReduceConflicts.Value + 1 shiftItem | (_, Reduce prodIdx1), (_, Reduce prodIdx2) -> "we prefer the rule earlier in the file" @@ -1039,7 +1039,7 @@ let CompilerLalrParserSpec logf (spec: ProcessedParserSpec) : CompiledSpec = else reportConflict itemNew itemSoFar - incr reduceReduceConflicts + reduceReduceConflicts.Value <- reduceReduceConflicts.Value + 1 if prodIdx1 < prodIdx2 then itemSoFar else itemNew | _ -> itemNew @@ -1161,15 +1161,15 @@ let CompilerLalrParserSpec logf (spec: ProcessedParserSpec) : CompiledSpec = printfn " returning tables." stdout.Flush() - if !shiftReduceConflicts > 0 then - printfn " %d shift/reduce conflicts" !shiftReduceConflicts + if shiftReduceConflicts.Value > 0 then + printfn " %d shift/reduce conflicts" shiftReduceConflicts.Value stdout.Flush() - if !reduceReduceConflicts > 0 then - printfn " %d reduce/reduce conflicts" !reduceReduceConflicts + if reduceReduceConflicts.Value > 0 then + printfn " %d reduce/reduce conflicts" reduceReduceConflicts.Value stdout.Flush() - if !shiftReduceConflicts > 0 || !reduceReduceConflicts > 0 then + if shiftReduceConflicts.Value > 0 || reduceReduceConflicts.Value > 0 then printfn " consider setting precedences explicitly using %%left %%right and %%nonassoc on terminals and/or setting explicit precedence on rules using %%prec" diff --git a/src/FsYacc.Core/fsyaccdriver.fs b/src/FsYacc.Core/fsyaccdriver.fs index a7b4641..5ca3076 100644 --- a/src/FsYacc.Core/fsyaccdriver.fs +++ b/src/FsYacc.Core/fsyaccdriver.fs @@ -481,11 +481,11 @@ let writeSpecToFile (generatorState: GeneratorState) (spec: ParserSpec) (compile let max = ref 0 for KeyValue(x, y) in countPerAction do - if y > !max then - (mostCommon := x - max := y) + if y > max.Value then + (mostCommon.Value <- x + max.Value <- y) - !mostCommon + mostCommon.Value (* Count the number of entries in the association table. *) let count = ref 0 @@ -493,11 +493,11 @@ let writeSpecToFile (generatorState: GeneratorState) (spec: ParserSpec) (compile for KeyValue(action, terminals) in terminalsByAction do for terminal in terminals do if action <> mostCommonAction then - incr count + count.Value <- count.Value + 1 (* Write the head of the table (i.e. the number of entries and the default value) *) actionTableCurrIndex <- actionTableCurrIndex + 1 - writer.WriteUInt16 !count + writer.WriteUInt16 count.Value writer.WriteUInt16(generatorState.map_action_to_int mostCommonAction) (* Write the pairs of entries in incremental order by key *) @@ -585,14 +585,14 @@ let writeSpecToFile (generatorState: GeneratorState) (spec: ParserSpec) (compile let c = code |> String.collect (fun c -> - if not !dollar && c = '$' then - (dollar := true + if not dollar.Value && c = '$' then + (dollar.Value <- true "") - elif !dollar && c >= '0' && c <= '9' then - (dollar := false + elif dollar.Value && c >= '0' && c <= '9' then + (dollar.Value <- false "_" + String(c, 1)) - elif !dollar then - (dollar := false + elif dollar.Value then + (dollar.Value <- false "$" + String(c, 1)) else String(c, 1)) @@ -602,7 +602,7 @@ let writeSpecToFile (generatorState: GeneratorState) (spec: ParserSpec) (compile for line in lines do writer.WriteLine " %s" line - if !dollar then + if dollar.Value then writer.Write "$" | None -> writer.WriteLine " raise (%s.Accept(Microsoft.FSharp.Core.Operators.box _1))" generatorState.parslib diff --git a/src/FsYacc.Core/fsyacclex.fs b/src/FsYacc.Core/fsyacclex.fs index 5b99ce6..fd12c38 100644 --- a/src/FsYacc.Core/fsyacclex.fs +++ b/src/FsYacc.Core/fsyacclex.fs @@ -307,7 +307,7 @@ and token lexbuf = ) | 2 -> ( # 37 "fsyacclex.fsl" - typeDepth := 1; startPos := lexbuf.StartPos; clearBuf(); TOKEN (fs_type lexbuf) + typeDepth.Value <- 1; startPos.Value <- lexbuf.StartPos; clearBuf(); TOKEN (fs_type lexbuf) # 311 "fsyacclex.fs" ) | 3 -> ( @@ -327,7 +327,7 @@ and token lexbuf = ) | 6 -> ( # 41 "fsyacclex.fsl" - typeDepth := 1; startPos := lexbuf.StartPos; clearBuf(); TYPE (match fs_type lexbuf with Some x -> x | None -> failwith "gettype") + typeDepth.Value <- 1; startPos.Value <- lexbuf.StartPos; clearBuf(); TYPE (match fs_type lexbuf with Some x -> x | None -> failwith "gettype") # 331 "fsyacclex.fs" ) | 7 -> ( @@ -425,13 +425,13 @@ and fs_type lexbuf = match _fslex_tables.Interpret(61,lexbuf) with | 0 -> ( # 65 "fsyacclex.fsl" - incr typeDepth; appendBuf(lexeme lexbuf); fs_type lexbuf + typeDepth.Value <- typeDepth.Value + 1; appendBuf(lexeme lexbuf); fs_type lexbuf # 429 "fsyacclex.fs" ) | 1 -> ( # 67 "fsyacclex.fsl" - decr typeDepth; - if !typeDepth = 0 + typeDepth.Value <- typeDepth.Value - 1; + if typeDepth.Value = 0 then Some(string str_buf) else appendBuf(lexeme lexbuf); fs_type lexbuf # 437 "fsyacclex.fs" diff --git a/src/FsYacc.Core/fsyacclex.fsl b/src/FsYacc.Core/fsyacclex.fsl index 02d4c48..2da24b9 100644 --- a/src/FsYacc.Core/fsyacclex.fsl +++ b/src/FsYacc.Core/fsyacclex.fsl @@ -34,11 +34,11 @@ let ident = ident_start_char ident_char* rule token = parse | "%{" { let p = lexbuf.StartPos in header p (new StringBuilder 100) lexbuf } | "%%" { PERCENT_PERCENT } - | "%token" (whitespace* '<') { typeDepth := 1; startPos := lexbuf.StartPos; clearBuf(); TOKEN (fs_type lexbuf) } + | "%token" (whitespace* '<') { typeDepth.Value <- 1; startPos.Value <- lexbuf.StartPos; clearBuf(); TOKEN (fs_type lexbuf) } | "%token" { TOKEN (None) } | "%start"{ START } | "%prec"{ PREC } - | "%type" (whitespace* '<') { typeDepth := 1; startPos := lexbuf.StartPos; clearBuf(); TYPE (match fs_type lexbuf with Some x -> x | None -> failwith "gettype") } + | "%type" (whitespace* '<') { typeDepth.Value <- 1; startPos.Value <- lexbuf.StartPos; clearBuf(); TYPE (match fs_type lexbuf with Some x -> x | None -> failwith "gettype") } | "%left" { LEFT } | "%right" { RIGHT } | "%nonassoc" { NONASSOC } @@ -62,10 +62,10 @@ rule token = parse | eof { EOF } and fs_type = parse - | '<' { incr typeDepth; appendBuf(lexeme lexbuf); fs_type lexbuf} + | '<' { typeDepth.Value <- typeDepth.Value + 1; appendBuf(lexeme lexbuf); fs_type lexbuf} | '>' - { decr typeDepth; - if !typeDepth = 0 + { typeDepth.Value <- typeDepth.Value - 1; + if typeDepth.Value = 0 then Some(string str_buf) else appendBuf(lexeme lexbuf); fs_type lexbuf } | _ { appendBuf(lexeme lexbuf); fs_type lexbuf }