Minimal programming language prototype, created with goal to have very small compiler, so that anyone can write his own compiler for it.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

50 lines
843B

  1. type integer = 4;
  2. type natural = 4;
  3. type boolean (
  4. false,
  5. true)
  6. type system_call (
  7. linux_read_system_call = 0,
  8. linux_write_system_call = 1,
  9. linux_open_system_call = 2,
  10. linux_close_system_call = 3,
  11. linux_exit_system_call = 60)
  12. type file_descriptor (
  13. standard_input,
  14. standard_output)
  15. string_length (string):
  16. length: natural = 0;
  17. loop (! string [length])
  18. length++;
  19. return (length);;
  20. echo (text):
  21. system (linux_write_system_call, standard_output, text, string_length (text));
  22. return;;
  23. heyo () echo ("Heyo!");
  24. cyaa () echo ("Cyaa!");
  25. global: integer = 666;
  26. uberglobal = 666;
  27. my_main ():
  28. heyo ();
  29. loop (x = 1 .. 17):
  30. if ((x % 3 = 0) & (x % 5 = 0))
  31. echo ("fizz+buzz");
  32. else if (x % 3 = 0)
  33. echo ("fizz");
  34. else if (x % 5 = 0)
  35. echo ("buzz");
  36. else
  37. echo ("<>");
  38. echo ("\n");;
  39. cyaa ();
  40. return 60;;