func checkNode(buf *buffer, node *types.TreeNode) { switch node.Node { case types.ExpK: if node.Exp == types.OpK { if node.Children[0].Type != types.Integer || node.Children[1].Type != types.Integer { typeError(node.Lineno, locale.Locale.AnalyzeTypeOpError) } if node.Op == types.EQ || node.Op == types.LT { node.Type = types.Boolean } else { node.Type = types.Integer } } else if node.Exp == types.ConstK || node.Exp == types.IdK { node.Type = types.Integer } else if node.Exp == types.StringK { node.Type = types.String } case types.StmtK: switch node.Stmt { case types.IfK: if node.Children[0].Type == types.Integer { typeError(node.Lineno, locale.Locale.AnalyzeTypeIfError) } case types.AssignK: if node.Children[0].Type != types.Integer { typeError(node.Lineno, locale.Locale.AnalyzeTypeAssignError) } case types.WriteK: if node.Children[0].Type != types.Integer && node.Children[0].Type != types.String { typeError(node.Lineno, locale.Locale.AnalyzeTypeWriteError) } case types.RepeatK: if node.Children[0].Type == types.Integer { typeError(node.Lineno, locale.Locale.AnalyzeTypeRepeatError) } } } }