<commit_before>(load "./util.scm")
(load "./macro.scm")
(load "./compile.scm")
(load "./linear.scm")
(load "./vm.scm")
(use slib)
(require 'trace)

(define evaluate
  (lambda (x)
    (VM '()     ; accumlator
        0       ; program counter
        0       ; frame pointer
        0       ; argp pointer
        '()     ; closure
        0       ; stack pointer
        (3imp->linear ;code
         (compile (expand-traditional-macro x) '(() . ()) '() '(halt))
         0))))

(define debug
  (lambda (code)
    (let* ([opecode  (compile (expand-traditional-macro code) '(() . ()) '() '(halt))]
           [opecode2 (3imp->linear opecode 0)])
      (display opecode)
      (newline)
      (display opecode2)
      (newline)
      (display (VM '() 0 0 0 '() 0 opecode2))
      (newline))))

;; C$B8@8l$h$&$K%U%)!<%^%C%H$9$k!%(B
(define linear-compile
  (lambda (code)
    (map (lambda (x)
           (recur next ([x x])
                  (unless (null? x)
                    (display (car x))
                    (display " ")
                    (next (cdr x))))
           (newline))
        (3imp->linear
         (compile (expand-traditional-macro code) '(() . ()) '() '(halt))
         0))))

(linear-compile '(letrec ([s (lambda (x)
                               (if (= x 0)
                                 0
                                 (+ x (s (- x 1)))))])
                   (s 10)))<commit_msg>add myrepl<commit_after>#!/usr/bin/gosh

(load "./util.scm")
(load "./macro.scm")
(load "./compile.scm")
(load "./linear.scm")
(load "./vm.scm")
(use slib)
(require 'trace)

(define evaluate
  (lambda (x)
    (VM '()     ; accumlator
        0       ; program counter
        0       ; frame pointer
        0       ; argp pointer
        '()     ; closure
        0       ; stack pointer
        (3imp->linear ;code
         (compile (expand-traditional-macro x) '(() . ()) '() '(halt))
         0))))

(define debug
  (lambda (code)
    (let* ([opecode  (compile (expand-traditional-macro code) '(() . ()) '() '(halt))]
           [opecode2 (3imp->linear opecode 0)])
      (display opecode)
      (newline)
      (display opecode2)
      (newline)
      (display (VM '() 0 0 0 '() 0 opecode2))
      (newline))))

;; C$B8@8l$h$&$K%U%)!<%^%C%H$9$k!%(B
(define linear-compile
  (lambda (code)
    (map (lambda (x)
           (recur next ([x x])
                  (unless (null? x)
                    (display (car x))
                    (display " ")
                    (next (cdr x))))
           (newline))
        (3imp->linear
         (compile (expand-traditional-macro code) '(() . ()) '() '(halt))
         0))))

;(linear-compile '(letrec ([s (lambda (x)
;                               (if (= x 0)
;                                 0
;                                 (+ x (s (- x 1)))))])
;                   (s 10)))

(define my-repl
  (lambda ()
    (let ([c (read)])
      (unless (eof-object? c)
        (linear-compile c)))))

(my-repl)
{'fraction_non_alphanumeric': 0.18882531134298217, 'fraction_numerical': 0.01682935038707506, 'mean_word_length': 1.4684385382059801, 'pattern_counts': {'":': 0, '<': 5, '<?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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1704053', 'n_tokens_mistral': 1063, 'n_tokens_neox': 995, 'n_words': 237}