Compiler/Sample programs: Difference between revisions

Fix bug in C solution
(Additional samples)
(Fix bug in C solution)
Line 1,696:
/* 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");
print(bottles, " bottles of beer on the wall\n\n");
bottles = bottles - 1;
print(bottles, " bottles of beer on the wall\n\n");
}
</lang>
Line 1,715:
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 1,738:
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
98 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 1,797:
String "Take one down, pass it around\n"
;
Assign
Identifier bottles
Subtract
Identifier bottles
Integer 1
Sequence
Sequence
Line 1,806 ⟶ 1,811:
String " bottles of beer on the wall\n\n"
;
Assign
Identifier bottles
Subtract
Identifier bottles
Integer 1
</pre></b>
 
Line 1,838:
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 1,857:
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 1,874 ⟶ 1,869:
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>
 
155

edits