Church and State (part 1)

After porting jolt-burg I started developing a higher level language on top of it. My codenames for this high-level and low-level combination are Church and State.

State

My implementation of State has been progressing steadily to the point where I have the following features:

  • lisp-like sexp syntax (I use the lisp reader from the host environment to read the State source files)
  • functions and global variables
  • Macros
    
    (syntax end? (x) `(if (null? ,x)
                          1
                          (if (pair? ,x)
                              0
                              (abort "bad list encountered in end?"))))
    
  • partial lexical closures (also known as ‘downward funargs’)
    (define |main| (lambda ()
                     (let ((a 1)
                           (b 2))
                       ((lambda (arg)
                          (+ arg a)) b))))
    
    
  • basic machine operations such as + – * bitwise and, bitwise or and bitshifts
  • if forms
    
    (if a
        1
        2)
    
    
  • ‘cond’, ‘and’ and ‘or’ forms
  • the tagbody control structure
    (tagbody
       start
       (setup-vars) 
       next
       (process-next)
       (if (end)
           (go finished)
           (go next))
       finished
       (cleanup))
    
    
  • primitive structures
  • non-local-return
    
    (define foo (lambda ()
                     (block a
                       (block b
                         (return-from foo 1)))
                     (not-executed)))
    
    

All of the above has been implemented with a 32-bit x86 backend. The compiler generates relocatable code which is written to ELF objects and linked with the unix linker.