Compiler/Sample programs: Difference between revisions

no edit summary
(Additional samples)
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1:
Additional sample programs for the Tiny Compiler, referenced by the following tasks:
 
* [[Compiler/lexical_analyzer|Lexical Analyzer task]]
* [[Compiler/syntax_analyzer|Syntax Analyzer task]]
* [[Compiler/code_generator|Code Generator task]]
* [[Compiler/virtual_machine_interpreter|Virtual Machine Interpreter task]]
* [[Compiler/AST_interpreter|AST Interpreter task]]
 
<hr>
__TOC__
 
=={{header|GCDHello world/Text}}==
 
{| class="wikitable"
|-
! Input to lex
! Output from lex, input to parse
! Output from parse
! Output from gen, input to VM
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
/*
Hello world
*/
print("Hello, World!\n");
</syntaxhighlight>
 
 
| style="vertical-align:top" |
<b><pre>
4 1 Keyword_print
4 6 LeftParen
4 7 String "Hello, World!\n"
4 24 RightParen
4 25 Semicolon
5 1 End_of_input
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
Sequence
;
Sequence
;
Prts
String "Hello, World!\n"
;
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
Datasize: 0 Strings: 1
"Hello, World!\n"
0 push 0
5 prts
6 halt
</pre></b>
|}
 
;And the output is:
<pre>
>lex ..\hello.t | parse | gen | vm
Hello, World!
</pre>
 
=={{header|Phoenix number}}==
 
{| class="wikitable"
|-
! Input to lex
! Output from lex, input to parse
! Output from parse
! Output from gen, input to VM
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
/*
Show Ident and Integers
*/
phoenix_number = 142857;
print(phoenix_number, "\n");
</syntaxhighlight>
 
 
| style="vertical-align:top" |
<b><pre>
4 1 Identifier phoenix_number
4 16 Op_assign
4 18 Integer 142857
4 24 Semicolon
5 1 Keyword_print
5 6 LeftParen
5 7 Identifier phoenix_number
5 21 Comma
5 23 String "\n"
5 27 RightParen
5 28 Semicolon
6 1 End_of_input
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
Sequence
Sequence
;
Assign
Identifier phoenix_number
Integer 142857
Sequence
Sequence
;
Prti
Identifier phoenix_number
;
Prts
String "\n"
;
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
Datasize: 1 Strings: 1
"\n"
0 push 142857
5 store [0]
10 fetch [0]
15 prti
16 push 0
21 prts
22 halt
</pre></b>
|}
 
;And the output is:
<pre>
>lex ..\phoenix_number.t | parse | gen | vm
142857
</pre>
 
 
=={{header|All symbols}}==
 
{| class="wikitable"
|-
! Input to lex
! Output from lex, input to parse
! Output from parse
! Output from gen, input to VM
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
/*
All lexical tokens - not syntactically correct, but that will
have to wait until syntax analysis
*/
/* Print */ print /* Sub */ -
/* Putc */ putc /* Lss */ <
/* If */ if /* Gtr */ >
/* Else */ else /* Leq */ <=
/* While */ while /* Geq */ >=
/* Lbrace */ { /* Eq */ ==
/* Rbrace */ } /* Neq */ !=
/* Lparen */ ( /* And */ &&
/* Rparen */ ) /* Or */ ||
/* Uminus */ - /* Semi */ ;
/* Not */ ! /* Comma */ ,
/* Mul */ * /* Assign */ =
/* Div */ / /* Integer */ 42
/* Mod */ % /* String */ "String literal"
/* Add */ + /* Ident */ variable_name
/* character literal */ '\n'
/* character literal */ '\\'
/* character literal */ ' '
</syntaxhighlight>
 
 
| style="vertical-align:top" |
<b><pre>
5 16 Keyword_print
5 40 Op_subtract
6 16 Keyword_putc
6 40 Op_less
7 16 Keyword_if
7 40 Op_greater
8 16 Keyword_else
8 40 Op_lessequal
9 16 Keyword_while
9 40 Op_greaterequal
10 16 LeftBrace
10 40 Op_equal
11 16 RightBrace
11 40 Op_notequal
12 16 LeftParen
12 40 Op_and
13 16 RightParen
13 40 Op_or
14 16 Op_subtract
14 40 Semicolon
15 16 Op_not
15 40 Comma
16 16 Op_multiply
16 40 Op_assign
17 16 Op_divide
17 40 Integer 42
18 16 Op_mod
18 40 String "String literal"
19 16 Op_add
19 40 Identifier variable_name
20 26 Integer 10
21 26 Integer 92
22 26 Integer 32
23 1 End_of_input
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
(5, 40) Print: Expecting '(', found '-'
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
</pre></b>
|}
 
