×

Langue

Fermer
Atelier 801
  • Forums
  • Dev Tracker
  • Connexion
    • English Français
      Português do Brasil Español
      Türkçe Polski
      Magyar Română
      العربية Skandinavisk
      Nederlands Deutsch
      Bahasa Indonesia Русский
      中文 Filipino
      Lietuvių kalba 日本語
      Suomi עברית
      Italiano Česky
      Hrvatski Slovensky
      Български Latviešu
      Estonian
  • Langue
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • lua "interpreter" in lua
lua "interpreter" in lua
Nathaan
« Citoyen »
1691575140000
    • Nathaan#0000
    • Profil
    • Derniers messages
    • Tribu
#1
  4
https://www.nathaan.com/uploads/27c1482feef2e82ebeb2bb3d5ddc135f.png

Recently wrote a lua lexer, parser and interpreter in lua for no reason. It has bad performance and might have some inaccurate behaviours, but wanted to share it anyway.

Demo version can be found here: https://pastebin.com/yk1VmNbt (last update: 2023-08-10)
Usage: !eval (snippet) in chat

Globals are shared, locals are not. It would not be difficult to change the globals table for the module that is being run and I might add a parmaeter for it in a future update.

Source code can be found on my GitHub: https://github.com/NathaanTFM/luainlua

Errors are not handled: if there's any parse or runtime error, it might either be detected by the runtime ; in which case it will include additional debug info and line numbers, but for most cases (i.e errors with binary - arithmetic - operations), there won't be any debug info.

(The demo version can be appended to any existing script and shouldn't break it. It also adds a "loadstring" global function. Usage: loadstring(code, chunkname, globals))

Changes:
- added "repeat (...) until" loops (those were parsed but not interpreted)
- fixed issue with commas at the end of functions (function() print("hello world"); end)
- fixed long strings
- fixed issue with argument passing (related to a LuaJ bug with table.pack and table.unpack)

Dernière modification le 1691701620000
Sklag
« Citoyen »
1692987780000
    • Sklag#2552
    • Profil
    • Derniers messages
    • Tribu
#2
  1
Nathaan a dit :
https://www.nathaan.com/uploads/27c1482feef2e82ebeb2bb3d5ddc135f.png

Recently wrote a lua lexer, parser and interpreter in lua for no reason. It has bad performance and might have some inaccurate behaviours, but wanted to share it anyway.

Demo version can be found here: https://pastebin.com/yk1VmNbt (last update: 2023-08-10)
Usage: !eval (snippet) in chat

Globals are shared, locals are not. It would not be difficult to change the globals table for the module that is being run and I might add a parmaeter for it in a future update.

Source code can be found on my GitHub: https://github.com/NathaanTFM/luainlua

Errors are not handled: if there's any parse or runtime error, it might either be detected by the runtime ; in which case it will include additional debug info and line numbers, but for most cases (i.e errors with binary - arithmetic - operations), there won't be any debug info.

(The demo version can be appended to any existing script and shouldn't break it. It also adds a "loadstring" global function. Usage: loadstring(code, chunkname, globals))

Changes:
- added "repeat (...) until" loops (those were parsed but not interpreted)
- fixed issue with commas at the end of functions (function() print("hello world"); end)
- fixed long strings
- fixed issue with argument passing (related to a LuaJ bug with table.pack and table.unpack)

complex, i like it congrats
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • lua "interpreter" in lua
© Atelier801 2018

Equipe Conditions Générales d'Utilisation Politique de Confidentialité Contact

Version 1.27