Skip to content

Instantly share code, notes, and snippets.

@spartanthe
Created April 7, 2017 07:20
Show Gist options
  • Save spartanthe/81f37b976269ee0bf4fd14d95e21357b to your computer and use it in GitHub Desktop.
Save spartanthe/81f37b976269ee0bf4fd14d95e21357b to your computer and use it in GitHub Desktop.
Generates INTERCAL program that prints input text
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace SICKPT
{
// http://catb.org/esr/intercal/ick.htm
// http://divingintointercal.blogspot.com/2007/03/part-dalawa-still-trying-to-write-hello.html
// http://www.angelfire.com/tx4/cus/notes/intercal.html
class Program
{
#region STATIC CRAP
#region CHARZ
#if false
01 $01 %0000:0001 %1000:0000 $80 $80 128 65 $41 %0100:0001 A %1000:0010 $82 $7E 126
02 $02 %0000:0010 %0100:0000 $40 $C0 192 66 $42 %0100:0010 B %0100:0010 $42 $BE 190
03 $03 %0000:0011 %1100:0000 $C0 $40 64 67 $43 %0100:0011 C %1100:0010 $C2 $3E 62
04 $04 %0000:0100 %0010:0000 $20 $E0 224 68 $44 %0100:0100 D %0010:0010 $22 $DE 222
05 $05 %0000:0101 %1010:0000 $A0 $60 96 69 $45 %0100:0101 E %1010:0010 $A2 $5E 94
06 $06 %0000:0110 %0110:0000 $60 $A0 160 70 $46 %0100:0110 F %0110:0010 $62 $9E 158
07 $07 %0000:0111 %1110:0000 $E0 $20 32 71 $47 %0100:0111 G %1110:0010 $E2 $1E 30
08 $08 %0000:1000 %0001:0000 $10 $F0 240 72 $48 %0100:1000 H %0001:0010 $12 $EE 238
09 $09 %0000:1001 %1001:0000 $90 $70 112 73 $49 %0100:1001 I %1001:0010 $92 $6E 110
10 $0A %0000:1010 %0101:0000 $50 $B0 176 74 $4A %0100:1010 J %0101:0010 $52 $AE 174
11 $0B %0000:1011 %1101:0000 $D0 $30 48 75 $4B %0100:1011 K %1101:0010 $D2 $2E 46
12 $0C %0000:1100 %0011:0000 $30 $D0 208 76 $4C %0100:1100 L %0011:0010 $32 $CE 206
13 $0D %0000:1101 %1011:0000 $B0 $50 80 77 $4D %0100:1101 M %1011:0010 $B2 $4E 78
14 $0E %0000:1110 %0111:0000 $70 $90 144 78 $4E %0100:1110 N %0111:0010 $72 $8E 142
15 $0F %0000:1111 %1111:0000 $F0 $10 16 79 $4F %0100:1111 O %1111:0010 $F2 $0E 14
16 $10 %0001:0000 %0000:1000 $08 $F8 248 80 $50 %0101:0000 P %0000:1010 $0A $F6 246
17 $11 %0001:0001 %1000:1000 $88 $78 120 81 $51 %0101:0001 Q %1000:1010 $8A $76 118
18 $12 %0001:0010 %0100:1000 $48 $B8 184 82 $52 %0101:0010 R %0100:1010 $4A $B6 182
19 $13 %0001:0011 %1100:1000 $C8 $38 56 83 $53 %0101:0011 S %1100:1010 $CA $36 54
20 $14 %0001:0100 %0010:1000 $28 $D8 216 84 $54 %0101:0100 T %0010:1010 $2A $D6 214
21 $15 %0001:0101 %1010:1000 $A8 $58 88 85 $55 %0101:0101 U %1010:1010 $AA $56 86
22 $16 %0001:0110 %0110:1000 $68 $98 152 86 $56 %0101:0110 V %0110:1010 $6A $96 150
23 $17 %0001:0111 %1110:1000 $E8 $18 24 87 $57 %0101:0111 W %1110:1010 $EA $16 22
24 $18 %0001:1000 %0001:1000 $18 $E8 232 88 $58 %0101:1000 X %0001:1010 $1A $E6 230
25 $19 %0001:1001 %1001:1000 $98 $68 104 89 $59 %0101:1001 Y %1001:1010 $9A $66 102
26 $1A %0001:1010 %0101:1000 $58 $A8 168 90 $5A %0101:1010 Z %0101:1010 $5A $A6 166
27 $1B %0001:1011 %1101:1000 $D8 $28 40 91 $5B %0101:1011 [ %1101:1010 $DA $26 38
28 $1C %0001:1100 %0011:1000 $38 $C8 200 92 $5C %0101:1100 \ %0011:1010 $3A $C6 198
29 $1D %0001:1101 %1011:1000 $B8 $48 72 93 $5D %0101:1101 ] %1011:1010 $BA $46 70
30 $1E %0001:1110 %0111:1000 $78 $88 136 94 $5E %0101:1110 ^ %0111:1010 $7A $86 134
31 $1F %0001:1111 %1111:1000 $F8 $08 8 95 $5F %0101:1111 _ %1111:1010 $FA $06 6
32 $20 %0010:0000 %0000:0100 $04 $FC 252 96 $60 %0110:0000 ` %0000:0110 $06 $FA 250
33 $21 %0010:0001 ! %1000:0100 $84 $7C 124 97 $61 %0110:0001 a %1000:0110 $86 $7A 122
34 $22 %0010:0010 " %0100:0100 $44 $BC 188 98 $62 %0110:0010 b %0100:0110 $46 $BA 186
35 $23 %0010:0011 # %1100:0100 $C4 $3C 60 99 $63 %0110:0011 c %1100:0110 $C6 $3A 58
36 $24 %0010:0100 $ %0010:0100 $24 $DC 220 100 $64 %0110:0100 d %0010:0110 $26 $DA 218
37 $25 %0010:0101 % %1010:0100 $A4 $5C 92 101 $65 %0110:0101 e %1010:0110 $A6 $5A 90
38 $26 %0010:0110 & %0110:0100 $64 $9C 156 102 $66 %0110:0110 f %0110:0110 $66 $9A 154
39 $27 %0010:0111 ' %1110:0100 $E4 $1C 28 103 $67 %0110:0111 g %1110:0110 $E6 $1A 26
40 $28 %0010:1000 ( %0001:0100 $14 $EC 236 104 $68 %0110:1000 h %0001:0110 $16 $EA 234
41 $29 %0010:1001 ) %1001:0100 $94 $6C 108 105 $69 %0110:1001 i %1001:0110 $96 $6A 106
42 $2A %0010:1010 * %0101:0100 $54 $AC 172 106 $6A %0110:1010 j %0101:0110 $56 $AA 170
43 $2B %0010:1011 + %1101:0100 $D4 $2C 44 107 $6B %0110:1011 k %1101:0110 $D6 $2A 42
44 $2C %0010:1100 , %0011:0100 $34 $CC 204 108 $6C %0110:1100 l %0011:0110 $36 $CA 202
45 $2D %0010:1101 - %1011:0100 $B4 $4C 76 109 $6D %0110:1101 m %1011:0110 $B6 $4A 74
46 $2E %0010:1110 . %0111:0100 $74 $8C 140 110 $6E %0110:1110 n %0111:0110 $76 $8A 138
47 $2F %0010:1111 / %1111:0100 $F4 $0C 12 111 $6F %0110:1111 o %1111:0110 $F6 $0A 10
48 $30 %0010:0000 0 %0000:0100 $04 $FC 252 112 $70 %0111:0000 p %0000:1110 $0E $F2 242
49 $31 %0011:0001 1 %1000:1100 $8C $74 116 113 $71 %0111:0001 q %1000:1110 $8E $72 114
50 $32 %0011:0010 2 %0100:1100 $4C $B4 180 114 $72 %0111:0010 r %0100:1110 $4E $B2 178
51 $33 %0011:0011 3 %1100:1100 $CC $34 52 115 $73 %0111:0011 s %1100:1110 $CE $32 50
52 $34 %0011:0100 4 %0010:1100 $2C $D4 212 116 $74 %0111:0100 t %0010:1110 $2E $D2 210
53 $35 %0011:0101 5 %1010:1100 $AC $54 84 117 $75 %0111:0101 u %1010:1110 $AE $52 82
54 $36 %0011:0110 6 %0110:1100 $6C $94 148 118 $76 %0111:0110 v %0110:1110 $6E $92 146
55 $37 %0011:0111 7 %1110:1100 $EC $14 20 119 $77 %0111:0111 w %1110:1110 $EE $12 18
56 $38 %0011:1000 8 %0001:1100 $1C $E4 228 120 $78 %0111:1000 x %0001:1110 $1E $E2 226
57 $39 %0011:1001 9 %1001:1100 $9C $64 100 121 $79 %0111:1001 y %1001:1110 $9E $62 98
58 $3A %0011:1010 : %0101:1100 $5C $A4 164 122 $7A %0111:1010 z %0101:1110 $5E $A2 162
59 $3B %0011:1011 ; %1101:1100 $DC $24 36 123 $7B %0111:1011 { %1101:1110 $DE $22 34
60 $3C %0011:1100 < %0011:1100 $3C $C4 196 124 $7C %0111:1100 | %0011:1110 $3E $C2 194
61 $3D %0011:1101 = %1011:1100 $BC $44 68 125 $7D %0111:1101 } %1011:1110 $BE $42 66
62 $3E %0011:1110 > %0111:1100 $7C $84 132 126 $7E %0111:1110 ~ %0111:1110 $7E $82 130
63 $3F %0011:1111 ? %1111:1100 $FC $04 4 127 $7F %0111:1111 %1111:1110 $FE $02 2
64 $40 %0100:0000 @ %0000:0010 $02 $FE 254
#endif
#endregion
private static readonly byte[] ASCII2Azbuka = //new char[1]()
{
0,
128, // 01 $01 %0000:0001 %1000:0000 $80 $80 128
192,
64,
224,
96,
160,
32,
240,
112,
176,
48,
208,
80,
144,
16,
248,
120,
184,
56,
216,
88,
152,
24,
232,
104,
168,
40,
200,
72,
136,
8,
252, // $20 (32) = ' ' - OK
124,
188,
60,
220,
92,
156,
28,
236,
108,
172,
44,
204,
76,
140,
12,
1, //252, // $30 - '0' -?????
116,
180,
52,
212,
84,
148,
20,
228,
100,
164,
36,
196,
68,
132,
4,
254, //1 col
126,
190,
62,
222,
94,
158,
30,
238,
110,
174,
46,
206,
78,
142,
14,
246,
118,
182,
54,
214,
86,
150,
22,
230,
102,
166,
38,
198,
70,
134,
6,
250,
122,
186,
58,
218,
90,
154,
26,
234,
106,
170,
42,
202,
74,
138,
10,
242,
114,
178,
50,
210,
82,
146,
18,
226,
98,
162,
34,
194,
66,
130,
2 // 127 $7F %0111:1111 %1111:1110 $FE $02 2
};
private static readonly char[]Azbuka2ASCII = Revert(ASCII2Azbuka);
private static char[] Revert(byte[] bubu)
{
char[] result = new char[256];
byte[] OneByte = { 0 };
char[] charz;
for (int i = 0; i < bubu.Length; i++)
{
OneByte[0] = (byte)i;
charz = Encoding.ASCII.GetChars(OneByte);
result[bubu[i]] = charz[0];
}
return result;
}
#endregion STATIC CRAP
static int Main(string[] args)
{
if (args.Length != 1)
{
PrintUsage();
return 1;
}
if (args[0].StartsWith("-dataurl:"))
{
string filePath = args[0].Substring(9);
string base64 = GetDataURL(filePath);
Console.WriteLine(base64);
return 0;
}
string fileName = args[0];
if (!File.Exists(fileName))
{
Console.WriteLine("File {0} doesn't exist.", fileName);
return 404;
}
// --gpl --- DO NOTE COPYRIGHT MMXIV S INCORPORATED
//Console.WriteLine("PLEASE NOTE: VARIABLES NOT FREED, USING GARBAGE");
int lineNo = 1;
string line;
using (var file = new StreamReader(fileName, Encoding.Default))
{
while ((line = file.ReadLine()) != null)
{
//Console.WriteLine("AT LINE {0}, LEN={1}", counter, line.Length);
ChewLine(line + "\n", lineNo);
lineNo++;
// LIMIT
//if (counter == 20)
// break; // NO LIMITS FOR SICK
}
}
Console.WriteLine("PLEASE GIVE UP");
//testc();
//testgen();
return 0;
}
public static string GetDataURL(string imgFile)
{
return "<img src=\"data:image/"
+ Path.GetExtension(imgFile).Replace(".","")
+ ";base64,"
+ Convert.ToBase64String(File.ReadAllBytes(imgFile)) + "\" />";
}
#region GEN
private static void testgen()
{
int[] array = Generate("I do not feel like sharing.");
//int[] array = Generate("Hello, world\n");
for (int idx = 0; idx < array.Length; idx++)
{
Console.WriteLine("{0}", array[idx]);
}
}
// converts string to series of numbers needed to print it
// @see http://divingintointercal.blogspot.com/2007/03/part-dalawa-still-trying-to-write-hello.html
private static int[] Generate(string s)
{
var result = new List<int>();
//byte[] charz = Encoding.ASCII.GetBytes(s);
//if (charz.Length != s.Length)
//{
// throw new NotImplementedException(
// String.Format("NON ASCII STRING: {0}", s));
//}
// LEAVE TAPE
//TapeHeadPos = 0; // reset tape
char[] charzUtf16 = s.ToCharArray();
byte[] oneByteBuffer = new byte[1];
foreach (char ch in s)
{
byte[] charz;
if (ch < 128)
{
oneByteBuffer[0] = (byte)ch;
charz = oneByteBuffer;
}
else
{
// Convert chr(160) => &#160;
string htmlEntity = String.Format("&#{0};", (int)ch);
charz = Encoding.ASCII.GetBytes(htmlEntity);
}
for (int idx = 0; idx < charz.Length; idx++)
{
// Required binary
byte requiredOutputByte = charz[idx];
// Reverse binary
byte reverseOutputByte = BitReverseTable[0 | requiredOutputByte];
// Required head position
int requiredHeadPosition = reverseOutputByte;
// Move head by
int moveHeadBy = TapeHeadPos - requiredHeadPosition;
if (moveHeadBy < 0)
moveHeadBy = 256 + moveHeadBy;
result.Add(moveHeadBy);
// Landing here
TapeHeadPos = requiredHeadPosition;
}
}
return result.ToArray();
}
private static readonly byte[] BitReverseTable =
{
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};
#endregion
#region OUTPUT
private static void testc()
{
testsio(110, 142, 222, 48, 242, 142, 128, 200, 42, 158, 192, 0,
112, 50, 206, 160, 192, 48, 162, 54, 184, 144, 56, 184, 32, 144,
114, 36
);
}
private static int TapeHeadPos = 0;
private static int IOutLine = 0;
private readonly static byte[] OneByte = { 0 };
private const byte Whirpool = 254; // @ = 254
private const char ChWhirpool = '@'; // = 254
private static void testsio(params int[] numbers)
{
// DON'T RESET TapeHeadPos
TapeHeadPos = 0; // reset tape
//#warning WHAT HAPPENS AT LINE BREAK???
//if (TapeHeadPos != 0)
//TapeHeadPos = 10;
//TapeHeadPos = BitReverseTable[10];
for (int i = 0; i < numbers.Length; i++)
charOut(numbers[i]);
}
private static void charOut(int num)
{
char ttt = Azbuka2ASCII.FirstOrDefault(c => c == '.');
char ttt3 = Azbuka2ASCII.FirstOrDefault(c => c == '\x0A');
char ch;
if (num < 256)
{
TapeHeadPos = (TapeHeadPos + num) % 256;
ch = Azbuka2ASCII[TapeHeadPos];
}
else
{
throw new NotImplementedException(
String.Format("NON ASCII CHAR: #{0}", num));
ch = ChWhirpool;
}
Console.Write(ch);
}
#endregion
#if false
//case '}': // binary output [info, number]
// a = code[ip++];
// b = code[ip++];
// binaryOutput((a << 16) | b);
// break;
protected readonly static int VAR_SCALAR16 = 0;
protected readonly static int VAR_SCALAR32 = 1;
protected readonly static int VAR_ARRAY16 = 2;
protected readonly static int VAR_ARRAY32 = 3;
protected static int hints, line, lastin, lastout = 0;
protected readonly static int HDR_DATASIZE = 1;
//? protected static short[] array16 = new short[code[HDR_DATASIZE + VAR_ARRAY16]];
//array16 = new Array16[b = code[HDR_DATASIZE + VAR_ARRAY16]]; a += b;
protected static void binaryOutput(int var)// throws IntercalException, IOException {
{
if ((var >> 16) == VAR_ARRAY16) {
Array16 source;
byte[] buf;
int i, c;
source = array16[var & 0xffff];
//if ((source == null) || (source.dimensions.length != 1)) fail(241);
buf = new byte[source.data.length];
for (i=0; i<buf.Length; i++) {
lastout = c = lastout - source.data[i];
c = (c & 0x0f) << 4 | (c & 0xf0) >> 4;
c = (c & 0x33) << 2 | (c & 0xcc) >> 2;
c = (c & 0x55) << 1 | (c & 0xaa) >> 1;
buf[i] = (byte) (c & 0xff);
}
Console.WriteLine(buf);
}
}
protected static void plainOutput(int i) //throws IntercalException, IOException {
{
long l;
//if (outw == null) outw = new PrintWriter(out);
l = ((long) i) & 0xffffffffL;
//if ((hints & HINT_WIMP) != 0)
// Console.WriteLine((l);
//else
// Console.WriteLine((butcher(l, (hints & HINT_CLOCKFACE) != 0 ? 1 : 0));
Console.WriteLine(butcher(l, 0));
//outw.flush();
}
protected static readonly int NUM_MAXDIGITS = 10;
protected static readonly int NUM_MAXROMAN = NUM_MAXDIGITS * 4;
protected static String butcher(long value, int mode)
{
int i, j, digit, sig;
char[] result, overbar;
// zero is special
if (value == 0)
return "_\n ";
result = new char[NUM_MAXROMAN];
overbar = new char[NUM_MAXROMAN];
i = NUM_MAXROMAN;
for (sig = 0; (sig < NUM_MAXDIGITS) && (value > 0); sig++)
{
digit = (int)(value % 10);
value /= 10;
//for (j = brnTrans[mode][digit][0]; j > 0; j--)
for (j = brnTrans[mode,digit,0]; j > 0; j--)
{
//result[--i] = brnDigit[sig][brnTrans[mode][digit][j]];
result[--i] = brnDigit[sig, brnTrans[mode,digit,j]];
//overbar[i] = brnOverbar[sig][brnTrans[mode][digit][j]];
overbar[i] = brnOverbar[sig, brnTrans[mode, digit, j]];
}
}
return new String(overbar, i, NUM_MAXROMAN - i) + "\n" + new String(result, i, NUM_MAXROMAN - i);
}
/*
protected static int[] numNumbers = {
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, // English
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // Sanskrit
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // Basque
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // Tagalog
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // Classical Nahuatl
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // Georgian
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // Kwakiutl (technically, Kwak'wala)
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // Volap\"uk
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, // Esperanto
};
*/
//protected static short[][][] brnTrans = {
protected static short[,,] brnTrans = {
{ // "normal" butchered mode
{ 0, 0, 0, 0, 0 }, { 1, 0, 0, 0, 0 },
{ 2, 0, 0, 0, 0 }, { 3, 0, 0, 0, 0 },
{ 2, 1, 2, 0, 0 }, { 1, 2, 0, 0, 0 },
{ 2, 2, 1, 0, 0 }, { 3, 2, 1, 1, 0 },
{ 4, 2, 1, 1, 1 }, { 2, 1, 3, 0, 0 },
},
{ // clockface mode
{ 0, 0, 0, 0, 0 }, { 1, 0, 0, 0, 0 },
{ 2, 0, 0, 0, 0 }, { 3, 0, 0, 0, 0 },
{ 4, 0, 0, 0, 0 }, { 1, 2, 0, 0, 0 }, // <-- here's the difference
{ 2, 2, 1, 0, 0 }, { 3, 2, 1, 1, 0 },
{ 4, 2, 1, 1, 1 }, { 2, 1, 3, 0, 0 },
},
};
//protected static char[][] brnDigit =
protected static char[,] brnDigit =
{
{ 'I', 'I', 'V', 'X' }, { 'X', 'X', 'L', 'C' },
{ 'C', 'C', 'D', 'M' }, { 'M', 'I', 'V', 'X' },
{ 'X', 'X', 'L', 'C' }, { 'C', 'C', 'D', 'M' },
{ 'M', 'i', 'v', 'x' }, { 'x', 'x', 'l', 'c' },
{ 'c', 'c', 'd', 'm' }, { 'm', 'i', 'v', 'x' },
};
//protected static char[][] brnOverbar =
protected static char[,] brnOverbar =
{
{ ' ', ' ', ' ', ' ' }, { ' ', ' ', ' ', ' ' },
{ ' ', ' ', ' ', ' ' }, { ' ', '_', '_', '_' },
{ '_', '_', '_', '_' }, { '_', '_', '_', '_' },
{ '_', ' ', ' ', ' ' }, { ' ', ' ', ' ', ' ' },
{ ' ', ' ', ' ', ' ' }, { ' ', '_', '_', '_' },
};
#endif
private static void PrintUsage()
{
Console.WriteLine("Usage");
}
private static void ChewLine(string line, int arrVar = 1)
{
int[] numbers = Generate(line);
if (numbers.Length == 0)
{
// Empty line
ChewLine("\n", arrVar);
return;
}
GENOUTLN(String.Format("DO ,{0} <- #{1}", arrVar, numbers.Length));
for (int idx = 0; idx < numbers.Length; idx++)
{
int number = numbers[idx];
GENOUTLN(String.Format("DO ,{0}SUB#{1} <- #{2}", arrVar, idx + 1, number));
}
GENOUTLN(String.Format("DO READ OUT ,{0}", arrVar));
// Clean up
//GENOUTLN("DO IGNORE ,1");
//GENOUTLN("DO STASH ,1");
//GENOUTLN("REMEMBER ,1");
//Console.WriteLine("PLEASE REMEMBER ,1");
//GENOUTLN("DO RETRIEVE ,1");
//Console.WriteLine("DO RETRIEVE ,1");
}
private static void GENOUTLN(string iCodeLine)
{
string politePrefix = (IOutLine % 4) == 2 ? "PLEASE " : "";
Console.WriteLine("{0}{1}", politePrefix, iCodeLine);
IOutLine++;
}
private static string To2(object o)
{
return String.Format(BinaryFormatter.Instance, "{0:B}", o);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment