From f0aa32fbfb8dbeaa52f8175b0fac78d768083aff Mon Sep 17 00:00:00 2001 From: andy <1414772332@qq.com> Date: Mon, 21 Oct 2024 08:53:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/llex.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/llex.c b/src/llex.c index 5b3a705..dbf6584 100644 --- a/src/llex.c +++ b/src/llex.c @@ -103,7 +103,7 @@ const char *luaX_token2str (LexState *ls, int token) { } } - +// 返回token的字符串 static const char *txtToken (LexState *ls, int token) { switch (token) { case TK_NAME: case TK_STRING: @@ -138,6 +138,10 @@ l_noret luaX_syntaxerror (LexState *ls, const char *msg) { ** is irrelevant. We use the string itself as the value only because it ** is a TValue readily available. Later, the code generation can change ** this value. +创建一个新字符串并将其锚定在scanner的表中,以便在编译结束之前不会收集它; +到那时,它应该已经锚定在某个地方了。它还将长字符串内部化,确保每个唯一字符串只有一个副本。 +这里的表用作一个集合:字符串作为键输入,而其值无关紧要。 +我们使用字符串本身作为值,只是因为它是一个现成的TValue。稍后,代码生成可以更改此值。 */ TString *luaX_newstring (LexState *ls, const char *str, size_t l) { lua_State *L = ls->L;