\section{Program Structure} A program consists of the header followed by a list of bindings. \fragment{ \BNF{ \Rule{\MC{program}}{\MC{intro} \oneplus{\MC{binding}}} \Rule{\MC{intro}}{\CD{module} \MC{identifier}} \Or{\MC{identifier} \MC{identifier}} \Or{\MC{shebang}} } } The header is either a module declaration, giving the module name, a program declaration, or a \CD{\#!} path. \begin{itemize} \item If a module declaration, it will be compiled as a module, generating a \texttt{.o} file containing code and a \texttt{.ki} file containing interface details. \item If a program declaration, the first identifier gives the name of the file containing startup code (this is often one of \CD{program}, \CD{cgi} or \CD{webapp}), the second gives the root name of the output file. See section \ref{sect:progtype}. \item If a \texttt{\#!} path, the file is assumed to be a \CD{program} and will be executed immediately after compilation --- this allows \Kaya{} to be used for scripting. \end{itemize} Bindings contain the body of the program. They may be used to import other modules; they may be functions, data declarations (already seen in section \ref{usertypes}, global variable declarations or foreign function declarations. They may also contain compiler directives. \fragment{ \BNF{ \Rule{\MC{binding}}{\MC{import}} \Or{\MC{function}} \Or{\MC{data\_decl}} \Or{\MC{global\_block}} \Or{\MC{foreign\_block}} \Or{\MC{directive}} } }