zoukankan      html  css  js  c++  java
  • lua支持中文变量名

    本文章引用自 http://blog.csdn.net/chrisxie/archive/2008/09/29/2998290.aspx

    但有所修正.

    默认的LUA不支持中文变量名.

    少量修改源代码即可

    修改如下:

    在lua\src\llex.c中 修改420行-432行内容

    原内容

    1 else if (isalpha(ls->current) || ls->current == '_') {
    2 /* identifier or reserved word */
    3 TString *ts;
    4 do {
    5 save_and_next(ls);
    6 } while (isalnum(ls->current) || ls->current == '_');
    7 ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
    8 luaZ_bufflen(ls->buff));
    9 if (ts->tsv.reserved > 0) /* reserved word? */
    10 return ts->tsv.reserved - 1 + FIRST_RESERVED;
    11 else {
    12 seminfo->ts = ts;
    13 return TK_NAME;
    14 }
    15 }
    16  

    修改为:

    1 else if (isalpha(ls->current) || ls->current == '_' || ls->current > 0x80) {
    2 /* identifier or reserved word */
    3 TString *ts;
    4 do {
    5 if(ls->current > 0x80)
    6 {
    7 save_and_next(ls);
    8 save_and_next(ls);
    9 }
    10 else
    11 save_and_next(ls);
    12 } while (isalnum(ls->current) || ls->current == '_' || ls->current > 0x80);
    13 ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
    14 luaZ_bufflen(ls->buff));
    15 if (ts->tsv.reserved > 0) /* reserved word? */
    16 return ts->tsv.reserved - 1 + FIRST_RESERVED;
    17 else {
    18 seminfo->ts = ts;
    19 return TK_NAME;
    20 }
    21 }
    22  

    注意我已经打过PATCH2了,可能和实际情况不大一样..不过,代码逻辑很容易,看下,应该也能明白

  • 相关阅读:
    配色方案及色彩心理学(转)
    CSS中强大的EM
    Link To Sql简单
    改变html中鼠标形状
    JS实现雪花效果
    你真的已经搞懂JavaScript了吗?
    MVC特性
    初识 bower(一)
    学习前端模板引擎 jade (一)
    日志系统
  • 原文地址:https://www.cnblogs.com/javado/p/1878496.html
Copyright © 2011-2022 走看看