func (p *parser) asgmnt() ast.Expr { x := p.cond3() n := ast.Expr(x) if tok := p.peek(); isAssignOp(tok.Type) { p.next() y := p.asgmnt() op := &ast.BinaryExpr{ Op: tok, X: x, Y: y, } n = op } return n }
// typExt checks if the current type has * or [] extensions to it // to make them pointers or arrays. func (c *checker) typExt(typ Type, e ast.Expr) Type { n := ast.Expr(e) loop: for n != nil { pos := n.Span().Start switch m := n.(type) { case *ast.StarExpr: typ = NewPointer(typ, nil) n = m.X case *ast.ArrayType: var x operand var err error length := int64(-1) if m.Len != nil { c.constExpr(&x, m.Len) if x.val.Type() != constant.Int { c.errorf(pos, "array length is not a constant integer") break loop } length, err = strconv.ParseInt(x.val.String(), 0, 64) if err != nil { c.errorf(pos, "failed to convert array length into constant integer: %v", err) break loop } } typ = NewArray(typ, length) n = nil default: c.errorf(pos, "%s is not a type", n) break loop } } return typ }