=={{header|Test case 4}}==
 
{| class="wikitable"
|-
! Input to lex
! Output from lex, input to parse
! Output from parse
! Output from gen, input to VM
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
/*** test printing, embedded \n and comments with lots of '*' ***/
print(42);
print("\nHello World\nGood Bye\nok\n");
print("Print a slash n - \\n.\n");
</syntaxhighlight>
 
 
| style="vertical-align:top" |
<b><pre>
2 1 Keyword_print
2 6 LeftParen
2 7 Integer 42
2 9 RightParen
2 10 Semicolon
3 1 Keyword_print
3 6 LeftParen
3 7 String "\nHello World\nGood Bye\nok\n"
3 38 RightParen
3 39 Semicolon
4 1 Keyword_print
4 6 LeftParen
4 7 String "Print a slash n - \\n.\n"
4 33 RightParen
4 34 Semicolon
5 1 End_of_input
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
Sequence
Sequence
Sequence
;
Sequence
;
Prti
Integer 42
;
Sequence
;
Prts
String "\nHello World\nGood Bye\nok\n"
;
Sequence
;
Prts
String "Print a slash n - \\n.\n"
;
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
Datasize: 0 Strings: 2
"\nHello World\nGood Bye\nok\n"
"Print a slash n - \\n.\n"
0 push 42
5 prti
6 push 0
11 prts
12 push 1
17 prts
18 halt
</pre></b>
|}
 
;And the output is:
<pre>
>lex ..\testcase4.t | parse | gen | vm
42
Hello World
Good Bye
ok
Print a slash n - \n.
</pre>
 
=={{header|Count}}==
 
{| class="wikitable"
|-
! Input to lex
! Output from lex, input to parse
! Output from parse
! Output from gen, input to VM
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
count = 1;
while (count < 10) {
print("count is: ", count, "\n");
count = count + 1;
}
</syntaxhighlight>
 
 
| style="vertical-align:top" |
<b><pre>
1 1 Identifier count
1 7 Op_assign
1 9 Integer 1
1 10 Semicolon
2 1 Keyword_while
2 7 LeftParen
2 8 Identifier count
2 14 Op_less
2 16 Integer 10
2 18 RightParen
2 20 LeftBrace
3 5 Keyword_print
3 10 LeftParen
3 11 String "count is: "
3 23 Comma
3 25 Identifier count
3 30 Comma
3 32 String "\n"
3 36 RightParen
3 37 Semicolon
4 5 Identifier count
4 11 Op_assign
4 13 Identifier count
4 19 Op_add
4 21 Integer 1
4 22 Semicolon
5 1 RightBrace
6 1 End_of_input
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
Sequence
Sequence
;
Assign
Identifier count
Integer 1
While
Less
Identifier count
Integer 10
Sequence
Sequence
;
Sequence
Sequence
Sequence
;
Prts
String "count is: "
;
Prti
Identifier count
;
Prts
String "\n"
;
Assign
Identifier count
Add
Identifier count
Integer 1
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
Datasize: 1 Strings: 2
"count is: "
"\n"
0 push 1
5 store [0]
10 fetch [0]
15 push 10
20 lt
21 jz (43) 65
26 push 0
31 prts
32 fetch [0]
37 prti
38 push 1
43 prts
44 fetch [0]
49 push 1
54 add
55 store [0]
60 jmp (-51) 10
65 halt
</pre></b>
|}
 
