~akarle/fisl

95960e0a1c88238e4202f22518fc231ff8333318 — Alex Karle 1 year, 5 months ago 4913379
docs: Fix some TODO's and comment indentation

Emacs likes to put single-; comments way to the right :(

Mostly back in Vim now, if anyone is curious.
2 files changed, 6 insertions(+), 9 deletions(-)

M interpreter.scm
M scanner.scm
M interpreter.scm => interpreter.scm +0 -3
@@ 21,16 21,13 @@
   (else (equal? a b))))

(define (assert-num op x)
  ;; TODO: use call/cc to not abort the process
  (or (number? x) (runtime-err! (format "Operand must be a number ~A ~A" op x))))

(define (assert-nums op x y)
  ;; TODO: use call/cc to not abort the process
  (or (and (number? x) (number? y))
      (runtime-err! (format "Operands must be numbers ~A ~A ~A" x op y))))

(define (evaluate expr)
  ;; TODO: put these on the types themselves? like methods
  (cond
   ((literal? expr) (literal-value expr))
   ((grouping? expr)

M scanner.scm => scanner.scm +6 -6
@@ 42,15 42,15 @@

(define (scan src)
  (define (peek i)
					; safe string-ref
    ;; safe string-ref
    (if (< i (string-length src))
        (string-ref src i)
        #f))

  (define (get-tokens s i line in)
					; Gets all tokens after 'start', tracks state in i (current char), line, in
    ;; Gets all tokens after 'start', tracks state in i (current char), line, in
    (define (tok-range type s2 i2)
					; Helper to make a token, cons it to our list, and recurse with fresh state
      ;; Helper to make a token, cons it to our list, and recurse with fresh state
      (let ((text (substring src s2 (add1 i2))))
        (let ((tok (cond
                    ((eq? type 'STRING) (make-token type text (substring src (add1 s2) i2) line))


@@ 64,15 64,15 @@
          (cons tok (get-tokens (add1 i2) (add1 i2) line #f)))))

    (define (tok type)
					; helper to tokenize current span
      ;; helper to tokenize current span
      (tok-range type s i))

    (define (skip . line2)
					; Helper to skip this character range
      ;; Helper to skip this character range
      (get-tokens (add1 i) (add1 i) (optional line2 line) in))

    (define (advance . line2)
					; Helper to iterate; keeps start but increments range
      ;; Helper to iterate; keeps start but increments range
      (get-tokens s (add1 i) (optional line2 line) in))

    (let ((c (peek i)) (n (peek (add1 i))))