style: no underscores in variable names
This commit is contained in:
@@ -5,8 +5,8 @@ func ReduceOnce(e *Expression) bool {
|
||||
case *Abstraction:
|
||||
return ReduceOnce(&typed.Body)
|
||||
case *Application:
|
||||
fn, fn_ok := typed.Abstraction.(*Abstraction)
|
||||
if fn_ok {
|
||||
fn, fnOk := typed.Abstraction.(*Abstraction)
|
||||
if fnOk {
|
||||
Substitute(&fn.Body, fn.Parameter, typed.Argument)
|
||||
*e = fn.Body
|
||||
return true
|
||||
|
||||
@@ -11,16 +11,16 @@ func Substitute(e *Expression, target string, replacement Expression) {
|
||||
return
|
||||
}
|
||||
|
||||
replacement_free_vars := GetFreeVariables(replacement)
|
||||
if !replacement_free_vars.Has(typed.Parameter) {
|
||||
replacementFreeVars := GetFreeVariables(replacement)
|
||||
if !replacementFreeVars.Has(typed.Parameter) {
|
||||
Substitute(&typed.Body, target, replacement)
|
||||
return
|
||||
}
|
||||
|
||||
used := GetFreeVariables(typed.Body)
|
||||
used.Union(replacement_free_vars)
|
||||
fresh_var := GenerateFreshName(used)
|
||||
Rename(typed, typed.Parameter, fresh_var)
|
||||
used.Union(replacementFreeVars)
|
||||
freshVar := GenerateFreshName(used)
|
||||
Rename(typed, typed.Parameter, freshVar)
|
||||
Substitute(&typed.Body, target, replacement)
|
||||
case *Application:
|
||||
Substitute(&typed.Abstraction, target, replacement)
|
||||
|
||||
@@ -23,9 +23,9 @@ func ParseExpression(i *iterator.Iterator[tokenizer.Token]) (lambda.Expression,
|
||||
atoms := []string{}
|
||||
|
||||
for {
|
||||
atom, atom_err := i.Next()
|
||||
if atom_err != nil {
|
||||
return nil, fmt.Errorf("could not find parameter or terminator of function: %w", atom_err)
|
||||
atom, atomErr := i.Next()
|
||||
if atomErr != nil {
|
||||
return nil, fmt.Errorf("could not find parameter or terminator of function: %w", atomErr)
|
||||
} else if atom.Type == tokenizer.TokenVariable {
|
||||
atoms = append(atoms, atom.Value)
|
||||
} else if atom.Type == tokenizer.TokenDot {
|
||||
@@ -39,9 +39,9 @@ func ParseExpression(i *iterator.Iterator[tokenizer.Token]) (lambda.Expression,
|
||||
return nil, fmt.Errorf("every function must have atleast one parameter (column %d)", token.Index)
|
||||
}
|
||||
|
||||
body, body_err := ParseExpression(i)
|
||||
if body_err != nil {
|
||||
return nil, fmt.Errorf("could not parse function body: %w", body_err)
|
||||
body, bodyErr := ParseExpression(i)
|
||||
if bodyErr != nil {
|
||||
return nil, fmt.Errorf("could not parse function body: %w", bodyErr)
|
||||
}
|
||||
|
||||
// Construction.
|
||||
@@ -52,29 +52,29 @@ func ParseExpression(i *iterator.Iterator[tokenizer.Token]) (lambda.Expression,
|
||||
|
||||
return result, nil
|
||||
case tokenizer.TokenOpenParen:
|
||||
fn, fn_err := ParseExpression(i)
|
||||
if fn_err != nil {
|
||||
return nil, fmt.Errorf("could not parse call function: %w", fn_err)
|
||||
fn, fnErr := ParseExpression(i)
|
||||
if fnErr != nil {
|
||||
return nil, fmt.Errorf("could not parse call function: %w", fnErr)
|
||||
}
|
||||
|
||||
args := []lambda.Expression{}
|
||||
|
||||
for {
|
||||
if next, next_err := i.Peek(); next_err == nil && next.Type == tokenizer.TokenCloseParen {
|
||||
if next, nextErr := i.Peek(); nextErr == nil && next.Type == tokenizer.TokenCloseParen {
|
||||
break
|
||||
}
|
||||
|
||||
arg, arg_err := ParseExpression(i)
|
||||
if arg_err != nil {
|
||||
return nil, fmt.Errorf("could not parse call argument: %w", arg_err)
|
||||
arg, argErr := ParseExpression(i)
|
||||
if argErr != nil {
|
||||
return nil, fmt.Errorf("could not parse call argument: %w", argErr)
|
||||
}
|
||||
|
||||
args = append(args, arg)
|
||||
}
|
||||
|
||||
close, close_err := i.Next()
|
||||
if close_err != nil {
|
||||
return nil, fmt.Errorf("Could not parse call terminating parenthesis: %w", close_err)
|
||||
close, closeErr := i.Next()
|
||||
if closeErr != nil {
|
||||
return nil, fmt.Errorf("Could not parse call terminating parenthesis: %w", closeErr)
|
||||
} else if close.Type != tokenizer.TokenCloseParen {
|
||||
return nil, fmt.Errorf("expected call terminating parenthesis, got '%v' (column %v)", close.Value, close.Index)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user