;And the output is:
<pre>
>lex ..\count.t | parse | gen | vm
count is: 1
count is: 2
count is: 3
count is: 4
count is: 5
count is: 6
count is: 7
count is: 8
count is: 9
</pre>
 
=={{header|100_doors}}==
 
{| class="wikitable"
|-
! Input to lex
! Output from lex, input to parse
! Output from parse
! Output from gen, input to VM
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
/* 100 Doors */
i = 1;
while (i * i <= 100) {
print("door ", i * i, " is open\n");
i = i + 1;
}
</syntaxhighlight>
 
 
| style="vertical-align:top" |
<b><pre>
lex ..\100doors.t
2 1 Identifier i
2 3 Op_assign
2 5 Integer 1
2 6 Semicolon
3 1 Keyword_while
3 7 LeftParen
3 8 Identifier i
3 10 Op_multiply
3 12 Identifier i
3 14 Op_lessequal
3 17 Integer 100
3 20 RightParen
3 22 LeftBrace
4 5 Keyword_print
4 10 LeftParen
4 11 String "door "
4 18 Comma
4 20 Identifier i
4 22 Op_multiply
4 24 Identifier i
4 25 Comma
4 27 String " is open\n"
4 39 RightParen
4 40 Semicolon
5 5 Identifier i
5 7 Op_assign
5 9 Identifier i
5 11 Op_add
5 13 Integer 1
5 14 Semicolon
6 1 RightBrace
7 1 End_of_input
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
lex ..\100doors.t | parse
Sequence
Sequence
;
Assign
Identifier i
Integer 1
While
LessEqual
Multiply
Identifier i
Identifier i
Integer 100
Sequence
Sequence
;
Sequence
Sequence
Sequence
;
Prts
String "door "
;
Prti
Multiply
Identifier i
Identifier i
;
Prts
String " is open\n"
;
Assign
Identifier i
Add
Identifier i
Integer 1
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
lex ..\100doors.t | parse | gen
Datasize: 1 Strings: 2
"door "
" is open\n"
0 push 1
5 store [0]
10 fetch [0]
15 fetch [0]
20 mul
21 push 100
26 le
27 jz (49) 77
32 push 0
37 prts
38 fetch [0]
43 fetch [0]
48 mul
49 prti
50 push 1
55 prts
56 fetch [0]
61 push 1
66 add
67 store [0]
72 jmp (-63) 10
77 halt
</pre></b>
|}
 
;And the output is:
<pre>
lex ..\100doors.t | parse | gen | vm
door 1 is open
door 4 is open
door 9 is open
door 16 is open
door 25 is open
door 36 is open
door 49 is open
door 64 is open
door 81 is open
door 100 is open
</pre>
 
=={{header|Negative tests}}==
 
