The Tilegamer Intermediate Language (TIL) is an intermediate language which specifies the format of the .TIL files, which are the output of the Treescript Compiler and the input of the TIL Loader. The TIL Loader converts the .TIL files to an in-memory format, and the TIL Runtime executes it.
Grammar Format
The following Grammar defines the syntax of the .TIL files.
· Non-terminal symbols are written in italics, e.g. while-stmt. A non-terminal symbol is a place-holder for an entity in the Grammar which can be replaced by lower-level symbols.
· Terminal symbols appear in a monospaced font, e.g. #func. Terminal symbols are bottom-level entities in the Grammar, which cannot be replaced by any other symbols.
· Square brackets ([]) enclose something that is optional (can occur 0 or 1 times).
· Square brackets followed by an ellipsis (...) enclose something that repeats (can occur 0 or more times).
· A non-terminal symbol followed by an ellipsis indicates repetition (can occur 1 or more times).
· If a given non-terminal can be replaced by multiple expressions, each one is usually on a separate bulleted line. Otherwise, the vertical slash (|) is used to separate them.
· A backslash (\) indicates that the rest of the line is a comment.
TIL Design Specs
class-decl:
(
id
modifs \ set
imp-idx
cls-idx
( interf-ref… )
( fld-decl… )
static-blk
do-blk
( meth-decl… )
)
interf-ref:
imp-idx interf-idx
meth-decl:
(
meth-typ
func-typ | ()
modifs \ set
( parm-decl… )
( loc-decl… )
( except-typ… )
( stmt… )
id
)
meth-typ:
· #proc
· #func
· #cons
· #event-hndlr
func-typ:
(
scalar-typ
( arr-lst… )
[ imp-idx cls-idx ]
)
loc-decl:
(
value
scalar-typ
( arr-lst… )
imp-idx
cls-idx
( minval maxval ) \ int
id
[ expr ] \ loc-decl only
)
parm-decl:
loc-decl
fld-decl:
(
value
scalar-typ
( arr-lst… )
imp-idx
cls-idx
modifs \ set
property
( minval maxval ) \ int
id
[ expr ]
)
simp-typ:
· $st-byte
· $st-short
· $st-int
· $st-long
· $st-float
· $st-double
· $st-char
· $st-boolean
· $st-object
· $st-listnode
· $st-set
· $st-setlong
property:
· $rw-read
· $rw-write
· $rw-readwrite
arr-lst:
· A [ size ]
· L
scalar-typ:
simp-typ | meth-typ
meth-typ:
(
#proc-typ | #func-typ
simp-parm…
)
simp-parm:
(
simp-typ
id
[ imp-idx cls-idx ]
)
source-file:
pkg-stmt
( imp-stmt… )
pub-cls-def
[ priv-cls-def… ]
pkg-stmt:
( cls-name… )
imp-stmt:
(
imp-typ
( cls-name… )
[ cls-idx | interf-idx ]
)
imp-typ:
· $imp-class
· $imp-interf
· $imp-all
pub-cls-def:
priv-cls-def:
· class-decl
· interf-decl
interf-decl:
(
id
modifs \ set
( interf-ref… )
( fld-decl… )
( meth-hdr… )
)
meth-hdr:
(
#proc-hdr | #func-hdr
func-typ | ()
modifs \ set
( parm-decl… )
( except-typ… )
id
)
call-stmt:
· proc-ref
· colon-proc-expr
colon-proc-expr:
(
#colon-proc
obj-expr
proc-ref
)
asst-stmt:
(
asst-op
var-expr
expr
)
var-expr:
· var-ref
· arr-ref
· colon-prop-expr
static-blk:
do-blk:
(
#stat-blk | #do-blk
( loc-decl… )
block
)
colon-prop-expr:
(
#colon-prop
obj-expr
var-ref | arr-ref
)
colon-meth-expr:
(
#colon-meth
obj-expr
meth-ref
)
var-ref:
(
#var-ref
value
decl-idx
is-local
scalar-typ
id
)
obj-ref:
(
#obj-ref
value
decl-idx
is-local
imp-idx
cls-idx
id
)
meth-ref:
(
#proc-ref | #func-ref
decl-idx
scalar-typ
( [ expr ]… )
id
)
obj-expr:
· obj-ref
· func-ref
· arr-ref
· colon-prop-expr
· colon-meth-expr
func-ref:
proc-ref:
meth-ref
arr-ref:
(
#arr-ref
value
decl-idx
is-local
scalar-typ
( expr… )
id
)
expr:
· const-expr
· var-expr
· op-expr
· func-ref
· arr-ref
· obj-expr
· list-expr
const-expr:
· int-const
· float-const
· string-const
· bool-const
· nil
op-expr:
· bin-op-expr
· multi-op-expr
· unary-op-expr
· misc-expr
bin-op-expr:
(
bin-op
expr
expr
)
multi-op-expr:
(
multi-op
expr…
)
unary-op-expr:
(
unary-op
expr
)
list-expr:
(
#list-expr
expr…
)
block:
(
[ stmt… ]
)
stmt:
· if-stmt
· switch-stmt
· while-stmt
· for-stmt
· for-list-stmt
· asst-stmt
· inc-dec-stmt
· ptr-stmt
· call-stmt
· jump-stmt
· try-stmt
· throw-stmt
· synch-stmt
· resize-stmt
if-stmt:
(
$stmt-if
if-clause…
)
if-clause:
bool-expr
block
switch-stmt:
(
$stmt-switch
expr
( case-clause… )
[ block ]
)
case-clause:
(
( expr… )
block
)
while-stmt:
(
$stmt-while | $stmt-repeat
bool-expr
block
)
throw-stmt:
(
$stmt-throw
obj-ref
)
for-stmt:
(
$stmt-for
decl-idx
( init-expr limit-expr step-expr )
block
)
for-list-stmt:
(
$stmt-for-list
var-expr \ list
is-reverse
block
)
inc-dec-stmt:
(
$stmt-inc | $stmt-dec
var-expr
)
ptr-stmt:
(
$stmt-left | $stmt-right
var-expr
expr
)
jump-stmt:
· return-stmt
· $stmt-brk
· $stmt-cont
return-stmt:
(
$stmt-rtn
[ expr ]
)
try-stmt:
(
$stmt-try
block
( catch-clause… )
[ block ]
)
catch-clause:
(
decl-idx \ exception decl.
block
)
synch-stmt:
(
$stmt-sync
obj-ref
block
)
misc-expr:
· cond-expr
· cast-cls
· cast-typ
· inst-of
· new-expr
· quote-expr
cond-expr:
(
#cond-expr
bool-expr
expr
expr
)
cast-cls:
(
$bop-cast-cls
imp-idx
cls-idx
expr
)
cast-typ:
(
$bop-cast-typ
simp-typ
expr
)
inst-of:
(
$bop-inst-of
imp-idx
cls-idx
expr
)
new-expr:
(
$uop-new
imp-idx
cls-idx
[ expr… ]
)
resize-stmt:
(
$stmt-resize
colon-prop-expr | arr-ref
expr…
)
quote-expr:
(
$uop-quote
expr
)
int-const:
[ hyphen ] digit…
float-const:
F [ hyphen ] digit… [ dec ][ exp ]
string-const:
quote [ char… ] quote
bool-const:
· Y
· N
dec:
dec-pt digit…
exp:
E [ hyphen ] digit…
id:
underscore identifier
identifier:
id-start id-char…
underscore:
_
hyphen:
-
quote:
‘
dec-pt:
.
id-start:
· underscore
· letter
id-char:
· underscore
· letter
· digit
· hyphen
bin-op:
· $bop-plus
· $bop-minus
· $bop-mult
· $bop-div
· $bop-mod
· $bop-eq
· $bop-ne
· $bop-lt
· $bop-le
· $bop-ge
· $bop-gt
· $bop-and
· $bop-or
· $bop-xor
· $bop-shl
· $bop-shr
· $bop-zshr
· $bop-setun
· $bop-setdiff
· $bop-setinter
· $bop-seteq
· $bop-setne
· $bop-setinc
· $bop-setin
· $bop-concat
· $bop-lstidx
· $bop-cast-cls
· $bop-cast-typ
· $bop-inst-of
multi-op:
· $mop-plus
· $mop-mult
· $mop-and
· $mop-or
· $mop-xor
· $mop-setun
· $mop-setinter
· $mop-concat
unary-op:
· $uop-neg
· $uop-left
· $uop-right
· $uop-not
· $uop-atom
· $uop-new
· $uop-quote
asst-op:
· $asst
· $aop-plus
· $aop-minus
· $aop-mult
· $aop-div
· $aop-mod
· $aop-and
· $aop-or
· $aop-xor
· $aop-shl
· $aop-shr
· $aop-zshr
· $aop-concat
modifiers:
· $mod-pub
· $mod-prot
· $mod-priv
· $mod-fin
· $mod-stat
· $mod-ab
· $mod-sync
· $mod-trans
· $mod-vol
· $mod-auto