Skip to content

Commit

Permalink
fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
xrstf committed Nov 18, 2023
1 parent ed7184a commit deda901
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 39 deletions.
6 changes: 3 additions & 3 deletions pkg/eval/builtin/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,19 +310,19 @@ func rangeFunction(ctx types.Context, args []ast.Expression) (any, error) {
if size == 1 {
varNameIdent, ok := namingVector.Expressions[0].(ast.Identifier)
if !ok {
return nil, fmt.Errorf("loop variable name must be an identifer, got %T", namingVector.Expressions[0])
return nil, fmt.Errorf("loop variable name must be an identifier, got %T", namingVector.Expressions[0])
}

loopVarName = string(varNameIdent)
} else {
indexIdent, ok := namingVector.Expressions[0].(ast.Identifier)
if !ok {
return nil, fmt.Errorf("loop index name must be an identifer, got %T", namingVector.Expressions[0])
return nil, fmt.Errorf("loop index name must be an identifier, got %T", namingVector.Expressions[0])
}

varNameIdent, ok := namingVector.Expressions[1].(ast.Identifier)
if !ok {
return nil, fmt.Errorf("loop variable name must be an identifer, got %T", namingVector.Expressions[0])
return nil, fmt.Errorf("loop variable name must be an identifier, got %T", namingVector.Expressions[0])
}

loopIndexName = string(indexIdent)
Expand Down
2 changes: 1 addition & 1 deletion pkg/eval/builtin/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func TestHasFunction(t *testing.T) {

testVariables := types.Variables{
// value does not matter here, but this testcase is still meant
// to ensure the missing path is detected, not detect an uknown variable
// to ensure the missing path is detected, not detect an unknown variable
"myvar": 42,
"obj": testObjDocument,
"vec": testVecDocument,
Expand Down
4 changes: 2 additions & 2 deletions pkg/eval/builtin/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ func TestFromBase64Function(t *testing.T) {
invalid: true,
},
{
expr: `(from-base64 "definitly-not-base64")`,
expr: `(from-base64 "definitely-not-base64")`,
invalid: true,
},
{
// should be able to recover
expr: `(try (from-base64 "definitly-not-base64") "fallback")`,
expr: `(try (from-base64 "definitely-not-base64") "fallback")`,
expected: "fallback",
},
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/eval/coalescing/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func IsEmpty(val any) (bool, error) {
default:
lit, ok := val.(ast.Literal)
if !ok {
return false, fmt.Errorf("cannot termine emptiness oT %s", val)
return false, fmt.Errorf("cannot determine emptiness oT %s", val)
}

return IsEmpty(lit.LiteralValue())
Expand Down
2 changes: 1 addition & 1 deletion pkg/eval/eval_symbol.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func EvalSymbolWithEvaluatedPath(ctx types.Context, sym ast.Symbol, path ast.Eva
rootDoc := ctx.GetDocument()
rootValue := rootDoc.Get()

// santity check
// sanity check
if sym.Variable == nil && sym.PathExpression == nil {
return ctx, nil, errors.New("invalid symbol")
}
Expand Down
31 changes: 0 additions & 31 deletions pkg/lang/grammar/otto.peg
Original file line number Diff line number Diff line change
Expand Up @@ -161,37 +161,6 @@ KeyValuePair <- (key:ScalarExpression __ value:Expression) {
//////////////////////////////////////////////////////////
// path expressions

/*
possible symbols:

(each step is evaluated immediately, so foo.bar[0] is (foo.bar)[0], not foo.(bar[0]))

// regular identifier
identifier

// regular variable
$var

// traverse variable
$var.subkey
$var[0]
$var[$var]
$var[(add $var 1)]

// deeper traversal
$var.subkey[0].$othervar.subkey

// instead of traversing starting with a var, you can also
// start traversing the current object
.subkey
.subkey[$index].subsubkey.$varstep

// array acces on the global document; this needs a leading dot to distinguish
// it from a bare "[index]", which constructs an array with 1 element in it
.[index]

*/

Symbol <- '.' acc:VectorAccessor expr:AnyQualifiedPathExpression? {
arrAcc := acc.(ast.Expression)

Expand Down

0 comments on commit deda901

Please sign in to comment.