{| class="wikitable"
|-
! Input to lex
! Output from lex, input to parse
! Output from parse
! Output from gen, input to VM
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
a = (-1 * ((-1 * (5 * 15)) / 10));
print(a, "\n");
b = -a;
print(b, "\n");
print(-b, "\n");
print(-(1), "\n");
</syntaxhighlight>
 
 
| style="vertical-align:top" |
<b><pre>
1 1 Identifier a
1 3 Op_assign
1 5 LeftParen
1 6 Op_subtract
1 7 Integer 1
1 9 Op_multiply
1 11 LeftParen
1 12 LeftParen
1 13 Op_subtract
1 14 Integer 1
1 16 Op_multiply
1 18 LeftParen
1 19 Integer 5
1 21 Op_multiply
1 23 Integer 15
1 25 RightParen
1 26 RightParen
1 28 Op_divide
1 30 Integer 10
1 32 RightParen
1 33 RightParen
1 34 Semicolon
2 1 Keyword_print
2 6 LeftParen
2 7 Identifier a
2 8 Comma
2 10 String "\n"
2 14 RightParen
2 15 Semicolon
3 1 Identifier b
3 3 Op_assign
3 5 Op_subtract
3 6 Identifier a
3 7 Semicolon
4 1 Keyword_print
4 6 LeftParen
4 7 Identifier b
4 8 Comma
4 10 String "\n"
4 14 RightParen
4 15 Semicolon
5 1 Keyword_print
5 6 LeftParen
5 7 Op_subtract
5 8 Identifier b
5 9 Comma
5 11 String "\n"
5 15 RightParen
5 16 Semicolon
6 1 Keyword_print
6 6 LeftParen
6 7 Op_subtract
6 8 LeftParen
6 9 Integer 1
6 10 RightParen
6 11 Comma
6 13 String "\n"
6 17 RightParen
6 18 Semicolon
7 1 End_of_input
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
Sequence
Sequence
Sequence
Sequence
Sequence
Sequence
;
Assign
Identifier a
Multiply
Negate
Integer 1
;
Divide
Multiply
Negate
Integer 1
;
Multiply
Integer 5
Integer 15
Integer 10
Sequence
Sequence
;
Prti
Identifier a
;
Prts
String "\n"
;
Assign
Identifier b
Negate
Identifier a
;
Sequence
Sequence
;
Prti
Identifier b
;
Prts
String "\n"
;
Sequence
Sequence
;
Prti
Negate
Identifier b
;
;
Prts
String "\n"
;
Sequence
Sequence
;
Prti
Negate
Integer 1
;
;
Prts
String "\n"
;
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
Datasize: 2 Strings: 1
"\n"
0 push 1
5 neg
6 push 1
11 neg
12 push 5
17 push 15
22 mul
23 mul
24 push 10
29 div
30 mul
31 store [0]
36 fetch [0]
41 prti
42 push 0
47 prts
48 fetch [0]
53 neg
54 store [1]
59 fetch [1]
64 prti
65 push 0
70 prts
71 fetch [1]
76 neg
77 prti
78 push 0
83 prts
84 push 1
89 neg
90 prti
91 push 0
96 prts
97 halt
</pre></b>
|}
 
;And the output is:
<pre>
>lex ..\negative.t | parse | gen | vm
7
-7
7
-1
</pre>
 
=={{header|Deep}}==
 
