<commit_before>package main

import (
	"fmt"

	linenoise "github.com/GeertJohan/go.linenoise"
	"github.com/glycerine/bigbird/gochick"
)

func main() {
	gochick.Start()

	for {
		line, err := linenoise.Line("> ")
		if err != nil {
			if err.Error() == "prompt was quited with a killsignal" {
				//fmt.Printf("ignoring: prompt was quited with a killsignal\n")
				continue
			}
			fmt.Printf("error: %v\n", err)
			continue
		}
		//fmt.Printf("line is %v\n", line)

		/*
			fset := token.NewFileSet()
			f, err := parser.ParseFile(fset, "", interface{}(line), parser.Trace)
			if err != nil {
				fmt.Printf("parse error: %v\n", err)
				continue
			}
			if f == nil {
				fmt.Printf("ast returned was nil\n")
			} else {
				fmt.Printf("f is %v\n", f)
			}
		*/
		schemeSrc := line

		s := gochick.Eval(schemeSrc)
		fmt.Printf("%v\n", s)
	}
}<commit_msg>repl.go has stubbed out three phases of processing: grab a line of golang input, translate into scheme, pass to scheme evaluator<commit_after>package main

import (
	"bufio"
	"fmt"
	"os"

	"go/parser"
	"go/token"
	"github.com/glycerine/bigbird/gochick"
)

func main() {
	gochick.Start()

	bParsing := false
	scanner := bufio.NewScanner(os.Stdin)

	lineNumber := 0
	line := ""
	var ok bool

	wrapper := `
     package main
     import (
       "fmt"
     )
     func main() {
      maincode := 0
     %s
     fmt.Printf("\n :maincode = %%d.\n", maincode)
     }
`

	for {
		lineNumber++
		fmt.Printf("%04d > ", lineNumber)
		ok = scanner.Scan()
		if !ok {
			fmt.Printf("\nok was false. quitting.\n")
			os.Exit(0)
		}

		if err := scanner.Err(); err != nil {
			panic(err)
		}
		line = scanner.Text()

		if line == ".parseoff" {
			bParsing = false
			fmt.Printf("parsing as golang off.\n")
			continue
		}

		if line == ".parseon" {
			bParsing = true
			fmt.Printf("parsing as golang on.\n")
			continue
		}

		fmt.Printf("line is: '%s'\n", line)

		wrapped := fmt.Sprintf(wrapper, line)
		fmt.Printf("wrapped line is: '%s'\n", wrapped)

		if bParsing {
			// first step of translating from golang to scheme:
			//  parse the go code using the standard libraries
			//  token and parse
			fset := token.NewFileSet()
			f, err := parser.ParseFile(fset, "", interface{}(wrapped), parser.Trace)
			if err != nil {
				fmt.Printf("parse error: %v\n", err)
				continue
			}
			if f == nil {
				fmt.Printf("ast returned was nil\n")
			} else {
				fmt.Printf("ast in f is %v\n", f)
			}
		}

		// step two: translate from golang to scheme
		schemeSrc := line

		// step three: evaluate in the chicken-scheme repl
		s := gochick.Eval(schemeSrc)
		fmt.Printf("chicken-scheme eval result: '%s'\n", s)
	}
}
{'fraction_non_alphanumeric': 0.1586284853051997, 'fraction_numerical': 0.0018839487565938207, 'mean_word_length': 2.672199170124481, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1898968', 'n_tokens_mistral': 1127, 'n_tokens_neox': 992, 'n_words': 256}