The following is the syntax of Sigil. Being a dialect of Lisp, it is spartan and simple, but and effective base for builing.
Numbers - a string of digits
Example:
1 is a number
100 is a number
3.141516 is a number
-3 is a number
Symbol - a string of characters not containing ’(’, or ’)’.
Example:
x is a symbol
abc is a symbol
x123 is a symbol
123x is a symbol
a-longer-symbol is a symbol
|a symbol with spaces| is a symbol
Comments - a string of characters up to a newline that is ignored
Example:
; this is a comment
Quoting - stops evaluation
Example:
1 =>;;;; 1
`1 =>;;;; 1
x =>;;;; ; Error, undefined symbol
`x =>;;;; x
(1 2 3) =>;;;; ; Error, undefined function
`(1 2 3) =>;;;; (1 2 3)
List - build lists
Example:
`() =>;;;; (); the empty list
`(1) =>;;;; (1) ; a ’proper’ list containing the digit 1
`(1 . ()) =>;;;; (1) ; a ’proper’ list containing the digit 1
`(1 2 3) =>;;;; (1 2 3) ; is a ’proper’ list of the digits 1 2 3
`(1 2 3 . ()) =>;;;; (1 2 3) ; is a ’proper’ list of the digits 1 2 3
`(1 . 2) =>;;;; (1 . 2) ; is an ’improper’ list of the digits 1 and 2
`(x . y) =>;;;; (x . y) ; is an ’improper’ list of the symbols x and y
A proper list has () as its last element, and it is not normally shown. An improper list does not have () as it’s last element, and this is shown by preceeding the last element with a dot.
Comma - evaulate inside of a quote
Example:
(set `x 1) =>;;;; 1
x =>;;;; 1
`(x 2 3) =>;;;; (x 2 3)
`(,x 2 3) =>;;;; (1 2 3)
Commaat - evaluate a list inside of a quote, and splice it
Example:
(set `x `(a b c))
x =>;;;; (a b c)
`(x 1 2 3) =>;;;; (x 1 2 3)
`(,x 1 2 3) =>;;;; ((a b c) 1 2 3)
`(,@x 1 2 3) =>;;;; (a b c 1 2 3)
NOTE: SYMBOLS AND NUMBERS ARE ALSO KNOWN AS ATOMS.
Booleans - () is false, everything else is true
As in most languages, Sigil has the idea of booleans, true and false. In this case, the empty list, () is ’false’ and everything else is ’true’. A special symbol ’t’ is defined to represent truth when needed, but is not required to be used.
Functions that are meant to return either a true or false value are known as ’predicates’.