30

GitHub - hsiaosiyuan0/jlua: Yet another Lua implementation in pure JavaScript.

 4 years ago
source link: https://github.com/hsiaosiyuan0/jlua
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

jlua

Yet another Lua implementation in pure JavaScript. It encapsulates:

  • Frontend infrastructure like Lexer and Parser to generate AST
  • Some subclasses of AstVisitors like YamlVisitor and Codegen generate YAML reflects the AST and bytecode for LuaVM, respectively
  • Particularly, JsCodegen translates Lua to JavaScript for running Lua on JavaScript runtime directly

Here is a demo, it will take a while for the browser to load the page since it has to load a large bundled js file, that file contains full code of the jlua compiler. Making a compiling service which runs jlua at server side can speed up the loading time, but it's limited by my low memory vhost.

The demo is naturally built with jlua and Vue.js, in other words we can use Lua within Single File Component, for example:

<template>
 <div>hi {{ lang }}</div>
</template>

<script lang="lua">
local m = {
 data = function () 
   return {
     lang = "Lua"
   }
 end
}
return m
</script>

here is the source of the demo.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK