新一篇: Doris一款为Lua制作的小巧OpenGL封装 | 旧一篇: 自己写的DllCall类方便dll动态链接库函数调用 function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}
/*** 作者:苏晓 时间:2006年5月24日** 若有转载请注明出处,谢谢!*/Lua脚本的执行效率是相当高的,源文件用纯C写成相当小巧,其可扩展性相当强,前途一片光明。其源文件写得不复杂,相当值得一读。作为中国人,在编程语言的使用上如果能够使用中文作为变量名是非常好的一件事。但是标准的Lua并不支持中文变量名。虽然可以在字符串中处理中文。其实只要修改少量代码就可以让Lua支持中文变量名。
打开lua的源文件文件夹(包)可以从文件名知道,llex.h,llex.c是用来做文件语法分析的。备份llex.c为llex_old.c打开llex.c进行修改如下:
/*
** $Id: llex.c,v 1.119 2003/03/24 12:39:34 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
#include
#include
#define llex_c
#include "lua.h"
#include "ldo.h"
#include "llex.h"
#include "lobject.h"
#include "lparser.h"
#include "lstate.h"
#include "lstring.h"
#include "lzio.h"
#define next(LS) (LS->current = zgetc(LS->z))
/* ORDER RESERVED */
static const char *const token2string[] =
{
"and", "break", "do", "else", "elseif", "end", "false", "for", "function",
"if", "in", "local", "nil", "not", "or", "repeat", "return", "then", "true",
"until", "while", "*name", "..", "...", "==", ">=", "linenumber;
luaX_checklimit(LS, LS->linenumber, MAX_INT, "lines in a chunk");
}
void luaX_setinput(lua_State *L, LexState *LS, ZIO *z, TString *source)
{
LS->L = L;
LS->lookahead.token = TK_EOS; /* no look-ahead token */
LS->z = z;
LS->fs = NULL;
LS->linenumber = 1;
LS->lastline = 1;
LS->source = source;
next(LS); /* read first char */
|