Mercurial > repo
comparison interps/linguine/README @ 996:859f9b4339e6
<Gregor> tar xf egobot.tar.xz
author | HackBot |
---|---|
date | Sun, 09 Dec 2012 19:30:08 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
995:6883f5911eb7 | 996:859f9b4339e6 |
---|---|
1 Linguine programming language | |
2 by Jeffry Johnston (linguine@kidsquid.com) | |
3 November 23, 2005 | |
4 | |
5 | |
6 Introduction | |
7 ------------ | |
8 Linguine is designed as a successor to Spaghetti. The word linguine means | |
9 flattened pasta or spaghetti. True to this definition, Linguine programs | |
10 are much shorter and flatter compared to their long and skinny Spaghetti | |
11 ancestors. However, both languages share the yummy feature that program | |
12 lines may be arranged in any arbitrary order. Linguine adds multiple | |
13 pointers and unlimited storage and cell sizes for Turing completeness (and | |
14 that extra full quality). The command set is similar to Spaghetti, | |
15 although AND has been replaced by the more capable (and delectable) NAND, | |
16 and there is an additional integer output command. Try some Linguine to | |
17 satisfy your saucy esoteric appetite... mmm carbs! | |
18 | |
19 | |
20 Syntax | |
21 ------ | |
22 The program line format is: | |
23 | |
24 line[command]jump | |
25 | |
26 Each part is required, so there must be a line, left bracket, at least one | |
27 command, a right bracket, and a jump. Line is a unique line number for | |
28 this program line. Jump is the line number to jump to if all commands | |
29 on this line have completed without jumping. Line and jump are integer | |
30 values. Integers may be positive or negative and have no upper or lower | |
31 bounds. However, line may not be 0, as this line number is reserved for | |
32 jumping to line 0 to exit the program. There may be multiple commands per | |
33 program line, separated by commas. Valid commands are: | |
34 | |
35 Command Meaning | |
36 ------- ------- | |
37 x=y Assignment (x=y) | |
38 x+y Addition (x=x+y) | |
39 x-y Subtraction (x=x-y) | |
40 x|y NAND (x=x NAND y) | |
41 x>y Bit shift (x=x>>y if y is positive, else x=x<<y) | |
42 x? Input (x=input), returns -1 on EOF | |
43 x$ Character output (output character x) | |
44 x# Integer output (output integer x) | |
45 x<y:ifjump Less than (if x<y then jump to ifjump) | |
46 x~y:ifjump Equal to (if x==y then jump to ifjump) | |
47 x^ Time (x=Number of seconds since the epoch) | |
48 | |
49 x, y, and ifjump are integers. The x, y, and ifjump values may be | |
50 dereferenced by preceding them with the `*' character. Multiple | |
51 dereferences may be done by prepending additional `*' characters. | |
52 | |
53 If there are multiple commands on a line, each is executed in turn, left | |
54 to right, unless an ifjump occurs. | |
55 | |
56 | |
57 Memory | |
58 ------ | |
59 The memory tape indices extend without limit in both the positive and | |
60 negative directions. Each memory cell may store any integer value. All | |
61 cells initially hold a value of 0. | |
62 | |
63 | |
64 Dereference | |
65 ----------- | |
66 The x and y values work slightly differently (by default x is an address | |
67 and y is a plain value). Take the following example commands: | |
68 | |
69 10=20 | |
70 | |
71 So x is 10 and y is 20. That means that cell 10 is assigned the value 20. | |
72 | |
73 10=*20 | |
74 | |
75 That command assigns the value in cell 20 to cell 10. | |
76 | |
77 *10=20 | |
78 | |
79 Now, the value 20 won't be assigned to cell 10, it will instead be | |
80 assigned to the cell index given in (pointed to by) cell 10. | |
81 | |
82 *10=*20 | |
83 | |
84 Finally, the value in cell 20 is assigned to the cell pointed to by cell | |
85 10. | |
86 | |
87 | |
88 Code comments | |
89 ------------- | |
90 Linguine programs may include line comments with the ' (apostrophe) | |
91 character. Everything on the line after the comment character will be | |
92 ignored. | |
93 | |
94 | |
95 Line numbers and Jumps | |
96 ---------------------- | |
97 Every non-blank line (excluding comments) must have a leading line number. | |
98 Program execution will start at the lowest specified line number. Line | |
99 numbers may be negative. | |
100 | |
101 Every non-blank line must also specify the line that will next be jumped | |
102 to. Jumping to line 0 exits the program. | |
103 | |
104 Jump and ifjump values may be dereferenced in a manner exactly as the y | |
105 value. A runtime error will be generated if a dereferenced jump line | |
106 number is not defined in the program, even if that line would not be | |
107 branched to by the instruction. | |
108 | |
109 | |
110 History | |
111 ------- | |
112 November 23, 2005 Started | |
113 November 24, 2005 Released | |
114 November 25, 2005 Amended to include jump dereferencing. This | |
115 change does not affect existing programs, although | |
116 some may be more simple now. | |
117 | |
118 | |
119 Examples | |
120 -------- | |
121 'Hello World in Linguine | |
122 'Programmed by Jeffry Johnston, 2005 | |
123 1[0=72,0$,0+29,0$,0+7,0$,0$,0+3,0$,1=32,1$,0-24,0$,0+24,0$,0+3,0$,0-6,0$,0-8,0$,1+1,1$,1-23,1$]0 | |
124 | |
125 | |
126 'Cat program in Linguine | |
127 'Programmed by Jeffry Johnston, 2005 | |
128 1[0?,0$,0~10:0]1 | |
129 | |
130 | |
131 'Fibonacci sequence calculator in Linguine | |
132 'Programmed by Jeffry Johnston, 2005 | |
133 1[0=32,2=1,1#,0$,2#]2 | |
134 2[1+*2,3=*1,1=*2,2=*3,0$,2#]2 | |
135 | |
136 | |
137 '99 bottles of beer in Linguine | |
138 'Programmed by Jeffry Johnston, 2005 | |
139 1[0=99,2=32,3=10,4=44,5=46]2 | |
140 2[1=0]8 | |
141 3[4$,3$,1=1]8 | |
142 4[5$,3$,6=84,6$,6+13,6$,6+10,6$,6-6,6$,2$,6+10,6$,6-1,6$,6-9,6$,2$]5 | |
143 5[6-1,6$,6+11,6$,6+8,6$,6-9,6$,4$,2$,6+2,6$,6-15,6$,6+18,6$,6$,2$]6 | |
144 6[6-10,6$,6+11,6$,2$,6-19,6$,6+17,6$,6-3,6$,6+6,6$,6-7,6$,6-10,6$,4$,3$]7 | |
145 7[0-1,1=2]8 | |
146 8[0~0:9,0#]10 | |
147 9[6=78,6$,6+33,6$]10 | |
148 10[2$,6=98,6$,6+13,6$,6+5,6$,6$,6-8,6$,6-7,6$,0~1:11,6+14,6$]11 | |
149 11[2$,6=111,6$,6-9,6$,2$,6-4,6$,6+3,6$,6$,6+13,6$,1~0:12,1~1:4]12 | |
150 12[2$,6-3,6$,6-1,6$,2$,6+6,6$,6-12,6$,6-3,6$,2$]13 | |
151 13[6+18,6$,6-22,6$,6+11,6$,6$,1~0:3,5$,3$,0~0:0,3$]2 | |
152 | |
153 | |
154 'Digital root calculator in Linguine | |
155 'Programmed by Jeffry Johnston, 2005 | |
156 1[1?,1~10:3,0+*1,0-49,0<9:2,0-9]2 | |
157 2[0+1]1 | |
158 3[0#,1$]0 | |
159 | |
160 | |
161 'ROT13 in Linguine | |
162 'Programmed by Jeffry Johnston, 2005 | |
163 1[-2?,-2~10:3,-2<65:2,-2<91:5,-2<97:2,-2<123:6]2 | |
164 2[*-1=*-2,-1+1]1 | |
165 3[*-3~0:4,*-3$,-3+1]3 | |
166 4[-2$]0 | |
167 5[-2+13,-2<91:2,-2-26]2 | |
168 6[-2+13,-2<123:2,-2-26]2 | |
169 | |
170 | |
171 'BF interpreter in Linguine (Turing completeness proof by implementation) | |
172 'Programmed by Jeffry Johnston, 2005 | |
173 1[*-2?,*-2~33:2,-2+1]1 | |
174 2[*-2=-1,-2+1]3 | |
175 3[-3=**-1,-3~-1:0,-3~43:4,-3~44:6,-3~45:7,-3~46:9,-3~60:10,-3~62:11,-3~91:12,-3~93:14]15 | |
176 4[*-2+1,*-2~256:5]15 '+ | |
177 5[*-2=0]15 | |
178 6[*-2?,*-2~-1:5]15 ', | |
179 7[*-2-1,*-2~-1:8]15 '- | |
180 8[*-2=255]15 | |
181 9[*-2$]15 '. | |
182 10[-2-1]15 '< | |
183 11[-2+1]15 '> | |
184 12[*-2~0:13]15 '[ | |
185 13[-3=1]16 | |
186 14[-3=-1]16 '] | |
187 15[-1+1]3 | |
188 16[-4=1]17 | |
189 17[-1+*-3,*-1~91:18,*-1~93:19]20 | |
190 18[-4+*-3]20 | |
191 19[-4-*-3]20 | |
192 20[-4~0:21]17 | |
193 21[-3~1:15]3 | |
194 | |
195 | |
196 'pi calculator in Linguine | |
197 'Programmed by Jeffry Johnston, 2005 | |
198 1[0=1,1=0,2=1,3=1,4=46]2 | |
199 2[5=*0,5+*0,5+*0,-2=*5,-2+*1,-3=*2,-1=3]16 | |
200 3[6=*-2,-2=*5,-2+*0,-2+*1,-1=4]16 | |
201 4[6~*-2:8,-3=*3,-3+*3,-3+1,-2=*2,-1=5]14 | |
202 5[2=*-2,1+*0,1+*0,-2=*1,-1=6]14 | |
203 6[1=*-2,-2=*0,-3=*3,-1=7]14 | |
204 7[0=*-2,3+1]2 | |
205 8[6#,4~46:9]10 | |
206 9[4$,4=0]10 | |
207 10[-2=*0,-3=10,-1=11]14 | |
208 11[0=*-2,-2=*2,-3=*6,-1=12]14 | |
209 12[1-*-2,-2=*1,-3=10,-1=13]14 | |
210 13[1=*-2]2 | |
211 14[-4=*-3,-5=*-2,-2=0]15 | |
212 15[-4~0:*-1,-2+*-5,-4-1]15 | |
213 16[-4=*-2,-2=0]17 | |
214 17[-4<*-3:*-1,-4-*-3,-2+1]17 |