Skip to content

Commit 3c3832f

Browse files
authored
Merge pull request #29 from LuaPlusPlus/1.0.5
1.0.5
2 parents cd33f1b + a094715 commit 3c3832f

File tree

5 files changed

+62
-20
lines changed

5 files changed

+62
-20
lines changed

src/main/java/org/luapp/language/Luapp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public String getRaw(){
9999

100100
public String getRawFromContext(ParserRuleContext context){
101101
int startToken = context.start.getStartIndex();
102-
int stopToken = context.stop.getStartIndex();
102+
int stopToken = context.stop.getStopIndex();
103103
return context.getStart().getInputStream().getText(new Interval(startToken, stopToken));
104104
}
105105

src/main/java/org/luapp/language/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class Main {
1010

1111
public static String output = "";
1212

13-
public static boolean debug = true;
13+
public static boolean debug = false;
1414

1515
public static void main(String[] args){
1616
String path = debug ? System.getProperty("user.dir") + "/src/main/java/org/luapp/language/test.lpp" : args[0];

src/main/java/org/luapp/language/handlers/ClassNameHandler.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ public void onSetManager() {
1717

1818
@Override
1919
public void onEnterContext(ParserRuleContext enterContext) {
20-
// StackTraceElement[] cause = Thread.currentThread().getStackTrace();
21-
// System.out.println(cause[2]);
2220
System.out.println("");
2321
this.getLuaPP().currentClass = enterContext.getText();
2422
String currentClass = enterContext.getText();
Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1-
concommand.Add('test.lpp', function()
2-
local thomas = cat.new("Thomas!")
3-
thomas:setAge(50)
4-
thomas:setName("Thomas v2")
5-
print(thomas:isCat()) -- outputs -> true
6-
print(thomas:getName()) -- outputs -> "Thomas v2"
7-
print(thomas:getAge()) -- outputs -> 50
8-
end)
1+
class cat
2+
name {get set}
3+
age {get set}
4+
type {get }
5+
6+
constructor(name)
7+
self.name = name
8+
end
9+
10+
function isCat()
11+
return true
12+
end
13+
14+
static function coolCat()
15+
return "coolCat!"
16+
end
17+
end
18+
19+
local thomas = cat.new("Thomas")
20+
thomas:setNge(50)
21+
thomas:setName("Thomas v2")
22+
print(thomas:isCat()) -- outputs -> true
23+
print(thomas:getName()) -- outputs -> "Thomas v2"
24+
print(thomas:getAge()) -- outputs -> 50

src/main/java/org/luapp/language/test.lua

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,39 @@ Don't remove this notice please
44
55
https://github.com/LuaPlusPlus/lua-plus-plus
66
]]--
7-
concommand.Add('test.lpp', function()
8-
local thomas = cat.new("Thomas!")
9-
thomas:setAge(50)
10-
thomas:setName("Thomas v2")
11-
print(thomas:isCat()) -- outputs -> true
12-
print(thomas:getName()) -- outputs -> "Thomas v2"
13-
print(thomas:getAge()) -- outputs -> 50
14-
end)
7+
cat = {}
8+
cat.__index = cat
9+
function cat.new(name)
10+
local self = {}
11+
setmetatable(self, cat)
12+
13+
self.name = name
14+
return self
15+
end
16+
function cat:isCat()
17+
return true
18+
end
19+
function cat.coolCat()
20+
return "coolCat!"
21+
end
22+
function cat:getName()
23+
return self.name
24+
end
25+
function cat:setName(obj)
26+
self.name = obj
27+
end
28+
function cat:getAge()
29+
return self.age
30+
end
31+
function cat:setAge(obj)
32+
self.age = obj
33+
end
34+
function cat:getType()
35+
return self.type
36+
end
37+
local thomas = cat.new("Thomas")
38+
thomas:setNge(50)
39+
thomas:setName("Thomas v2")
40+
print(thomas:isCat())
41+
print(thomas:getName())
42+
print(thomas:getAge())

0 commit comments

Comments
 (0)