1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// preprocess using luam -C -llc -o str.c str.l.c #include <string.h> 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; } }