\section{Lexical Structure} \subsection{Constants} Constants available in \Kaya{} include integers, floating point values, strings, characters and booleans, as shown in Figure \ref{consts}. \FFIG{ \begin{tabular}{rcl} \MC{constant} & ::= & \MC{int} \\ & $\mid$ & \MC{float} \\ & $\mid$ & \MC{string} \\ & $\mid$ & \MC{bool} \\ & $\mid$ & \MC{char} \\ \\ \MC{int} & ::= & \oneplus{\MC{digit}} \\ \MC{float} & ::= & \oneplus{\MC{digit}} . \oneplus{\MC{digit}} \maybe{\MC{exp}}\\ \MC{string} & ::= & \CD{"}\zeroplus{\MC{ascii}}\CD{"} \\ \MC{char} & ::= & \CD{'}\MC{ascii}\CD{'} \\ \MC{boolean} & ::= & \CD{true} $\mid$ \CD{false} \\ \\ \MC{digit} & ::= & 0 $\mid$ 1 $\mid$ \ldots $\mid$ 9 \\ \MC{exp} & ::= & \CD{e+} \oneplus{\MC{digit}} \\ & $\mid$ & \CD{e-} \oneplus{\MC{digit}} \\ & $\mid$ & \CD{e} \oneplus{\MC{digit}} \\ \MC{ascii} & ::= & $\langle$any printable ASCII character$\rangle$ \\ & $\mid$ & $\langle$an escape sequence$\rangle$ \\ \end{tabular} } {Constants} {consts} \subsection{Variables} A variable name is any sequence of characters (other than a reserved word, see section \ref{reserved}) beginning with a letter or underscore, and containing only letters, underscores, digits or apostrophes. In the BNF, we refer to variable names as \MC{identifier}. Names which must begin with an upper case letter are referred to as \MC{uc\_identifier}. Names which must begin with a lower case letter are referred to as \MC{lc\_identifier}. \subsection{Operators} The following tokens are operators: \begin{tabular}{ccccccc} \CD{+} & \CD{-} & \CD{*} & \CD{/} & \CD{\%} & \CD{**} & \CD{!} \\ \CD{++} & \CD{--} & \CD{+=} & \CD{-=} & \CD{*=} & \CD{/=} \\ \CD{==} & \CD{!=} & \CD{<} & \CD{>} & \CD{<=} & \CD{>=} \\ \CD{\&} & \CD{|} & \CD{\^} & \CD{\&\&} & \CD{||} & \CD{<<} & \CD{>>} \\ \end{tabular} \subsection{Reserved Words} \label{reserved} The lexical analyser recognises the following as reserved words, and hence they cannot be used as type or variable names: \CD{Bool}, \CD{Char}, \CD{Exception}, \CD{File}, \CD{Float}, \CD{Int}, \CD{Ptr}, \CD{String}, \CD{Void}, \CD{abstract}, \CD{break}, \CD{case}, \CD{catch}, \CD{data}, \CD{default}, \CD{do}, \CD{else}, \CD{end}, \CD{false}, \CD{finally}, \CD{fnid}, \CD{foreign}, \CD{for}, \CD{globals}, \CD{if}, \CD{import}, \CD{include}, \CD{in}, \CD{lambda}, \CD{module}, \CD{of}, \CD{pass}, \CD{pure}, \CD{private}, \CD{public}, \CD{repeat}, \CD{return}, \CD{size}, \CD{throw}, \CD{trace}, \CD{true}, \CD{try}, \CD{type}, \CD{var}, \CD{while}. \subsection{Delimiters} The following tokens are used as delimiters: \begin{tabular}{ccccccc} \CD{\{} & \CD{\}} & \CD{(} & \CD{)} & \CD{[} & \CD{]} \\ \CD{.} & \CD{=} & \CD{,} & \CD{|} & \CD{;} & \CD{`} & \CD{->} \\ \end{tabular} \subsection{Comments} A single line comment is introduced with \CD{//}, and continues to the end of a line, e.g.: \begin{verbatim} pi = 3.0; // unreasonable approximation \end{verbatim} A multi line comment is introduced with \CD{/*} and continues until \CD{*/}, e.g.: \begin{verbatim} /* We should probably use something more accurate than this, but I can't remember any more decimal places */ pi = 3.14; \end{verbatim} \subsection{Directives} Directives (special instructions to the compiler) are prefixed with a \CD{\%} sign. These may be implementation dependent; those required by all implementations are: \CD{imported}, \CD{include}, \CD{link}, \CD{VM}. \noindent An implementation is free to introduce others as required.