词法分析阶段如何判断'*'字符是运算符还是标点符号

how to determine the '*' character is an operator or a punctuator at the step of lexical analysis

我正准备为c编写一个编译器,通过引用google我发现星号在运算符和标点符号的定义中都有。我认为这应该在解析步骤中决定,因为我们必须先环顾四周才能判断 it.But 我必须在解析之前为那个星号生成一个标记。

But I have to generate a token for that star character before parsing.

也一样。当您看到 * 时,只需生成一个 * 令牌。您不需要知道如何使用 * 来为其生成令牌。