<commit_before>// Copyright (C) 2017 <NAME>
// See LICENSE for copying information.

package main

import (
	"bytes"
	"fmt"
)

type Byte byte

func (b Byte) String() string {
	return fmt.Sprintf("byte(%x)", string(b))
}

type Builtin struct {
	Name      string
	Transform func(*Context, Value) (val Value, cacheable bool, err error)
}

func (b *Builtin) String() string {
	return fmt.Sprintf("builtin(%s)", b.Name)
}

func nextByte(ctx *Context, v Value) (Value, bool, error) {
	if t, ok := v.(Byte); ok {
		return Byte(t + 1), true, nil
	}
	return nil, false, fmt.Errorf("type %T is not a byte", v)
}

func printByte(ctx *Context, v Value) (Value, bool, error) {
	if t, ok := v.(Byte); ok {
		_, err := fmt.Fprint(ctx.out, string(t))
		return v, false, err
	}
	return nil, false, fmt.Errorf("type %T is not a byte", v)
}

type Scope struct {
	Name   string
	Value  Value
	Parent *Scope
}

func NewScope() *Scope {
	return nil // deliberate
}

func NewScopeWithBuiltins() *Scope {
	expr, err := Parse(NewStream(bytes.NewReader([]byte(`
    \n.(\a.\b.b (print (n next null)) n)
  `))))
	if err != nil {
		// programmer screwed up the builtin above
		panic(err)
	}
	return NewScope().Set("PRINT_BYTE", NewClosure(
		NewScope().
			Set("null", Byte(0)).
			SetBuiltin("print", printByte).
			SetBuiltin("next", nextByte),
		expr.Expr.(*LambdaExpr)))
}

func (s *Scope) Get(name string) Value {
	if s == nil {
		return nil
	}<commit_msg>tabbing<commit_after>// Copyright (C) 2017 <NAME>
// See LICENSE for copying information.

package main

import (
	"bytes"
	"fmt"
)

type Byte byte

func (b Byte) String() string {
	return fmt.Sprintf("byte(%x)", string(b))
}

type Builtin struct {
	Name      string
	Transform func(*Context, Value) (val Value, cacheable bool, err error)
}

func (b *Builtin) String() string {
	return fmt.Sprintf("builtin(%s)", b.Name)
}

func nextByte(ctx *Context, v Value) (Value, bool, error) {
	if t, ok := v.(Byte); ok {
		return Byte(t + 1), true, nil
	}
	return nil, false, fmt.Errorf("type %T is not a byte", v)
}

func printByte(ctx *Context, v Value) (Value, bool, error) {
	if t, ok := v.(Byte); ok {
		_, err := fmt.Fprint(ctx.out, string(t))
		return v, false, err
	}
	return nil, false, fmt.Errorf("type %T is not a byte", v)
}

type Scope struct {
	Name   string
	Value  Value
	Parent *Scope
}

func NewScope() *Scope {
	return nil // deliberate
}

func NewScopeWithBuiltins() *Scope {
	expr, err := ParseExpr(NewStream(bytes.NewReader([]byte(
		`\n.(\a.\b.b (print (n next null)) n)`))))
	if err != nil {
		// programmer screwed up the builtin above
		panic(err)
	}
	return NewScope().Set("PRINT_BYTE", NewClosure(
		NewScope().
			Set("null", Byte(0)).
			SetBuiltin("print", printByte).
			SetBuiltin("next", nextByte),
		expr.(*LambdaExpr)))
}

func (s *Scope) Get(name string) Value {
	if s == nil {
		return nil
	}
{'fraction_non_alphanumeric': 0.16362999299229153, 'fraction_numerical': 0.004204625087596356, 'mean_word_length': 3.6880131362889985, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4271896', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1030, 'n_words': 330}