{| class="wikitable"
|-
! Input to lex
! Output from lex, input to parse
! Output from parse
! Output from gen, input to VM
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
print(---------------------------------+++5, "\n");
print(((((((((3 + 2) * ((((((2))))))))))))), "\n");
 
if (1) { if (1) { if (1) { if (1) { if (1) { print(15, "\n"); } } } } }
</syntaxhighlight>
 
 
| style="vertical-align:top" |
<b><pre>
1 1 Keyword_print
1 6 LeftParen
1 7 Op_subtract
1 8 Op_subtract
1 9 Op_subtract
1 10 Op_subtract
1 11 Op_subtract
1 12 Op_subtract
1 13 Op_subtract
1 14 Op_subtract
1 15 Op_subtract
1 16 Op_subtract
1 17 Op_subtract
1 18 Op_subtract
1 19 Op_subtract
1 20 Op_subtract
1 21 Op_subtract
1 22 Op_subtract
1 23 Op_subtract
1 24 Op_subtract
1 25 Op_subtract
1 26 Op_subtract
1 27 Op_subtract
1 28 Op_subtract
1 29 Op_subtract
1 30 Op_subtract
1 31 Op_subtract
1 32 Op_subtract
1 33 Op_subtract
1 34 Op_subtract
1 35 Op_subtract
1 36 Op_subtract
1 37 Op_subtract
1 38 Op_subtract
1 39 Op_subtract
1 40 Op_add
1 41 Op_add
1 42 Op_add
1 43 Integer 5
1 44 Comma
1 46 String "\n"
1 50 RightParen
1 51 Semicolon
2 1 Keyword_print
2 6 LeftParen
2 7 LeftParen
2 8 LeftParen
2 9 LeftParen
2 10 LeftParen
2 11 LeftParen
2 12 LeftParen
2 13 LeftParen
2 14 LeftParen
2 15 Integer 3
2 17 Op_add
2 19 Integer 2
2 20 RightParen
2 22 Op_multiply
2 24 LeftParen
2 25 LeftParen
2 26 LeftParen
2 27 LeftParen
2 28 LeftParen
2 29 LeftParen
2 30 Integer 2
2 31 RightParen
2 32 RightParen
2 33 RightParen
2 34 RightParen
2 35 RightParen
2 36 RightParen
2 37 RightParen
2 38 RightParen
2 39 RightParen
2 40 RightParen
2 41 RightParen
2 42 RightParen
2 43 RightParen
2 44 Comma
2 46 String "\n"
2 50 RightParen
2 51 Semicolon
4 1 Keyword_if
4 4 LeftParen
4 5 Integer 1
4 6 RightParen
4 8 LeftBrace
4 10 Keyword_if
4 13 LeftParen
4 14 Integer 1
4 15 RightParen
4 17 LeftBrace
4 19 Keyword_if
4 22 LeftParen
4 23 Integer 1
4 24 RightParen
4 26 LeftBrace
4 28 Keyword_if
4 31 LeftParen
4 32 Integer 1
4 33 RightParen
4 35 LeftBrace
4 37 Keyword_if
4 40 LeftParen
4 41 Integer 1
4 42 RightParen
4 44 LeftBrace
4 46 Keyword_print
4 51 LeftParen
4 52 Integer 15
4 54 Comma
4 56 String "\n"
4 60 RightParen
4 61 Semicolon
4 63 RightBrace
4 65 RightBrace
4 67 RightBrace
4 69 RightBrace
4 71 RightBrace
5 1 End_of_input
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
Sequence
Sequence
Sequence
;
Sequence
Sequence
;
Prti
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Negate
Integer 5
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
Prts
String "\n"
;
Sequence
Sequence
;
Prti
Multiply
Add
Integer 3
Integer 2
Integer 2
;
Prts
String "\n"
;
If
Integer 1
If
Sequence
;
If
Integer 1
If
Sequence
;
If
Integer 1
If
Sequence
;
If
Integer 1
If
Sequence
;
If
Integer 1
If
Sequence
;
Sequence
Sequence
;
Prti
Integer 15
;
Prts
String "\n"
;
;
;
;
;
;
</pre></b>
 
 
| style="vertical-align:top" |
<b><pre>
Datasize: 0 Strings: 1
"\n"
0 push 5
5 neg
6 neg
7 neg
8 neg
9 neg
10 neg
11 neg
12 neg
13 neg
14 neg
15 neg
16 neg
17 neg
18 neg
19 neg
20 neg
21 neg
22 neg
23 neg
24 neg
25 neg
26 neg
27 neg
28 neg
29 neg
30 neg
31 neg
32 neg
33 neg
34 neg
35 neg
36 neg
37 neg
38 prti
39 push 0
44 prts
45 push 3
50 push 2
55 add
56 push 2
61 mul
62 prti
63 push 0
68 prts
69 push 1
74 jz (56) 131
79 push 1
84 jz (46) 131
89 push 1
94 jz (36) 131
99 push 1
104 jz (26) 131
109 push 1
114 jz (16) 131
119 push 15
124 prti
125 push 0
130 prts
131 halt
</pre></b>
|}
 
;And the output is:
<pre>
>lex ..\deep.t | parse | gen | vm
-5
10
15
</pre>
 
 
=={{header|Greatest common divisor}}==
{| class="wikitable"
|-
Line 11 ⟶ 1,162:
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
<lang c>
/* Compute the gcd of 1071, 1029: 21 */
 
Line 23 ⟶ 1,174:
}
print(a);
</syntaxhighlight>
</lang>
 
 
Line 144 ⟶ 1,295:
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
<lang c>
/* 12 factorial is 479001600 */
 
Line 155 ⟶ 1,306:
}
print(result);
</syntaxhighlight>
</lang>
 
 
Line 271 ⟶ 1,422:
|}
 
