问题
之前一直觉得getTok()函数每次获得一个Token后,会丢弃Token后面的一个字符。所以当时觉得,在写Kaleidoscope语言时必须在每一个Token后加一个空格符来方便getTok()识别。比如输入:
def f ( x ) x ;
思考
想了想这样的语言有点离谱,每个Token间必须要有一个空格隔开。一直带着这个问题到后面的章节,当运行toy时发现,上面的语句把不必要的空格去掉也可以正常解析,如下:
def f(x) x;
再回过头看getTok():
/// gettok - Return the next token from standard input.
static int gettok() {
static int LastChar = ' ';
// Skip any whitespace.
while (isspace(LastChar))
LastChar = getchar();
if (

最低0.47元/天 解锁文章
2726

被折叠的 条评论
为什么被折叠?



