github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/syntax/positions.go (about) 1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // This file implements helper functions for scope position computations. 6 7 package syntax 8 9 // StartPos returns the start position of n. 10 func StartPos(n Node) Pos 11 12 // EndPos returns the approximate end position of n in the source. 13 // For some nodes (*Name, *BasicLit) it returns the position immediately 14 // following the node; for others (*BlockStmt, *SwitchStmt, etc.) it 15 // returns the position of the closing '}'; and for some (*ParenExpr) 16 // the returned position is the end position of the last enclosed 17 // expression. 18 // Thus, EndPos should not be used for exact demarcation of the 19 // end of a node in the source; it is mostly useful to determine 20 // scope ranges where there is some leeway. 21 func EndPos(n Node) Pos