1. 在官網下載最新版Lua源碼
2. 解壓后進入目錄,找到/src/llex.c,打開修改
找到如下內容
修改為下面代碼,並保存。
default: {
if (lislalpha(ls->current)|| ls->current >= 0x80) { /* identifier or reserved word? *///修改
TString *ts;
do {
if (ls->current >= 0x80) { //修改
save_and_next(ls); //修改
if(ls->current !='('&&ls->current >=0x80)//修改
save_and_next(ls); //修改
}
else if(ls->current !='('){ //修改
save_and_next(ls); //修改
}
} while (lislalnum(ls->current)|| ls->current >= 0x80);//修改
ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
luaZ_bufflen(ls->buff));
seminfo->ts = ts;
if (isreserved(ts)) /* reserved word? */
return ts->extra - 1 + FIRST_RESERVED;
else {
return TK_NAME;
}
}
else { /* single-char tokens (+ - / ...) */
int c = ls->current;
next(ls);
return c;
}
}
3. 編譯
- Mac OS X 系統
cd lua-5.3.4 #進入lua目錄
make macosx test
make install
- Linux 系統
cd lua-5.3.4
make linux test
make install
- Win 系統可以用vs編譯。
ps.這樣修改也支持中文函數名,網上修改的方法 function 跑()
運行會報錯如下:
lua: 任務.lua:18: '(' expected near ')'