lua的中文支持,修改了其中的语法分析器
来源:互联网 发布:网络电视盒价格 编辑:程序博客网 时间:2024/05/16 06:12
相信各种大神喜欢利用中文来处理策划,为了方便各种策划童鞋来进行游戏策划,鉴于大家都是中国人,英语的程度和对游戏解释的程度都不如自己的母语,所以本人从各处学习找到了在最新版本中文的支持。
static int llex (LexState *ls, SemInfo *seminfo) { luaZ_resetbuffer(ls->buff); for (;;) { switch (ls->current) { case '\n': case '\r': { /* line breaks */ inclinenumber(ls); break; } case ' ': case '\f': case '\t': case '\v': { /* spaces */ next(ls); break; } case '-': { /* '-' or '--' (comment) */ next(ls); if (ls->current != '-') return '-'; /* else is a comment */ next(ls); if (ls->current == '[') { /* long comment? */ int sep = skip_sep(ls); luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ if (sep >= 0) { read_long_string(ls, NULL, sep); /* skip long comment */ luaZ_resetbuffer(ls->buff); /* previous call may dirty the buff. */ break; } } /* else short comment */ while (!currIsNewline(ls) && ls->current != EOZ) next(ls); /* skip until end of line (or end of file) */ break; } case '[': { /* long string or simply '[' */ int sep = skip_sep(ls); if (sep >= 0) { read_long_string(ls, seminfo, sep); return TK_STRING; } else if (sep == -1) return '['; else lexerror(ls, "invalid long string delimiter", TK_STRING); } case '=': { next(ls); if (ls->current != '=') return '='; else { next(ls); return TK_EQ; } } case '<': { next(ls); if (ls->current != '=') return '<'; else { next(ls); return TK_LE; } } case '>': { next(ls); if (ls->current != '=') return '>'; else { next(ls); return TK_GE; } } case '~': { next(ls); if (ls->current != '=') return '~'; else { next(ls); return TK_NE; } } case ':': { next(ls); if (ls->current != ':') return ':'; else { next(ls); return TK_DBCOLON; } } case '"': case '\'': { /* short literal strings */ read_string(ls, ls->current, seminfo); return TK_STRING; } case '.': { /* '.', '..', '...', or number */ save_and_next(ls); if (check_next(ls, ".")) { if (check_next(ls, ".")) return TK_DOTS; /* '...' */ else return TK_CONCAT; /* '..' */ } else if (!lisdigit(ls->current)) return '.'; /* else go through */ } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { read_numeral(ls, seminfo); return TK_NUMBER; } case EOZ: { return TK_EOS; } default: { if (lislalpha(ls->current) || (ls->current > 0x80)) { /* identifier or reserved word? */ TString *ts; do { if(ls->current > 0x80) { save_and_next(ls); save_and_next(ls); } else 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->tsv.extra - 1 + FIRST_RESERVED; else { return TK_NAME; } } else { /* single-char tokens (+ - / ...) */ int c = ls->current; next(ls); return c; } } } }}
希望大家喜欢! 附上一张截图
- lua的中文支持,修改了其中的语法分析器
- Lucen支持中文分词的分析器使用
- 简单的语法分析器
- 【小技巧】如何修改 Lua 5.1 的引擎,让Lua支持中文变量名、混合变量名
- 【小技巧】如何修改 LuaPlus中的 Lua 5.1 的引擎,让Lua支持中文变量名、混合变量名
- 语法分析器的编写!急!
- 一个语法分析器的实现
- 写语法分析器的感想
- 算术表达式的语法分析器
- 一个简易的语法分析器
- LL语法分析器和LR语法分析器的比较
- 想做个支持中文语法的编译器
- 我的中文句法分析器
- 我的中文句法分析器
- 使得UltraEdit支持lua的语法高亮
- 用C++语言手工编写的词法分析器,语法分析器
- FXLabel支持中文行距的简单修改
- FXLabel支持中文行距的简单修改
- 尚观学习-ule-用户和组
- 计算机中丢失glut32.dll
- web.xml中load-on-startup的作用
- base.js文件
- Android的输入法框架
- lua的中文支持,修改了其中的语法分析器
- log4j和web.xml配置webAppRootKey 的问题
- innodb 锁的查看
- PL/SQL记录
- web项目--c3p0
- PHP静态变量、成员、方法
- 图书推荐:《iOS软件开发兵法:应用程序与游戏开发之道》
- Flex生命周期
- Java多线程优化之偏向锁原理分析(转载)