=={{header|Fibonacci sequence}}==
 
{| class="wikitable"
Line 281 ⟶ 1,432:
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
<lang c>
/* fibonacci of 44 is 701408733 */
 
Line 295 ⟶ 1,446:
}
print(w, "\n");
</syntaxhighlight>
</lang>
 
 
Line 351 ⟶ 1,502:
13 14 RightParen
13 15 Semicolon
1514 1 End_of_input
</pre></b>
 
Line 459 ⟶ 1,610:
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
<lang c>
/* FizzBuzz */
i = 1;
Line 475 ⟶ 1,626:
i = i + 1;
}
</syntaxhighlight>
</lang>
 
 
Line 687 ⟶ 1,838:
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
<lang c>
/* 99 bottles */
bottles = 99;
while (bottles >= 0) {
print(bottles, " bottles of beer on the wall\n");
print(bottles, " bottles of beer\n");
print("Take one down, pass it around\n");
bottles = bottles - 1;
print(bottles, " bottles of beer on the wall\n\n");
bottles = bottles - 1;
}
</syntaxhighlight>
</lang>
 
 
Line 709 ⟶ 1,860:
3 7 LeftParen
3 8 Identifier bottles
3 16 Op_greaterequalOp_greater
3 1918 Integer 0
3 2019 RightParen
3 2221 LeftBrace
4 5 Keyword_print
4 10 LeftParen
Line 732 ⟶ 1,883:
6 44 RightParen
6 45 Semicolon
7 5 Keyword_printIdentifier bottles
7 1013 LeftParenOp_assign
7 1115 Identifier bottles
7 1823 CommaOp_subtract
7 2025 StringInteger " bottles of beer on the wall\n\n"1
7 5426 RightParenSemicolon
78 55 Semicolon5 Keyword_print
8 10 5 Identifier bottlesLeftParen
8 1311 Op_assignIdentifier bottles
8 1518 Identifier bottlesComma
8 20 String " bottles of beer on the wall\n\n"
8 23 Op_subtract
8 2554 Integer 1RightParen
8 2655 Semicolon
9 1 RightBrace
10 1 End_of_input
Line 791 ⟶ 1,942:
String "Take one down, pass it around\n"
;
Assign
Identifier bottles
Subtract
Identifier bottles
Integer 1
Sequence
Sequence
Line 800 ⟶ 1,956:
String " bottles of beer on the wall\n\n"
;
Assign
Identifier bottles
Subtract
Identifier bottles
Integer 1
</pre></b>
 
Line 832 ⟶ 1,983:
55 prts
56 fetch [0]
61 prtipush 1
6266 push 3sub
67 prtsstore [0]
6872 fetch [0]
7377 push 1prti
78 subpush 3
7983 store [0]prts
84 jmp (-75) 10
89 halt
Line 851 ⟶ 2,002:
99 bottles of beer
Take one down, pass it around
9998 bottles of beer on the wall
 
98 bottles of beer on the wall
98 bottles of beer
Take one down, pass it around
98 bottles of beer on the wall
 
97 bottles of beer on the wall
97 bottles of beer
Take one down, pass it around
97 bottles of beer on the wall
Line 868 ⟶ 2,014:
2 bottles of beer
Take one down, pass it around
21 bottles of beer on the wall
 
1 bottles of beer on the wall
1 bottles of beer
Take one down, pass it around
10 bottles of beer on the wall
 
0 bottles of beer on the wall
0 bottles of beer
Take one down, pass it around
0 bottles of beer on the wall
</pre>
 
Line 891 ⟶ 2,033:
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
<lang c>
/*
Simple prime number generator
Line 912 ⟶ 2,054:
}
print("Total primes found: ", count, "\n");
</syntaxhighlight>
</lang>
 
 
Line 1,226 ⟶ 2,368:
|-
| style="vertical-align:top" |
<syntaxhighlight lang="c">
<lang c>
{
/*
Line 1,269 ⟶ 2,411:
}
}
</syntaxhighlight>
</lang>