Advertisement
Narzew

LiteElite Programming Language (New programming language!!!)

Dec 9th, 2012
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.15 KB | None | 0 0
  1. #========================================================
  2. #**Lite Elite Programming Language
  3. #========================================================
  4. #**Narzew
  5. #**09.12.2012
  6. #**Version 1.1
  7. #========================================================
  8. #**Versions :
  9. #**09.12.2012 => v 1.0
  10. #**09.12.2012 => v 1.1
  11. #========================================================
  12. #**Changes in 1.1
  13. #**3 new methods, self in methods object, shortcuts
  14. #========================================================
  15.  
  16. #========================================================
  17. #**License:
  18. #**GPL with some changes :
  19. #**Share & use free where you want, but you must give credit to original
  20. #**author in visible place.
  21. #**All plugins/mods etc please send to authors email (narzew at gmail.com),
  22. #**to make this software better and better.
  23. #**User can't change this license.
  24. #**This license are for all plugins and mods
  25. #**Original author (Narzew) can change this license when he wants.
  26. #**Using => accepting this license
  27. #========================================================
  28. #========================================================
  29. #**Licencja :
  30. #**GPL z kilkoma zmianami :
  31. #**Rozprzestrzeniaj & używaj gdzie chcesz, ale musisz dać nazwę
  32. #**oryginalnego autora w widocznym miejscu
  33. #**Wszelkie pluginy/mody itp. proszę wysyłać mi na e-mail (narzew at gmail.com),
  34. #**w celu ulepszenia rozwoju oprogramowania
  35. #**Użytkownik nie może zmienić licencji
  36. #**Do pluginów itp. też się tyczy ta licencja.
  37. #**Autor oryginału (Narzew) ma prawo zmienić licencję w każdym czasie.
  38. #**Używając akceptujesz tą licencję.
  39. #========================================================
  40.  
  41. $code = "" # Zmienna kodu / Code variable
  42. tt = true # Skrót od true / True shortcut
  43. fl = false # Skrót od false / False shortcut
  44. nl = nil # Skrót od nil / Nil shortcut
  45. sl = self # Skrót od self / Self shortcut
  46.  
  47. #========================================================
  48. #**Lista instrukcji :
  49. #**Instructions list :
  50. #**mt(x,y,z) => metoda / method
  51. #**cb(x,y,z,e) => warunek / conditional branch
  52. #**wh(x,y) => pętla while / while loop
  53. #**ut(x,y) => pętla until / until loop
  54. #**md(x,y) => moduł / module
  55. #**cl(x,y) => klasa / class
  56. #**as(x,y) => alias / alias
  57. #**bg(x,y,z) => główna pętla (begin) / main loop (begin)
  58. #**ev(x) => ewaluacja code / code eval
  59. #**ex => wywołanie kodu / code evaluation
  60. #**cs => wyczyszczenie codu / code clear
  61. #**ss(x) => zapisanie kodu do pliku / save code to file
  62. #========================================================
  63. #**New in 1.1
  64. #========================================================
  65. #**se => zwykły koniec / standalone end
  66. #**sm(x) => zwyczajny moduł / standalone module
  67. #**sc(x) => zwyczajna klasa / standalone class
  68. #========================================================
  69.  
  70. #========================================================
  71. #**mt(x,y,z)
  72. #**Metoda
  73. #**Method
  74. #**x => nazwa (ciąg)
  75. #**x => name (string)
  76. #**y => argumenty (tablica) [argument1,argument2] (opcjonalnie)
  77. #**y => arguments (array) [argument1, argument2] (optional)
  78. #**z => treść metody (ciąg)
  79. #**z => method data (string)
  80. #========================================================
  81.  
  82. def mt(x,y,z,s=false)
  83.   if s == false
  84.     $code << "def #{x}("
  85.   else
  86.     $code << "def self.#{x}("
  87.   end
  88.   a = y.size
  89.   b = 0
  90.   unless y == nil
  91.     y.each{|x|
  92.     b += 1
  93.     $code << "#{x}"
  94.     $code << "," if b != a
  95.     }
  96.   end
  97.   $code << ")\n#{z}\nend\n"
  98. end
  99.  
  100. #========================================================
  101. #**cb(x,y,z,e)
  102. #**Warunek
  103. #**Conditional branch
  104. #**x => warunek (ciąg)
  105. #**x => branch (string)
  106. #**y => instrukcje jeśli spełniony (ciąg)
  107. #**y => instructions when true (string)
  108. #**z => instrukcje jeśli niespełniony (ciąg, opcjonalnie)
  109. #**z => instructions when false (string, optional)
  110. #**e => elsify w tablicy asocjacyjnej {warunek => instrukcje} (opcjonalnie)
  111. #**e => elsifs in assoc table [elsif  => instr] (optional)
  112. #========================================================
  113.  
  114. def cb(x,y,z=nil,e={})
  115.   $code << "if #{x}\n#{y}\n"
  116.   unless z == {}
  117.     e.each{|a,b|
  118.     $code << "elsif #{a}\n#{b}\n"
  119.     }
  120.   end
  121.   unless z == nil
  122.     $code << "else\n#{z}\n"
  123.   end
  124.   $code << "end\n"
  125. end
  126.  
  127. #========================================================
  128. #**wh(x,y)
  129. #**While
  130. #**x => warunek
  131. #**x => branch
  132. #**y => instrukcje
  133. #**y => instructions
  134. #**Dopóki warunek jest spełnione, wykonuj instrukcje (sprawdzany na początku)
  135. #**Until branch is true, do instructions (check at the start)
  136. #========================================================
  137.  
  138. def wh(x,y)
  139.   $code << "while #{x}\n#{y}\nend\n"
  140. end
  141.  
  142. #========================================================
  143. #**ut(x,y)
  144. #**Until
  145. #**x => warunek
  146. #**x=> branch
  147. #**y => instrukcje
  148. #**y => instructions
  149. #**Dopóki warunek jest spełnione, wykonuj instrukcje (sprawdzany na końcu)
  150. #**Until branch is true, do instructions (check at the end)
  151. #========================================================
  152.  
  153. def ut(x,y)
  154.   $code << "until #{x}\n#{y}\nend\n"
  155. end
  156.  
  157. #========================================================
  158. #**md(x,y)
  159. #**Moduł
  160. #**Module
  161. #**x => nazwa modułu
  162. #**x => module name
  163. #**y => treść modułu
  164. #**y => module data
  165. #========================================================
  166.  
  167. def md(x,y)
  168.   $code << "module #{x}\n#{y}\nend\n"
  169. end
  170.  
  171. #========================================================
  172. #**cl(x,y)
  173. #**Klasa
  174. #**Class
  175. #**x => nazwa klasy
  176. #**x => class name
  177. #**y => treść klasy
  178. #**y => class data
  179. #========================================================
  180.  
  181. def cl(x,y)
  182.   $code << "class #{x}\n#{y}\nend\n"
  183. end
  184.  
  185. #========================================================
  186. #**as(x,y)
  187. #**Alias
  188. #**x => wcześniejsza metoda
  189. #**x => previous method
  190. #**y => nowa nazwa metody
  191. #**y => new method
  192. #========================================================
  193.  
  194. def as(x,y)
  195.   $code << "alias #{x} #{y}\n"
  196. end
  197.  
  198. #========================================================
  199. #**bg(x,y,z)
  200. #**Główna metoda (begin)
  201. #**Main method (begin)
  202. #**x => treść głównej metody
  203. #**x => main method code
  204. #**y => treść warunku rescue (opcjonalnie)
  205. #**y => rescue branch code (optional)
  206. #**z => treść warunku ensure (opcjonalnie)
  207. #**z => ensure branch code (optional)
  208. #========================================================
  209.  
  210. def bg(x,y=nil,z=nil)
  211.   $code << "begin\n#{x}\n"
  212.   unless y == nil
  213.     $code << "rescue\n#{y}\n"
  214.   end
  215.   unless z == nil
  216.     $code << "ensure\n#{z}\n"
  217.   end
  218.   $code << "end\n"
  219. end
  220.  
  221. #========================================================
  222. #**ev(x,y)
  223. #**Eval
  224. #**x => code
  225. #**x => kod
  226. #========================================================
  227.  
  228. def ev(x)
  229.   $code << "#{x}\n"
  230. end
  231.  
  232. #========================================================
  233. #**ex
  234. #**Wykonuje kod
  235. #**Executes a code
  236. #========================================================
  237.  
  238. def ex
  239.   eval($code)
  240. end
  241.  
  242. #========================================================
  243. #**cs
  244. #**Czyści kod
  245. #**Clears a code
  246. #========================================================
  247.  
  248. def cs
  249.   $code = ""
  250. end
  251.  
  252. #========================================================
  253. #**ss(x)
  254. #**x=> plik
  255. #**x => filename
  256. #**Zapisuje kod
  257. #**Saves a code
  258. #========================================================
  259.  
  260. def ss(x)
  261.   file = File.open(x, 'wb')
  262.   file.write($code)
  263.   file.close
  264. end
  265.  
  266. #========================================================
  267. #**se
  268. #**Zwyczajny koniec
  269. #**Standalone end
  270. #========================================================
  271.  
  272. def se
  273.   $code << "end\n"
  274. end
  275.  
  276. #========================================================
  277. #**sc(x)
  278. #**x => klasa
  279. #**x => class
  280. #**Start klasy
  281. #**Class start
  282. #========================================================
  283.  
  284. def sc(x)
  285.   $code << "class #{x}\n"
  286. end
  287.  
  288. #========================================================
  289. #**sm(x)
  290. #**x => moduł
  291. #**x => module
  292. #**Start modułu
  293. #**Module start
  294. #========================================================
  295.  
  296. def sm(x)
  297.   $code << "module #{x}\n"
  298. end
  299.  
  300. #========================================================
  301. #**Koniec skryptu
  302. #**End of script
  303. #========================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement