Skip to content
/ Jua Public

The Jua Lanauage: A simplified Lua written in Java.

License

Notifications You must be signed in to change notification settings

kyle-ip/Jua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jua

Java lua

Introduction

Jua is a simplified Lua (5.3) implementation written in Java.

The purpose of building this project is to learn:

  • Data Structure
  • Register-based Virtual Machine & Instruction Set Design
  • Compilers
  • Lua & Standard Libraries

Features

  • Virtual Machine: (Instruction Set & Runner)
  • Compiler: Lexer, AST Parser & Code Generator
  • Standard Libraries
  • Metaprogramming

To-Do List

Standard Libraries

Lua 5.3 Reference Manual

Basic

No. Function Synopsis
0 print print (···)
1 assert assert (v [, message])
2 error error (message [, level])
3 select select (index, ···)
4 ipairs ipairs (t)
5 pairs pairs (t)
6 next next (table [, index])
7 load load (chunk [, chunkname [, mode [, env]]])
8 loadfile loadfile ([filename [, mode [, env]]])
9 dofile dofile ([filename])
10 pcall pcall (f [, arg1, ···])
11 xpcall xpcall (f, msgh [, arg1, ···])
12 getmetatable getmetatable (object)
13 setmetatable setmetatable (table, metatable)
14 rawequal rawequal (v1, v2)
15 rawlen rawlen (v)
16 rawget rawget (table, index)
17 rawset rawset (table, index, value)
18 type type (v)
19 tostring tostring (v)
20 tonumber tonumber (e [, base])

Math

No. Function Synopsis
0 random math.random ([m [, n]])
1 randomseed math.randomseed (x)
2 max math.max (x, ···)
3 min math.min (x, ···)
4 exp math.exp (x)
5 log math.log (x [, base])
6 deg math.deg (x)
7 rad math.rad (x)
8 sin math.sin (x)
9 cos math.cos (x)
10 tan math.tan (x)
11 asin math.asin (x)
12 acos math.acos (x)
13 atan math.atan (y [, x])
14 ceil math.ceil (x)
15 floor math.floor (x)
16 abs math.abs (x)
17 sqrt math.sqrt (x)
18 fmod math.abs (x)
19 modf math.modf (x)
20 ult math.ult (m, n)
21 tointeger math.tointeger (x)
22 type math.type (x)
23 pi The value of π.
24 huge A value larger than any other numeric value.
25 maxinteger An integer with the maximum value for an integer.
26 mininteger An integer with the minimum value for an integer.

String

No. Function Synopsis
0 len string.len (s)
1 rep string.rep (s, n [, sep])
2 lower string.lower (s)
3 upper string.upper (s)

...

Modules

No. Function Synopsis
0 require require (modname)
1 searchers package.searchers
2 searchpath package.searchpath (name, path [, sep [, rep]])

...

Example

Dependencies

  • JDK 1.8+
  • Maven 3+

Build Project

mvn clean package

Write and Run Script

sum.lua

function sum()
    local s = 0
    for i = 1, 100 do
        if i % 2 == 0 then
            s = s + math.sqrt(i)
        end
    end
    return s
end
print(sum())
$ java -jar jua-5.3.5-alpha.jar sum.lua

             ,---._
           .-- -.' \
           |    |   :
           |    |   |         ,--,
           |    |   |       ,'_ /|
           |    |   |  .--. |  | :    ,--.--.
           |    |   |,'_ /| :  . |   /       \
           |    |   ||  ' | |  . .  .--.  .-. |
       ___ |    |   ||  | ' |  | |   \__\/| . .
     /    /\    |   ||  | : ;  ; |   ," .--.; |
    /  ../  `..-    ,|  |  `--'   \ /  /  ,.  |
    \    \         ; :  ,      .-./;  :  |..'  \
     \    \      ,'   `--`----'    |  ,     .-./
      "---....--'                   `--`---'
    :: jua ::                      (5.3.5-alpha)

338.048

Links

License

See LICENSE file.

About

The Jua Lanauage: A simplified Lua written in Java.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages