Aer Interpreter Source
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.2 KiB

  1. class Test {
  2. public void goto_test1() {
  3. int $i = 0;
  4. a:
  5. print("Foo $i\n");
  6. if($i > 5)
  7. goto b;
  8. $i++;
  9. goto a;
  10. b:
  11. print("Bar $i\n\n");
  12. }
  13. public void goto_test2(int $a = 2) {
  14. switch($a) {
  15. case 1:
  16. print("\$a is 1\n\n");
  17. goto out;
  18. case 2:
  19. print("\$a is 2\n\n");
  20. goto out;
  21. case 3:
  22. print("\$a is 3\n\n");
  23. goto out;
  24. case 4:
  25. print("\$a is 4\n\n");
  26. goto out;
  27. }
  28. out:
  29. }
  30. public void goto_test3() {
  31. int $a = 10;
  32. a:
  33. $a--;
  34. print("$a\n");
  35. if($a > 5) {
  36. goto a;
  37. }
  38. print("\n");
  39. }
  40. public void goto_test4() {
  41. string[] $headers = {'subject', 'bcc', 'to', 'cc', 'date', 'sender'};
  42. int $pos = 0;
  43. int $c;
  44. hIterator: {
  45. $c = 0;
  46. print($headers[$pos], "\n");
  47. cIterator: {
  48. print(" ", $headers[$pos][$c], "\n");
  49. if(strlen($headers[$pos]) <= ++$c) {
  50. goto cIteratorExit;
  51. }
  52. goto cIterator;
  53. }
  54. cIteratorExit: {
  55. if(array_key_exists(++$pos, $headers)) {
  56. goto hIterator;
  57. }
  58. }
  59. }
  60. }
  61. }
  62. class Program {
  63. private object $test;
  64. public void __construct() {
  65. $this->test = new Test();
  66. }
  67. public void main() {
  68. $this->test->goto_test1();
  69. $this->test->goto_test2();
  70. $this->test->goto_test3();
  71. $this->test->goto_test4();
  72. }
  73. }