From 19dadd080226d2e7c6dc44a53eb0ee3ee2afcbae Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Thu, 22 Jan 2026 11:19:54 +0100 Subject: Add Lua grammar --- tests/test.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/test.lua (limited to 'tests') diff --git a/tests/test.lua b/tests/test.lua new file mode 100644 index 0000000..32e18c7 --- /dev/null +++ b/tests/test.lua @@ -0,0 +1,34 @@ +-- Standard function declaration +function hello(name) + print("Hello, " .. name) +end + +-- Local function declaration +local function secret_formula(x, y) + return x * y + 42 +end + +-- Function assigned to a variable +myfunc = function(a, b) + return a - b +end + +-- Method-like function +local MyTable = {} +function MyTable:greet() + print("Greetings!") +end + +-- Nested function +function outer() + local function inner() + print("I am inside") + end + inner() +end + +hello("User") +secret_formula(1, 2) +myfunc(10, 5) +MyTable:greet() +outer() -- cgit v1.2.3