From 27d6efb5f5a076f825fe2da1875e0cabaf02b4e7 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 17 Nov 2021 23:03:07 +0800 Subject: + LuaMacro --- Tools/LuaMacro/tests/str.l.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Tools/LuaMacro/tests/str.l.c (limited to 'Tools/LuaMacro/tests/str.l.c') diff --git a/Tools/LuaMacro/tests/str.l.c b/Tools/LuaMacro/tests/str.l.c new file mode 100644 index 0000000..e15891c --- /dev/null +++ b/Tools/LuaMacro/tests/str.l.c @@ -0,0 +1,19 @@ +// preprocess using luam -C -llc -o str.c str.l.c +#include + +module "str" { + + def at (Str s, Int i = 0) { + lua_pushlstring(L,&s[i-1],1); + return 1; + } + + def upto (Str s, Str delim = " ") { + lua_pushinteger(L, strcspn(s,delim) + 1); + return 1; + } + +} + + + -- cgit v1.1-26-g67d0