我正在阅读一些实现简单解析器的代码。一个名为的函数将scan一行分解为标记。scan有一个静态变量bp,分配给要标记的行。在分配之后,空格被跳过。见下文。我不明白的是为什么代码对bp指向 with的字符进行按位和处理0xff,即, 的目的是* bp & 0xff什么?这怎么样:
while (isspace(* bp & 0xff))
++ bp;
Run Code Online (Sandbox Code Playgroud)
与此不同:
while (isspace(* bp))
++ bp;
Run Code Online (Sandbox Code Playgroud)
这是scan函数:
static enum tokens scan (const char * buf)
/* return token = next input symbol */
{ static const char * bp;
while (isspace(* bp & 0xff))
++ bp;
..
}
Run Code Online (Sandbox Code Playgroud)