Sample of LSSL code

Below is a simple LSSL method for keeping items in a defined sequence. It is offered here merely to give a flavour of the language, without further explanation except to point out that that the rules defined here are not forward or backward chaining production rules, but rather event handlers triggered at significant points either by the system itself, or by the style's strategy.

;;; Method SEQ: Keep items in sequence
;;; Copyright (c) 1997 AIAI, University of Edinburgh

(a method seq "Keep items in sequence"
   ("Page grid type"        grid     nil)
   ("Sequenced item type"   item     nil)
   ("Sequencing predicate"  follows?  follows?))

;;; Initialise the minimum column when a page is started
;;; (the MIN-COLUMN slot of an item is used by GET-SPACE)
(a rule seq.start-page (for seq.grid) (at start) :(_) ->
   (set seq.entry.min-column 0))

;;; Remember the last sequenced item pasted on the page
;;; and update the minimum column
(a rule seq.remember-last (for seq.entry) (at paste) :(it gd _ _) ->
   (set gd.last-entry it)
   (set seq.entry.min-column it.x))

;;; If the last sequenced item on the page gets unpasted, forget it
(a rule seq.forget-last (for seq.entry) (at unpaste) :(it gd _ _) ->
   (if (eq? it gd.last-entry)
      (do (set gd.last-entry nil)
          (set seq.entry.min-column 0))))

;;; Align a sequenced entry following the last one on the page
(a rule seq.check (for seq.entry) (at align) :(it gd _ _) ->
   (or (not? gd.last-entry)
       (seq.follows? it gd.last-entry)))

AIAI Artificial Intelligence Applications Institute