root/hodgestar/WhitespaceCode/tabs2spaces/comment.txt

Revision 425, 1.0 kB (checked in by hodgestar, 3 years ago)

Playing around with Whitespace.

Line 
1=== Embedded Programming ==
2
3I have written a tabs to spaces converter in Whitespace [1] and embedded [2] it
4into this comment. You'll need the Python interpreter from [3] because the
5Haskell one doesn't report EOFs nicely.
6
7Usage:
8 python main.py file-containing-this-comment < file-with-tabs > file-with-spaces
9
10I have included the dissambled [4] code below for your convenience. Hopefully the
11blog software doesn't discard the (extremely meaningful) whitespace in this
12comment!
13
14[1] http://compsoc.dur.ac.uk/whitespace/
15[2] http://compsoc.dur.ac.uk/whitespace/tools.php
16[3] http://www.mrphlip.com/pywhitespace.tar.bz2
17[4] http://yagni.com/whitespace/index.html
18
19=== Source Code ===
20
21label 1
22
23#read a char and put copies on the stack
24push 0
25readchar
26push 0
27retrieve
28
29#compare to EOF and jump to end if it matches
30dup
31push -1
32sub
33jz 5
34
35#compare to \t and jump to 3 if it matches
36dup
37push 9
38sub
39jz 3
40jump 2
41
42#non-tab
43label 2
44outchar
45jump 4
46
47#tab
48label 3
49discard
50push 32
51dup
52dup
53dup
54outchar
55outchar
56outchar
57outchar
58jump 4
59
60#goto start
61label 4
62jump 1
63
64#end
65label 5
66exit
Note: See TracBrowser for help on using the browser.