style: no "this" or "self" as receiver
This commit is contained in:
@@ -6,9 +6,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Define the correct logger for the program to use.
|
// Define the correct logger for the program to use.
|
||||||
func (this Config) GetLogger() *slog.Logger {
|
func (c Config) GetLogger() *slog.Logger {
|
||||||
var level slog.Level
|
var level slog.Level
|
||||||
if this.Verbose {
|
if c.Verbose {
|
||||||
level = slog.LevelInfo
|
level = slog.LevelInfo
|
||||||
} else {
|
} else {
|
||||||
level = slog.LevelError
|
level = slog.LevelError
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ type Source interface {
|
|||||||
// A source coming from a string.
|
// A source coming from a string.
|
||||||
type StringSource struct{ data string }
|
type StringSource struct{ data string }
|
||||||
|
|
||||||
func (this StringSource) Pull() (string, error) { return this.data, nil }
|
func (s StringSource) Pull() (string, error) { return s.data, nil }
|
||||||
|
|
||||||
// A source coming from standard input.
|
// A source coming from standard input.
|
||||||
type StdinSource struct{}
|
type StdinSource struct{}
|
||||||
|
|
||||||
func (this StdinSource) Pull() (string, error) {
|
func (s StdinSource) Pull() (string, error) {
|
||||||
data, err := io.ReadAll(os.Stdin)
|
data, err := io.ReadAll(os.Stdin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ type Abstraction struct {
|
|||||||
Body Expression
|
Body Expression
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Abstraction) Copy() Expression {
|
func (a *Abstraction) Copy() Expression {
|
||||||
return NewAbstraction(this.Parameter, this.Body.Copy())
|
return NewAbstraction(a.Parameter, a.Body.Copy())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Abstraction) Accept(v Visitor) {
|
func (a *Abstraction) Accept(v Visitor) {
|
||||||
v.VisitAbstraction(this)
|
v.VisitAbstraction(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAbstraction(parameter string, body Expression) *Abstraction {
|
func NewAbstraction(parameter string, body Expression) *Abstraction {
|
||||||
@@ -31,12 +31,12 @@ type Application struct {
|
|||||||
Argument Expression
|
Argument Expression
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Application) Copy() Expression {
|
func (a *Application) Copy() Expression {
|
||||||
return NewApplication(this.Abstraction.Copy(), this.Argument.Copy())
|
return NewApplication(a.Abstraction.Copy(), a.Argument.Copy())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Application) Accept(v Visitor) {
|
func (a *Application) Accept(v Visitor) {
|
||||||
v.VisitApplication(this)
|
v.VisitApplication(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewApplication(function Expression, argument Expression) *Application {
|
func NewApplication(function Expression, argument Expression) *Application {
|
||||||
@@ -49,12 +49,12 @@ type Variable struct {
|
|||||||
Value string
|
Value string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Variable) Copy() Expression {
|
func (v *Variable) Copy() Expression {
|
||||||
return NewVariable(this.Value)
|
return NewVariable(v.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Variable) Accept(v Visitor) {
|
func (v *Variable) Accept(visitor Visitor) {
|
||||||
v.VisitVariable(this)
|
visitor.VisitVariable(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewVariable(name string) *Variable {
|
func NewVariable(name string) *Variable {
|
||||||
|
|||||||
@@ -6,23 +6,23 @@ type stringifyVisitor struct {
|
|||||||
builder strings.Builder
|
builder strings.Builder
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *stringifyVisitor) VisitVariable(a *Variable) {
|
func (v *stringifyVisitor) VisitVariable(a *Variable) {
|
||||||
this.builder.WriteString(a.Value)
|
v.builder.WriteString(a.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *stringifyVisitor) VisitAbstraction(f *Abstraction) {
|
func (v *stringifyVisitor) VisitAbstraction(f *Abstraction) {
|
||||||
this.builder.WriteRune('\\')
|
v.builder.WriteRune('\\')
|
||||||
this.builder.WriteString(f.Parameter)
|
v.builder.WriteString(f.Parameter)
|
||||||
this.builder.WriteRune('.')
|
v.builder.WriteRune('.')
|
||||||
f.Body.Accept(this)
|
f.Body.Accept(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *stringifyVisitor) VisitApplication(c *Application) {
|
func (v *stringifyVisitor) VisitApplication(c *Application) {
|
||||||
this.builder.WriteRune('(')
|
v.builder.WriteRune('(')
|
||||||
c.Abstraction.Accept(this)
|
c.Abstraction.Accept(v)
|
||||||
this.builder.WriteRune(' ')
|
v.builder.WriteRune(' ')
|
||||||
c.Argument.Accept(this)
|
c.Argument.Accept(v)
|
||||||
this.builder.WriteRune(')')
|
v.builder.WriteRune(')')
|
||||||
}
|
}
|
||||||
|
|
||||||
func Stringify(e Expression) string {
|
func Stringify(e Expression) string {
|
||||||
|
|||||||
@@ -2,32 +2,32 @@ package set
|
|||||||
|
|
||||||
type Set[T comparable] map[T]bool
|
type Set[T comparable] map[T]bool
|
||||||
|
|
||||||
func (this *Set[T]) Add(items ...T) {
|
func (s *Set[T]) Add(items ...T) {
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
(*this)[item] = true
|
(*s)[item] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Set[T]) Has(item T) bool {
|
func (s Set[T]) Has(item T) bool {
|
||||||
return this[item] == true
|
return s[item] == true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Set[T]) Remove(items ...T) {
|
func (s *Set[T]) Remove(items ...T) {
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
delete(*this, item)
|
delete(*s, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Set[T]) Union(o Set[T]) {
|
func (s *Set[T]) Union(o Set[T]) {
|
||||||
for item := range o {
|
for item := range o {
|
||||||
this.Add(item)
|
s.Add(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this Set[T]) ToList() []T {
|
func (s Set[T]) ToList() []T {
|
||||||
list := []T{}
|
list := []T{}
|
||||||
|
|
||||||
for item := range this {
|
for item := range s {
|
||||||
list = append(list, item)
|
list = append(list, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user