标签:
static int llex (LexState *ls, SemInfo *seminfo)
else if (isalpha(ls->current) || ls->current == ‘_‘) { 02. /* identifier or reserved word */ 03. TString *ts; 04. if (ls->current == ‘L‘) { 05. next(ls); 06. if (ls->current == ‘"‘ || ls->current == ‘/‘‘) { 07. read_wstring(ls, ls->current, seminfo); 08. return TK_WSTRING; 09. } 10. save(ls, ‘L‘); 11. } 12. /* identifier or reserved word */ 13. do { 14. save_and_next(ls); 15. } while (isalnum(ls->current) || ls->current == ‘_‘); 16. ts = luaX_newstring(ls, luaZ_buffer(ls->buff), 17. luaZ_bufflen(ls->buff)); 18. if (ts->tsv.reserved > 0) /* reserved word? */ 19. return ts->tsv.reserved - 1 + FIRST_RESERVED; 20. else { 21. seminfo->ts = ts; 22. return TK_NAME; 23. } 24. }
5. 将该段替换为下面这一段即可,其作用在于加入了对中文ASCII字符的识别
else if (isalpha(ls->current) || ls->current == ‘_‘ || ls->current > 0x80) { 02. /* identifier or reserved word */ 03. TString *ts; 04. if (ls->current == ‘L‘) { 05. next(ls); 06. if (ls->current == ‘"‘ || ls->current == ‘/‘‘) { 07. read_wstring(ls, ls->current, seminfo); 08. return TK_WSTRING; 09. } 10. save(ls, ‘L‘); 11. } 12. /* identifier or reserved word */ 13. do { 14. if(ls->current > 0x80) 15. { 16. save_and_next(ls); 17. save_and_next(ls); 18. } 19. else 20. save_and_next(ls); 21. } while (isalnum(ls->current) || ls->current == ‘_‘ || ls->current > 0x80); 22. ts = luaX_newstring(ls, luaZ_buffer(ls->buff), 23. luaZ_bufflen(ls->buff)); 24. if (ts->tsv.reserved > 0) /* reserved word? */ 25. return ts->tsv.reserved - 1 + FIRST_RESERVED; 26. else { 27. seminfo->ts = ts; 28. return TK_NAME; 29. } 30. }
标签:
原文地址:http://www.cnblogs.com/wumac/p/4288642.html