1 | // These end up inside the main class |
2 | |
3 | static class LFixWhitespace extends LearnerImpl {
|
4 | static boolean debug; |
5 | Learner base; |
6 | String s; |
7 | |
8 | *(Learner *base) {}
|
9 | |
10 | public void tryAgain() {
|
11 | base.tryAgain(); |
12 | } |
13 | |
14 | public void processInOut(Object _in, Object _out) {
|
15 | String in = (String) _in, out = (String) _out; |
16 | int i = count(in), j = count(out); |
17 | in = in.substring(i); |
18 | s = out.substring(0, j); |
19 | out = out.substring(j); |
20 | if (debug) |
21 | System.out.println("LFixWhitespace: Feeding to input learner: " + in + " => " + out);
|
22 | base.processInOut(in, out); |
23 | } |
24 | |
25 | public Object processIn(Object _in) {
|
26 | String in = (String) _in; |
27 | int i = count(in); |
28 | in = in.substring(i); |
29 | in = (String) base.processIn(in); |
30 | in = s + in; |
31 | return in; |
32 | } |
33 | |
34 | int count(String s) {
|
35 | int I = 0; |
36 | while (I < s.length () && "\r\n\t ".indexOf(s.charAt(I)) >= 0) |
37 | ++I; |
38 | return I; |
39 | } |
40 | |
41 | } |
Began life as a copy of #1000387
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1000459 |
| Snippet name: | LFixWhitespace (works) |
| Eternal ID of this version: | #1000459/1 |
| Text MD5: | c1d05958a7f866bf16f2164493f74129 |
| Author: | stefan |
| Category: | |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-08-08 03:20:55 |
| Source code size: | 968 bytes / 41 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 853 / 2255 |
| Referenced in: | [show references] |