| | @@ -94,10 +94,10 @@ |
| 94 | 94 | end; |
| 95 | 95 | |
| 96 | 96 | (* Whether s ends an operand, so that a - after it subtracts. *) |
| 97 | | -proc endsOperand(s: ^Scan.Scanner): BOOL; |
| 97 | +proc endsOperand(const s: Scan.Scanner): BOOL; |
| 98 | 98 | begin |
| 99 | | - if s^.kind = Scan.word then return not Scan.reserved(Scan.text(s)); end; |
| 100 | | - return (s^.kind = Scan.number) or (s^.kind = Scan.literal) |
| 99 | + if s.kind = Scan.word then return not Scan.reserved(Scan.text(s)); end; |
| 100 | + return (s.kind = Scan.number) or (s.kind = Scan.literal) |
| 101 | 101 | or Scan.is(s, ")") or Scan.is(s, "]") or Scan.is(s, "}") or Scan.is(s, "^"); |
| 102 | 102 | end; |
| 103 | 103 | |
| | @@ -106,7 +106,7 @@ |
| 106 | 106 | var s: Scan.Scanner; |
| 107 | 107 | begin |
| 108 | 108 | s := sc; |
| 109 | | - repeat Scan.next(ADR(s)); until s.kind # Scan.comment; |
| 109 | + repeat Scan.next(s); until s.kind # Scan.comment; |
| 110 | 110 | return s; |
| 111 | 111 | end; |
| 112 | 112 | |
| | @@ -115,18 +115,18 @@ |
| 115 | 115 | proc binary: BOOL; |
| 116 | 116 | var n: Scan.Scanner; |
| 117 | 117 | begin |
| 118 | | - if sc.kind = Scan.word then return Scan.among(Scan.text(ADR(sc)), binaryWords); end; |
| 119 | | - if (sc.kind # Scan.symbol) or not Scan.among(Scan.text(ADR(sc)), binarySymbols) then |
| 118 | + if sc.kind = Scan.word then return Scan.among(Scan.text(sc), binaryWords); end; |
| 119 | + if (sc.kind # Scan.symbol) or not Scan.among(Scan.text(sc), binarySymbols) then |
| 120 | 120 | return false; |
| 121 | 121 | end; |
| 122 | 122 | (* a | after an operand is or; one after anything else starts an arm *) |
| 123 | | - if Scan.is(ADR(sc), "-") or Scan.is(ADR(sc), "+") or Scan.is(ADR(sc), "|") then |
| 124 | | - return endsOperand(ADR(prev)); |
| 123 | + if Scan.is(sc, "-") or Scan.is(sc, "+") or Scan.is(sc, "|") then |
| 124 | + return endsOperand(prev); |
| 125 | 125 | end; |
| 126 | | - if Scan.is(ADR(sc), "*") and (prev.kind = Scan.word) then |
| 126 | + if Scan.is(sc, "*") and (prev.kind = Scan.word) then |
| 127 | 127 | n := following(); |
| 128 | | - if Scan.among(Scan.text(ADR(n)), "; , : = )") then return false; end; |
| 129 | | - if Scan.is(ADR(n), "(") and Scan.is(ADR(prev2), "proc") then return false; end; |
| 128 | + if Scan.among(Scan.text(n), "; , : = )") then return false; end; |
| 129 | + if Scan.is(n, "(") and Scan.is(prev2, "proc") then return false; end; |
| 130 | 130 | end; |
| 131 | 131 | return true; |
| 132 | 132 | end; |
| | @@ -136,10 +136,10 @@ |
| 136 | 136 | proc continues: BOOL; |
| 137 | 137 | var t: []U8; |
| 138 | 138 | begin |
| 139 | | - if (brackets > 0) or prevBinary or Scan.is(ADR(prev), ",") then return true; end; |
| 140 | | - t := Scan.text(ADR(sc)); |
| 139 | + if (brackets > 0) or prevBinary or Scan.is(prev, ",") then return true; end; |
| 140 | + t := Scan.text(sc); |
| 141 | 141 | if sc.kind = Scan.word then return Scan.among(t, binaryWords) or Scan.among(t, "then do of"); end; |
| 142 | | - if Scan.is(ADR(sc), "|") then return endsOperand(ADR(prev)); end; |
| 142 | + if Scan.is(sc, "|") then return endsOperand(prev); end; |
| 143 | 143 | return (sc.kind = Scan.symbol) and Scan.among(t, binarySymbols); |
| 144 | 144 | end; |
| 145 | 145 | |
| | @@ -147,10 +147,10 @@ |
| 147 | 147 | procedure type. *) |
| 148 | 148 | proc declaration(s: Scan.Scanner): BOOL; |
| 149 | 149 | begin |
| 150 | | - if (s.kind # Scan.word) or not Scan.among(Scan.text(ADR(s)), declarations) then return false; end; |
| 151 | | - if not Scan.is(ADR(s), "proc") then return true; end; |
| 152 | | - Scan.next(ADR(s)); |
| 153 | | - return not Scan.is(ADR(s), "("); |
| 150 | + if (s.kind # Scan.word) or not Scan.among(Scan.text(s), declarations) then return false; end; |
| 151 | + if not Scan.is(s, "proc") then return true; end; |
| 152 | + Scan.next(s); |
| 153 | + return not Scan.is(s, "("); |
| 154 | 154 | end; |
| 155 | 155 | |
| 156 | 156 | (* The indent of the block's own lines, or of its end. *) |
| | @@ -182,10 +182,10 @@ |
| 182 | 182 | end; |
| 183 | 183 | if declaration(sc) then |
| 184 | 184 | depth := 0; |
| 185 | | - inSection := Scan.among(Scan.text(ADR(sc)), "const type var"); |
| 185 | + inSection := Scan.among(Scan.text(sc), "const type var"); |
| 186 | 186 | return 0; |
| 187 | 187 | end; |
| 188 | | - if Scan.among(Scan.text(ADR(sc)), "end until else elsif |") then |
| 188 | + if Scan.among(Scan.text(sc), "end until else elsif |") then |
| 189 | 189 | return outer(); |
| 190 | 190 | end; |
| 191 | 191 | return inner(); |
| | @@ -216,8 +216,8 @@ |
| 216 | 216 | spaces(n); |
| 217 | 217 | elsif afterComment then |
| 218 | 218 | Buf.str(out, src[last..sc.start]); |
| 219 | | - elsif Scan.is(ADR(sc), ",") or Scan.is(ADR(sc), ";") then |
| 220 | | - elsif Scan.is(ADR(prev), ",") or Scan.is(ADR(prev), ";") or binaryNow or prevBinary then |
| 219 | + elsif Scan.is(sc, ",") or Scan.is(sc, ";") then |
| 220 | + elsif Scan.is(prev, ",") or Scan.is(prev, ";") or binaryNow or prevBinary then |
| 221 | 221 | if not prevUnary then spaces(1); end; |
| 222 | 222 | elsif not prevUnary then |
| 223 | 223 | Buf.str(out, src[last..sc.start]); |
| | @@ -254,7 +254,7 @@ |
| 254 | 254 | proc track(binaryNow: BOOL); |
| 255 | 255 | var t: []U8; |
| 256 | 256 | begin |
| 257 | | - t := Scan.text(ADR(sc)); |
| 257 | + t := Scan.text(sc); |
| 258 | 258 | if sc.kind = Scan.word then |
| 259 | 259 | if Scan.among(t, openers) then |
| 260 | 260 | if depth = LEN(bases) then Rt.stop("Pretty: blocks nested too deep"); end; |
| | @@ -268,8 +268,8 @@ |
| 268 | 268 | elsif Scan.among(t, ") ] }") and (brackets > 0) then DEC(brackets); |
| 269 | 269 | end; |
| 270 | 270 | end; |
| 271 | | - prevUnary := (Scan.is(ADR(sc), "-") or Scan.is(ADR(sc), "+")) and not binaryNow |
| 272 | | - or Scan.is(ADR(sc), "~"); |
| 271 | + prevUnary := (Scan.is(sc, "-") or Scan.is(sc, "+")) and not binaryNow |
| 272 | + or Scan.is(sc, "~"); |
| 273 | 273 | prevBinary := binaryNow; |
| 274 | 274 | prev2 := prev; |
| 275 | 275 | prev := sc; |
| | @@ -296,14 +296,14 @@ |
| 296 | 296 | inSection := false; |
| 297 | 297 | stmtIndent := 0; |
| 298 | 298 | stmtDelta := 0; |
| 299 | | - Scan.init(ADR(sc), src); |
| 299 | + Scan.init(sc, src); |
| 300 | 300 | prev := sc; |
| 301 | 301 | prev2 := sc; |
| 302 | 302 | prevBinary := false; |
| 303 | 303 | prevUnary := false; |
| 304 | 304 | afterComment := false; |
| 305 | 305 | last := 0; |
| 306 | | - Scan.next(ADR(sc)); |
| 306 | + Scan.next(sc); |
| 307 | 307 | while sc.kind # Scan.eof do |
| 308 | 308 | b := (sc.kind # Scan.comment) and binary(); |
| 309 | 309 | if sc.lineBreak then |
| | @@ -316,7 +316,7 @@ |
| 316 | 316 | afterComment := sc.kind = Scan.comment; |
| 317 | 317 | if not afterComment then track(b); end; |
| 318 | 318 | last := sc.stop; |
| 319 | | - Scan.next(ADR(sc)); |
| 319 | + Scan.next(sc); |
| 320 | 320 | end; |
| 321 | 321 | lineBreaks(last, LEN(src)); |
| 322 | 322 | trim; |