Loss, v. 1.11.11.1_

From Esolang
Jump to navigation Jump to search
Not to be confused with Loss.

Loss is a language that is currently in its most stable version, 1.11.11.1_. It is no longer being updated.

Syntax

I prints I
II prints II
II prints II
I_ prints I_

Example Program

Input:

I      II
II     I_

Output:

I      II
II     I_

Implementation

The following implementation is realized in the programming language Common Lisp:

(defun interpret-Loss-v-.1.11.11.1_ (code)
  "Interprets the piece of Loss, v. 1.11.11.1_ source code and returns
   no value."
  (declare (type string code))
  (let ((ip 0))
    (declare (type fixnum ip))
    (symbol-macrolet
        ((current-character (the character (char code     ip)))
         (next-character    (the character (char code (1+ ip))))
         (next-character-is-identifier-p
          (the boolean
            (not (null
              (and (array-in-bounds-p code ip)
                   (find next-character "I_" :test #'char=)))))))
      (declare (type character current-character next-character)
               (type boolean   next-character-is-identifier-p))
      (loop while (< ip (length code)) do
        (case current-character
          (#\I
            (format T "~c" current-character)
            (when next-character-is-identifier-p
              (format T "~c" next-character)
              (incf ip))
            (incf ip))
          ((#\Space #\Tab #\Newline)
            (format T "~c" current-character)
            (incf ip))
          (otherwise
            (error "Cannot print the character \"~c\" at position ~d."
              current-character ip))))))
  (values))