File tree Expand file tree Collapse file tree 4 files changed +61
-19
lines changed
src/main/java/org/luapp/language Expand file tree Collapse file tree 4 files changed +61
-19
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ();
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change @@ -4,11 +4,39 @@ Don't remove this notice please
44
55https://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 ())
You can’t perform that action at this time.
0 commit comments