Skip to content

Commit

Permalink
chore: clean up code and add copyright header (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
muktihari authored Dec 30, 2023
1 parent 340f13e commit a801aaa
Show file tree
Hide file tree
Showing 33 changed files with 436 additions and 24 deletions.
15 changes: 14 additions & 1 deletion arithmetic.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package expr

import (
Expand All @@ -6,7 +19,7 @@ import (
"go/token"
"math"

"github.com/muktihari/expr/conv"
"github.com/muktihari/expr/internal/conv"
)

func arithmetic(v, vx, vy *Visitor, binaryExpr *ast.BinaryExpr) {
Expand Down
13 changes: 13 additions & 0 deletions arithmetic_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package expr

import (
Expand Down
14 changes: 13 additions & 1 deletion bind/bind.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
// bind is an helper to bind variable values into the string expression.
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package bind

import (
Expand Down
13 changes: 13 additions & 0 deletions bind/bind_benchmark_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package bind_test

import (
Expand Down
13 changes: 13 additions & 0 deletions bind/bind_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package bind

import (
Expand Down
15 changes: 15 additions & 0 deletions bind/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package bind is an helper to bind variable values into the string expression.
package bind
15 changes: 14 additions & 1 deletion bitwise.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package expr

import (
"fmt"
"go/ast"
"go/token"

"github.com/muktihari/expr/conv"
"github.com/muktihari/expr/internal/conv"
)

func bitwise(v, vx, vy *Visitor, binaryExpr *ast.BinaryExpr) {
Expand Down
13 changes: 13 additions & 0 deletions bitwise_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package expr

import (
Expand Down
15 changes: 14 additions & 1 deletion comparison.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package expr

import (
"fmt"
"go/ast"
"go/token"

"github.com/muktihari/expr/conv"
"github.com/muktihari/expr/internal/conv"
)

func comparison(v, vx, vy *Visitor, binaryExpr *ast.BinaryExpr) {
Expand Down
13 changes: 13 additions & 0 deletions comparison_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package expr

import (
Expand Down
13 changes: 0 additions & 13 deletions conv/conv.go

This file was deleted.

15 changes: 15 additions & 0 deletions docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package expr is the core of this library, it contains implementation to parse and evaluate mathematical and boolean expression.
package expr
13 changes: 13 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package expr

import (
Expand Down
16 changes: 16 additions & 0 deletions exp/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package exp contains experimental projects. Packages under this package are not guaranteed to be stable
// nor should it be maintained its backward compatibility.
package exp
2 changes: 1 addition & 1 deletion explain/README.md → exp/explain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ Explain is a standalone package aimed to explain step by step operation in expr.
// explanation:
// 1 + 2 -> 3
// (1 + 2) + 3 -> (3 + 3) -> 6
```
```
16 changes: 16 additions & 0 deletions exp/explain/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package explain is a standalone package aimed to explain step by step operation in expr.
// This package is EXPERIMENTAL, and it's not guaranteed to be stable nor should it be maintained its backward compatibility.
package explain
14 changes: 13 additions & 1 deletion explain/explain.go → exp/explain/explain.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
// explain is a standalone package aimed to explain step by step operation in expr.
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package explain

import (
Expand Down
15 changes: 14 additions & 1 deletion explain/explain_test.go → exp/explain/explain_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package explain_test

import (
Expand All @@ -6,7 +19,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/muktihari/expr"
"github.com/muktihari/expr/explain"
"github.com/muktihari/expr/exp/explain"
)

func TestExplain(t *testing.T) {
Expand Down
15 changes: 14 additions & 1 deletion explain/visitor.go → exp/explain/visitor.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package explain

import (
"fmt"
"go/ast"

"github.com/muktihari/expr"
"github.com/muktihari/expr/conv"
"github.com/muktihari/expr/internal/conv"
)

type exprType int
Expand Down
13 changes: 13 additions & 0 deletions explain/visitor_test.go → exp/explain/visitor_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package explain

import (
Expand Down
13 changes: 13 additions & 0 deletions expr.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2020-2023 The Expr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package expr

import (
Expand Down
Loading

0 comments on commit a801aaa

Please sign in to comment.