Fix "indicies" -> indices.

This commit is contained in:
Qi Xiao 2021-08-22 23:31:26 +01:00
parent c1ebcbb296
commit 4d62732ebc
12 changed files with 29 additions and 29 deletions

View File

@ -1,2 +1,2 @@
[codespell]
ignore-words-list = upto,nd,ba,doas,fo,struc,indicies,shouldbe,iterm,lates,testof
ignore-words-list = upto,nd,ba,doas,fo,struc,shouldbe,iterm,lates,testof

View File

@ -112,7 +112,7 @@ func completeIndex(n parse.Node, cfg Config) (*context, []RawItem, error) {
if is(parent(n), aIndexing) {
// We are just after an opening bracket.
indexing := parent(n).(*parse.Indexing)
if len(indexing.Indicies) == 1 {
if len(indexing.Indices) == 1 {
if indexee := ev.PurelyEvalPrimary(indexing.Head); indexee != nil {
return generateForEmpty(indexee, n.Range().To)
}
@ -123,7 +123,7 @@ func completeIndex(n parse.Node, cfg Config) (*context, []RawItem, error) {
if is(parent(array), aIndexing) {
// We are after an existing index and spaces.
indexing := parent(array).(*parse.Indexing)
if len(indexing.Indicies) == 1 {
if len(indexing.Indices) == 1 {
if indexee := ev.PurelyEvalPrimary(indexing.Head); indexee != nil {
return generateForEmpty(indexee, n.Range().To)
}
@ -141,7 +141,7 @@ func completeIndex(n parse.Node, cfg Config) (*context, []RawItem, error) {
if is(parent(array), aIndexing) {
// We are just after an incomplete index.
indexing := parent(array).(*parse.Indexing)
if len(indexing.Indicies) == 1 {
if len(indexing.Indices) == 1 {
if indexee := ev.PurelyEvalPrimary(indexing.Head); indexee != nil {
ctx := &context{
"index", seed, primary.Type, compound.Range()}

View File

@ -176,7 +176,7 @@ func emitVariableRegion(n *parse.Compound, f func(parse.Node, regionKind, string
}
func isBarewordCompound(n *parse.Compound) bool {
return len(n.Indexings) == 1 && len(n.Indexings[0].Indicies) == 0 && n.Indexings[0].Head.Type == parse.Bareword
return len(n.Indexings) == 1 && len(n.Indexings[0].Indices) == 0 && n.Indexings[0].Head.Type == parse.Bareword
}
func emitRegionsInIf(n *parse.Form, f func(parse.Node, regionKind, string)) {

View File

@ -82,8 +82,8 @@ func compileVar(cp *compiler, fn *parse.Form) effectOp {
if len(cn.Indexings) != 1 {
cp.errorpf(cn, "variable name must be a single string literal")
}
if len(cn.Indexings[0].Indicies) > 0 {
cp.errorpf(cn, "variable name must not have indicies")
if len(cn.Indexings[0].Indices) > 0 {
cp.errorpf(cn, "variable name must not have indices")
}
pn := cn.Indexings[0].Head
if !parse.ValidLHSVariable(pn, true) {
@ -150,7 +150,7 @@ func compileDel(cp *compiler, fn *parse.Form) effectOp {
cp.errorpf(cn, delArgMsg)
continue
}
head, indices := cn.Indexings[0].Head, cn.Indexings[0].Indicies
head, indices := cn.Indexings[0].Head, cn.Indexings[0].Indices
if head.Type == parse.Variable {
cp.errorpf(cn, "arguments to del must drop $")
} else if !parse.ValidLHSVariable(head, false) {

View File

@ -48,7 +48,7 @@ func (cp *compiler) parseCompoundLValues(ns []*parse.Compound) lvaluesGroup {
func (cp *compiler) parseIndexingLValue(n *parse.Indexing) lvaluesGroup {
if n.Head.Type == parse.Braced {
// Braced list of lvalues may not have indices.
if len(n.Indicies) > 0 {
if len(n.Indices) > 0 {
cp.errorpf(n, "braced list may not have indices when used as lvalue")
}
return cp.parseCompoundLValues(n.Head.Braced)
@ -60,7 +60,7 @@ func (cp *compiler) parseIndexingLValue(n *parse.Indexing) lvaluesGroup {
varUse := n.Head.Value
sigil, qname := SplitSigil(varUse)
var ref *varRef
if len(n.Indicies) == 0 {
if len(n.Indices) == 0 {
ref = resolveVarRef(cp, qname, nil)
if ref == nil {
segs := SplitQNameSegs(qname)
@ -80,12 +80,12 @@ func (cp *compiler) parseIndexingLValue(n *parse.Indexing) lvaluesGroup {
cp.errorpf(n, "cannot find variable $%s", qname)
}
}
ends := make([]int, len(n.Indicies)+1)
ends := make([]int, len(n.Indices)+1)
ends[0] = n.Head.Range().To
for i, idx := range n.Indicies {
for i, idx := range n.Indices {
ends[i+1] = idx.Range().To
}
lv := lvalue{n.Range(), ref, cp.arrayOps(n.Indicies), ends}
lv := lvalue{n.Range(), ref, cp.arrayOps(n.Indices), ends}
restIndex := -1
if sigil == "@" {
restIndex = 0

View File

@ -206,10 +206,10 @@ func (cp *compiler) arrayOps(ns []*parse.Array) []valuesOp {
}
func (cp *compiler) indexingOp(n *parse.Indexing) valuesOp {
if len(n.Indicies) == 0 {
if len(n.Indices) == 0 {
return cp.primaryOp(n.Head)
}
return &indexingOp{n.Range(), cp.primaryOp(n.Head), cp.arrayOps(n.Indicies)}
return &indexingOp{n.Range(), cp.primaryOp(n.Head), cp.arrayOps(n.Indices)}
}
func (cp *compiler) indexingOps(ns []*parse.Indexing) []valuesOp {

View File

@ -15,7 +15,7 @@ func (ev *Evaler) PurelyEvalPartialCompound(cn *parse.Compound, upto int) (strin
tilde := false
head := ""
for _, in := range cn.Indexings {
if len(in.Indicies) > 0 {
if len(in.Indices) > 0 {
return "", false
}
if upto >= 0 && in.To > upto {

View File

@ -13,7 +13,7 @@ import (
//
// During compilation, a qualified variable name (whether in lvalue, like "x
// = foo", or in variable use, like "$x") is searched in compiler's staticNs
// tables to determine which scope they belong to, as well as their indicies in
// tables to determine which scope they belong to, as well as their indices in
// that scope. This step is just called "resolve" in the code, and it stores
// information in a varRef struct.
//

View File

@ -10,7 +10,7 @@ import (
// Primary returns a primary node and true if that's the only child of the
// compound node. Otherwise it returns nil and false.
func Primary(n *parse.Compound) (*parse.Primary, bool) {
if len(n.Indexings) == 1 && len(n.Indexings[0].Indicies) == 0 {
if len(n.Indexings) == 1 && len(n.Indexings[0].Indices) == 0 {
return n.Indexings[0].Head, true
}
return nil, false
@ -58,7 +58,7 @@ func Shape(n *parse.Compound) string {
return "compound expression"
}
in := n.Indexings[0]
if len(in.Indicies) > 0 {
if len(in.Indices) > 0 {
return "indexing expression"
}
pn := in.Head

View File

@ -422,9 +422,9 @@ func startsCompound(r rune, ctx ExprCtx) bool {
// Indexing = Primary { '[' Array ']' }
type Indexing struct {
node
ExprCtx ExprCtx
Head *Primary
Indicies []*Array
ExprCtx ExprCtx
Head *Primary
Indices []*Array
}
func (in *Indexing) parse(ps *parser) {
@ -434,7 +434,7 @@ func (in *Indexing) parse(ps *parser) {
ps.error(errShouldBeArray)
}
ps.parse(&Array{}).addTo(&in.Indicies, in)
ps.parse(&Array{}).addTo(&in.Indices, in)
if !parseSep(in, ps, ']') {
ps.error(errShouldBeRBracket)

View File

@ -195,7 +195,7 @@ var testCases = []struct {
code: "$b[c][d][\ne\n]",
node: &Indexing{},
want: ast{"Indexing", fs{
"Head": "$b", "Indicies": []string{"c", "d", "\ne\n"}}},
"Head": "$b", "Indices": []string{"c", "d", "\ne\n"}}},
},
// Primary

View File

@ -368,18 +368,18 @@ func benchmarkIndexSeqPersistent(b *testing.B, n int) {
}
}
var randIndicies []int
var randIndices []int
func init() {
randIndicies = make([]int, N4)
randIndices = make([]int, N4)
for i := 0; i < N4; i++ {
randIndicies[i] = rand.Intn(N4)
randIndices[i] = rand.Intn(N4)
}
}
func BenchmarkIndexRandNative(b *testing.B) {
for r := 0; r < b.N; r++ {
for _, i := range randIndicies {
for _, i := range randIndices {
x = sliceN4[i]
}
}
@ -387,7 +387,7 @@ func BenchmarkIndexRandNative(b *testing.B) {
func BenchmarkIndexRandPersistent(b *testing.B) {
for r := 0; r < b.N; r++ {
for _, i := range randIndicies {
for _, i := range randIndices {
x, _ = vectorN4.Index(i)
}
}