Reader Syntax
David Jeske edited this page May 22, 2017
·
18 revisions
Irken's syntax is nearly identical to Scheme's.
- comments
- single-line comments begin with
;
- single-line comments begin with
- symbols
- begin with a non-numeric character and can contain alphanumeric characters and the symbols *, +, !, -, _, ', and ?. colon (:) is a reserved character, it identifies variant constructors.
-
foo
,my-foo
,is-foo?
- vectors
- literals
#(1 2 3)
and postfix array-indexingx[i]
, soon will support#[1 2 3]
- literals
- records literal declaration and field access
- literal declaration
{ field0 = 10 field1 = "foo" }
, and field-accessa.field1
- literal declaration
- lists
- lists of literals may be written as quoted lists
'(1 2 3)
or the empty list'()
- lists with where expressions should be evaluated require an explicit construction
(list 1 (+ 1 1) (+ 1 1 1))
- lists of literals may be written as quoted lists
- booleans
-
#t
: true, and#f
: false
-
- null
- A zero value is written as
#\nul
- A zero value is written as
-
pattern matching
- in match expressions and pattern function definitions, use
->
- in match expressions and pattern function definitions, use
- type declarations are optional. See datatypes and function type declarations
Irken's reader implements a subset of the Scheme literals.
#u ; undefined
#t ; true
#t ; false
'hello ; symbol
"hello" ; string
"\x5e" ; string with character hexcode 5e
"\r\n\t\"\\" ; carriage return; newline; tab; ", \
542 ; integer
#x5e ; hex 0x5e in C
#o12 ; octal 012 in C
#(1 2 3) ; vector
'(1 2 3) ; quoted list
#\a ; lowercase character 'a'
#\A ; uppercase character 'A'
#\space
#\newline
#\return
#\tab
#\nul
#\eof
Next: Datatypes