<commit_before>package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
)

func main() {
	src := scanSrc(os.Args[1])
	eval(src)
}

func scanSrc(filename string) []byte {
	src, err := ioutil.ReadFile(filename)
	if err != nil {
		fmt.Println("Unable to read file:", err)
		os.Exit(0)
	}
	return src
}

func eval(b []byte) {
	c := [30000]byte{}
	p := 0
	nestedLoops := 0
	for i := 0; i < len(b); i++ {
		switch string(b[i]) {
		case ">":
			p++
		case "<":
			p--
		case "+":
			c[p]++
		case "-":
			c[p]--
		case ".":
			fmt.Print(string(c[p]))
		case ",":
			reader := bufio.NewReader(os.Stdin)
			input, _ := reader.ReadString('\n')
			c[p] = input[0]
		case "[":
			if c[p] != 0 {
			} else {
				i++
				lend := "]"[0]
				for nestedLoops > 0 || b[i] != lend {
					if b[i] == 91 {
						nestedLoops++
					}
					if b[i] == 93 {
						nestedLoops--
					}
					i++
				}
			}
		case "]":
			i--
			lbegin := "["[0]
			for nestedLoops > 0 || b[i] != lbegin {
				if b[i] == 91 {
					nestedLoops--
				}
				if b[i] == 93 {
					nestedLoops++
				}
				i--
			}
			i--
		}
	}
}
<commit_msg>Documentation.<commit_after>// Brainfugo is a Go implementation of a Brainfuck interpreter.
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
)

// main calls the brainfuck source scanner, then the evaluator.
func main() {
	src := scanSrc(os.Args[1])
	eval(src)
}

// scanSrc reads the brainfuck source code file.
func scanSrc(filename string) []byte {
	src, err := ioutil.ReadFile(filename)
	if err != nil {
		fmt.Println("Unable to read file:", err)
		os.Exit(0)
	}
	return src
}

// eval examines each byte of the brainfuck source code and processes it accordingly.
func eval(b []byte) {
	c := [30000]byte{}
	p := 0
	nestedLoops := 0
	for i := 0; i < len(b); i++ {
		switch string(b[i]) {
		case ">":
			p++
		case "<":
			p--
		case "+":
			c[p]++
		case "-":
			c[p]--
		case ".":
			fmt.Print(string(c[p]))
		case ",":
			reader := bufio.NewReader(os.Stdin)
			input, _ := reader.ReadString('\n')
			c[p] = input[0]
		case "[":
			if c[p] != 0 {
			} else {
				i++
				lend := "]"[0]
				for nestedLoops > 0 || b[i] != lend {
					if b[i] == 91 {
						nestedLoops++
					}
					if b[i] == 93 {
						nestedLoops--
					}
					i++
				}
			}
		case "]":
			i--
			lbegin := "["[0]
			for nestedLoops > 0 || b[i] != lbegin {
				if b[i] == 91 {
					nestedLoops--
				}
				if b[i] == 93 {
					nestedLoops++
				}
				i--
			}
			i--
		}
	}
}

{'fraction_non_alphanumeric': 0.200652528548124, 'fraction_numerical': 0.01957585644371941, 'mean_word_length': 2.0972222222222223, 'pattern_counts': {'":': 16, '<': 7, '<?xml version=': 0, '>': 9, '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': '287613', 'n_tokens_mistral': 1305, 'n_tokens_neox': 1037, 'n_words': 249}