From 0ccbe14c906061eeb9aa60f81b6b8efe515abc3d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sun, 17 Jan 2016 02:00:21 -0500 Subject: [PATCH] Replace deprecated `or` and `&` --- aurochs/process.ml | 2 +- nog/nog.ml | 16 ++++++++-------- peg/peg.ml | 2 +- util/util.ml | 20 ++++++++++---------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/aurochs/process.ml b/aurochs/process.ml index 732dec6..cdd4335 100644 --- a/aurochs/process.ml +++ b/aurochs/process.ml @@ -143,7 +143,7 @@ let parse_file_with_nog pg fn = end in let pt = - let (trace, interactive) = (!Opt.trace or !Opt.debug, !Opt.debug) in + let (trace, interactive) = (!Opt.trace || !Opt.debug, !Opt.debug) in Nog.execute_positioned ~quick:!Opt.quick ?log_calls:!Opt.log_calls diff --git a/nog/nog.ml b/nog/nog.ml index 7e7a39b..236d456 100644 --- a/nog/nog.ml +++ b/nog/nog.ml @@ -221,7 +221,7 @@ let execute_positioned_quick program | BNEOF -> if c.head < m then run pc' else run pc | BNBOF -> if c.head > 0 then run pc' else run pc | BMB -> if c.memo_register = Busy then run pc' else run pc - | BMBF -> if c.memo_register = Busy or c.memo_register = Failure then run pc' else run pc + | BMBF -> if c.memo_register = Busy || c.memo_register = Failure then run pc' else run pc | BBRS -> if Stack.pop c.boolean then run pc' else run pc | BBRC -> if not (Stack.pop c.boolean) then run pc' else run pc | BMF -> if c.memo_register = Failure then run pc' else run pc @@ -229,7 +229,7 @@ let execute_positioned_quick program | BMK -> if c.memo_register <> Unknown then run pc' else run pc | JSR -> run pc'; run pc | SBNS ch -> - if c.head = m or u.[c.head] <> ch then + if c.head = m || u.[c.head] <> ch then run pc' else begin @@ -252,7 +252,7 @@ let execute_positioned_quick program | BOR -> let br1 = Stack.pop c.boolean in let br2 = Stack.pop c.boolean in - Stack.push (br1 or br2) c.boolean + Stack.push (br1 || br2) c.boolean | BNOT -> Stack.push (not (Stack.pop c.boolean)) c.boolean | BTRUE -> Stack.push true c.boolean | BFALSE -> Stack.push false c.boolean @@ -446,7 +446,7 @@ let execute_positioned program pf "S=[%a]\n" (print_stack print_stack_symbol) c.stack; in let iterate () = - if c.pc < 0 or c.pc >= n then + if c.pc < 0 || c.pc >= n then raise (Error "PC out of bounds") else begin @@ -466,7 +466,7 @@ let execute_positioned program | BNEOF -> if c.head < m then c.pc <- pc | BNBOF -> if c.head > 0 then c.pc <- pc | BMB -> if c.memo_register = Busy then c.pc <- pc - | BMBF -> if c.memo_register = Busy or c.memo_register = Failure then c.pc <- pc + | BMBF -> if c.memo_register = Busy || c.memo_register = Failure then c.pc <- pc | BBRS -> if Stack.pop c.boolean then c.pc <- pc | BBRC -> if not (Stack.pop c.boolean) then c.pc <- pc | BMF -> if c.memo_register = Failure then c.pc <- pc @@ -478,7 +478,7 @@ let execute_positioned program (*log_call program.pg_start;*) c.pc <- pc | SBNS ch -> - if c.head = m or u.[c.head] <> ch then + if c.head = m || u.[c.head] <> ch then c.pc <- pc else c.head <- c.head + 1 @@ -494,7 +494,7 @@ let execute_positioned program | BOR -> let br1 = Stack.pop c.boolean in let br2 = Stack.pop c.boolean in - Stack.push (br1 or br2) c.boolean + Stack.push (br1 || br2) c.boolean | BNOT -> Stack.push (not (Stack.pop c.boolean)) c.boolean | BTRUE -> Stack.push true c.boolean | BFALSE -> Stack.push false c.boolean @@ -838,7 +838,7 @@ let is_space = ("is_space", (=) ' ');; let is_not_space = ("is_not_space", (<>) ' ');; (* ***) (*** is_alpha *) -let is_alpha = ("is_alpha", (fun c -> ('a' <= c && c <= 'z') or ('A' <= c && c <= 'Z')));; +let is_alpha = ("is_alpha", (fun c -> ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')));; (* ***) (*** number *) let number ?root pg iterator = diff --git a/peg/peg.ml b/peg/peg.ml index b565fa5..49e30df 100644 --- a/peg/peg.ml +++ b/peg/peg.ml @@ -351,7 +351,7 @@ let is_factor v u i = in 0 <= i && i < m && n <= m - i && let rec loop j = - j = n or + j = n || u.[i + j] = v.[j] && loop (j + 1) in loop 0 diff --git a/util/util.ml b/util/util.ml index 65444b7..d4edc37 100644 --- a/util/util.ml +++ b/util/util.ml @@ -11,7 +11,7 @@ let first_line = fun w -> Buffer.clear b; let rec loop i = - if i = String.length w or w.[i] = '\n' then + if i = String.length w || w.[i] = '\n' then Buffer.contents b else begin @@ -63,7 +63,7 @@ let split_once_at f s = else loop1 (i + 1) and loop2 i j = - if j = m or not (f s.[j]) then + if j = m || not (f s.[j]) then (i,j) else loop2 i (j + 1) @@ -102,7 +102,7 @@ let parse_strings u = loop2 r (i + 1) | _ -> loop1 r i and loop1 r i = - if i = m or is_space u.[i] or u.[i] = '"' then + if i = m || is_space u.[i] || u.[i] = '"' then begin let x = Buffer.contents b in Buffer.clear b; @@ -167,7 +167,7 @@ let split_at c u = else loop1 r i and loop1 r i = - if i = m or u.[i] = c then + if i = m || u.[i] = c then begin let x = Buffer.contents b in Buffer.clear b; @@ -332,13 +332,13 @@ let word_wrap oc ?(columns=75) u = (* j: actual cursor column *) (* k: number of pending spaces *) and loop2 i0 i j k = - if i = m or u.[i] = ' ' or u.[i] = '\t' or u.[i] = '\n' then + if i = m || u.[i] = ' ' || u.[i] = '\t' || u.[i] = '\n' then let l = i - i0 in if j + k + l >= columns then begin f '\n'; g u i0 l; - if i < m & u.[i] = '\n' then + if i < m && u.[i] = '\n' then begin f '\n'; loop0 (i + 1) 0 @@ -398,7 +398,7 @@ let substitute_variables env w = let list_sub_rev l start length = let rec loop r j = function | [] -> r (* shall we raise an exception ? *) - | x::y -> loop (if j < start or j >= start + length then r else x::r) (j + 1) y + | x::y -> loop (if j < start || j >= start + length then r else x::r) (j + 1) y in loop [] 0 l @@ -407,7 +407,7 @@ let is_prefix u v = and n = String.length v in m <= n && - let rec loop i = i = m or u.[i] = v.[i] && loop (i + 1) in + let rec loop i = i = m || u.[i] = v.[i] && loop (i + 1) in loop 0 let remove_prefix u v = @@ -422,7 +422,7 @@ let is_suffix u v = and n = String.length v in m <= n && - let rec loop i = i = m or u.[m - 1 - i] = v.[n - 1 - i] && loop (i + 1) in + let rec loop i = i = m || u.[m - 1 - i] = v.[n - 1 - i] && loop (i + 1) in loop 0 let remove_suffix u v = @@ -513,7 +513,7 @@ let array_mem_assoc x a = if i = m then false else let (y,_) = a.(i) in - x = y or loop (i + 1) + x = y || loop (i + 1) in loop 0