Skip to content

Commit

Permalink
Merge pull request #29 from LuaPlusPlus/1.0.5
Browse files Browse the repository at this point in the history
1.0.5
  • Loading branch information
NoSharp authored Jun 12, 2020
2 parents cd33f1b + a094715 commit 3c3832f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/luapp/language/Luapp.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public String getRaw(){

public String getRawFromContext(ParserRuleContext context){
int startToken = context.start.getStartIndex();
int stopToken = context.stop.getStartIndex();
int stopToken = context.stop.getStopIndex();
return context.getStart().getInputStream().getText(new Interval(startToken, stopToken));
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/luapp/language/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Main {

public static String output = "";

public static boolean debug = true;
public static boolean debug = false;

public static void main(String[] args){
String path = debug ? System.getProperty("user.dir") + "/src/main/java/org/luapp/language/test.lpp" : args[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public void onSetManager() {

@Override
public void onEnterContext(ParserRuleContext enterContext) {
// StackTraceElement[] cause = Thread.currentThread().getStackTrace();
// System.out.println(cause[2]);
System.out.println("");
this.getLuaPP().currentClass = enterContext.getText();
String currentClass = enterContext.getText();
Expand Down
32 changes: 24 additions & 8 deletions src/main/java/org/luapp/language/test.lpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
concommand.Add('test.lpp', function()
local thomas = cat.new("Thomas!")
thomas:setAge(50)
thomas:setName("Thomas v2")
print(thomas:isCat()) -- outputs -> true
print(thomas:getName()) -- outputs -> "Thomas v2"
print(thomas:getAge()) -- outputs -> 50
end)
class cat
name {get set}
age {get set}
type {get }

constructor(name)
self.name = name
end

function isCat()
return true
end

static function coolCat()
return "coolCat!"
end
end

local thomas = cat.new("Thomas")
thomas:setNge(50)
thomas:setName("Thomas v2")
print(thomas:isCat()) -- outputs -> true
print(thomas:getName()) -- outputs -> "Thomas v2"
print(thomas:getAge()) -- outputs -> 50
44 changes: 36 additions & 8 deletions src/main/java/org/luapp/language/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,39 @@ Don't remove this notice please
https://github.com/LuaPlusPlus/lua-plus-plus
]]--
concommand.Add('test.lpp', function()
local thomas = cat.new("Thomas!")
thomas:setAge(50)
thomas:setName("Thomas v2")
print(thomas:isCat()) -- outputs -> true
print(thomas:getName()) -- outputs -> "Thomas v2"
print(thomas:getAge()) -- outputs -> 50
end)
cat = {}
cat.__index = cat
function cat.new(name)
local self = {}
setmetatable(self, cat)

self.name = name
return self
end
function cat:isCat()
return true
end
function cat.coolCat()
return "coolCat!"
end
function cat:getName()
return self.name
end
function cat:setName(obj)
self.name = obj
end
function cat:getAge()
return self.age
end
function cat:setAge(obj)
self.age = obj
end
function cat:getType()
return self.type
end
local thomas = cat.new("Thomas")
thomas:setNge(50)
thomas:setName("Thomas v2")
print(thomas:isCat())
print(thomas:getName())
print(thomas:getAge())

0 comments on commit 3c3832f

Please sign in to comment.