Linea:   line oriented reader
1 Stability
2 Linea Guide
3 Linea Reference
3.1 linea/  default
#%linea-expressions-begin
#%linea-line
#%linea-s-exp
3.2 linea/  line-macro
define-line-macro
with-default-line-macro
splicing-with-default-line-macro
3.3 linea/  line-macro-prop
3.4 #lang linea
3.5 linea/  read
4 Code and License
6.12

Linea: line oriented reader

William Hatch <[email protected]>

Linea is a line-oriented reader and one of the main components of the Rash language. While it was designed for Rash, it is flexible and suited to many potential line-oriented languages. Linea is simply another way to write s-expressions.

Note that you can’t represent any arbitrary s-expression with Linea, but you can represent a very useful subset of them.

1 Stability

Not yet stable. Things may still change a bit.

2 Linea Guide

TODO

Explanation of inner/outer reading, readtable modifications, #%symbol defaults.

TL;DR

This module:

#lang linea "my-lang-bindings.rkt"

 

finwe feanor fingolfin finarfin

 

beren (and) \

  luthien tinuviel

 

(huon (vs) werewolf-sauron)

 

manwe orome {

  varda yavanna

  aule (mandos

        nienna #{ulmo tulkas})

  melkor

}

reads as:

(module <some-file-name> "my-lang-bindings.rkt"

  (#%module-begin

    (#%linea-line finwe feanor fingolfin finarfin)

    (#%linea-line beren (and) luthien tinuviel)

    (#%linea-s-exp (huon (vs) werewold-sauron))

    (#%linea-line

     manwe

     orome

     (#%linea-expressions-begin

      (#%linea-line varda yavanna)

      (#%linea-line aule (mandos

                          nienna

                          (#%hash-braces

                           (#%linea-expressions-begin

                            (#%linea-line ulmo tulkas)))))

      (#%linea-line melkor)))))

3 Linea Reference

3.1 linea/default

TODO: #%hash-braces

Simply a rename-transformer for begin.

syntax

(#%linea-line starter e ...)

If starter is a line-macro?, then it acts as #’(starter e ...). If starter is not a line-macro?, then the current default (as set by with-default-line-macro) is inserted in place of #%linea-line.

syntax

(#%linea-s-exp e)

This is just a pass-through – (#%linea-s-exp foo) simply turns into foo.

3.2 linea/line-macro

syntax

(define-line-macro name transformer)

Defines name to be a line-macro? with transformer as its syntax transformer. Note that identifiers defined by define-line-macro can be used both as line-macros and normal macros and behave the same either way.

;; in a language like Rash that uses the Linea reader...
(define-line-macro basic-app
  (syntax-parser [(_ e ...) #'(#%app e ...)]))
basic-app println "hello world"

line-macro

(with-default-line-macro new-default-line-macro body ...)

Executes the bodies with new-default-line-macro as the default line-macro.

(with-default-line-macro basic-app {
  displayln "Oh hi"
  displayln "what's up?"
})
 
;; or
with-default-line-macro basic-app {
  displayln "Oh hi"
  displayln "what's up?"
}

line-macro

(splicing-with-default-line-macro new-default-line-macro body ...)

Like with-default-line-macro, only the bodies are spliced into the surrounding context as with splicing-syntax-parameterize.

3.3 linea/line-macro-prop

TODO: prop:line-macro line-macro?

3.4 #lang linea

Like #lang s-exp, you can use #lang linea to read the linea notation.

mylank.rkt:
#lang racket/base
(require linea/defaults linea/line-macro
         (for-syntax racket/base syntax/parse))
 
(define-line-macro print-quoted-list
  (syntax-parser
    [(_ e ...) #'(println '(e ...))]))
 
(provide (all-from-out linea/defaults
                       linea/line-macro
                       racket/base)
         print-quoted-list)

use-mylang.rkt
#lang linea "mylang.rkt"
 
;; prints '(a b c)
print-quoted-list a b c
with-default-line-macro print-quoted-list {
  ;; prints '(hello world)
  hello world
}
 

3.5 linea/read

TODO:

linea-read-syntax

linea-read

make-linea-read-funcs

readtable-add-linea-escape

default-linea-s-exp-readtable

default-linea-line-readtable

default-linea-line-avoid-list

current-linea-s-exp-readtable

current-linea-line-readtable

current-linea-line-avoid-list

4 Code and License

The code is available on github.

This library is licensed under the terms of the LGPL version 3, or (at your option) any later version published by the Free Software Foundation (IE LGPL3+).