Link Search Menu Expand Document

SIMPLE-3-Statements.part.tex

% 


\begin{center}
\rule{3in}{0.4pt}
\end{center}

\begin{displaymath}
\KEY{Language} \quad \LANG{\STRING{SIMPLE}}
\end{displaymath}

\section{$\SECT{3}$ Statements}\hypertarget{SectionNumber:3}{}\label{SectionNumber:3}

\begin{align*}
  \KEY{Syntax} \quad
    \VARDEC{Block} : \SYNDEC{block}
      \ ::= \ & \
      \LEX{{\LEFTBRACE}} \ \SYN@stmts\QUERY \ \LEX{{\RIGHTBRACE}}
    \\
    \VARDEC{Stmts} : \SYNDEC{stmts}
      \ ::= \ & \
      \SYN@stmt \ \SYN@stmts\QUERY
    \\
    \VARDEC{Stmt} : \SYNDEC{stmt}
      \ ::= \ & \
      \SYN@imp@stmt \mid \SYN@vars@decl
    \\
    \VARDEC{ImpStmt} : \SYNDEC{imp-stmt}
      \ ::= \ & \
      \SYN@block \\
      \ \mid \ & \ \SYN@exp \ \LEX{{;}} \\
      \ \mid \ & \ \LEX{if} \ \LEX{{(}} \ \SYN@exp \ \LEX{{)}} \ \SYN@block \ \LEFTGROUP \LEX{else} \ \SYN@block \RIGHTGROUP\QUERY \\
      \ \mid \ & \ \LEX{while} \ \LEX{{(}} \ \SYN@exp \ \LEX{{)}} \ \SYN@block \\
      \ \mid \ & \ \LEX{for} \ \LEX{{(}} \ \SYN@stmt \ \SYN@exp \ \LEX{{;}} \ \SYN@exp \ \LEX{{)}} \ \SYN@block \\
      \ \mid \ & \ \LEX{print} \ \LEX{{(}} \ \SYN@exps \ \LEX{{)}} \ \LEX{{;}} \\
      \ \mid \ & \ \LEX{return} \ \SYN@exp\QUERY \ \LEX{{;}} \\
      \ \mid \ & \ \LEX{try} \ \SYN@block \ \LEX{catch} \ \LEX{{(}} \ \SYN@id \ \LEX{{)}} \ \SYN@block \\
      \ \mid \ & \ \LEX{throw} \ \SYN@exp \ \LEX{{;}}
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \LEFTPHRASE \
        \LEX{if} \ \LEX{{(}} \ \VAR@Exp \ \LEX{{)}} \ \VAR@Block \
      \RIGHTPHRASE : \SYN@stmt = \\&
      \LEFTPHRASE \
        \LEX{if} \ \LEX{{(}} \ \VAR{Exp} \ \LEX{{)}} \ \VAR{Block} \ \LEX{else} \ \LEX{{\LEFTBRACE}} \ \LEX{{\RIGHTBRACE}} \
      \RIGHTPHRASE
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \LEFTPHRASE \
        \LEX{for} \ \LEX{{(}} \ \VAR@Stmt \ \VAR@Exp\SUB{1} \ \LEX{{;}} \ \VAR@Exp\SUB{2} \ \LEX{{)}} \\&\quad
        \LEX{{\LEFTBRACE}} \ \VAR@Stmts \ \LEX{{\RIGHTBRACE}} \
      \RIGHTPHRASE : \SYN@stmt = \\&
      \LEFTPHRASE \
        \LEX{{\LEFTBRACE}} \ \VAR{Stmt} \\&\quad
        \LEX{while} \ \LEX{{(}} \ \VAR{Exp}\SUB{1} \ \LEX{{)}} \\&\quad
        \LEX{{\LEFTBRACE}} \ \LEX{{\LEFTBRACE}} \ \VAR{Stmts} \ \LEX{{\RIGHTBRACE}} \ \VAR{Exp}\SUB{2} \ \LEX{{;}} \ \LEX{{\RIGHTBRACE}} \\&\quad
        \LEX{{\RIGHTBRACE}} \
      \RIGHTPHRASE
\end{align*}
\begin{align*}
  \KEY{Semantics} \quad
  & \SEMDEC{exec} \LEFTPHRASE \ \_ : \SYN@stmts \ \RIGHTPHRASE  
    :  \TO \FUN@null@type 
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \SEMREF{exec} \LEFTPHRASE \
                            \LEX{{\LEFTBRACE}} \ \LEX{{\RIGHTBRACE}} \
                          \RIGHTPHRASE  = 
      \FUN@null
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \SEMREF{exec} \LEFTPHRASE \
                            \LEX{{\LEFTBRACE}} \ \VAR@Stmts \ \LEX{{\RIGHTBRACE}} \
                          \RIGHTPHRASE  = 
      \SEM@exec \LEFTPHRASE \
                \VAR{Stmts} \
              \RIGHTPHRASE 
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \SEMREF{exec} \LEFTPHRASE \
                            \VAR@ImpStmt \ \VAR@Stmts \
                          \RIGHTPHRASE  = \\&\quad
      \FUN@sequential
        (  \SEM@exec \LEFTPHRASE \
                        \VAR{ImpStmt} \
                      \RIGHTPHRASE , 
               \SEM@exec \LEFTPHRASE \
                        \VAR{Stmts} \
                      \RIGHTPHRASE  )
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \SEMREF{exec} \LEFTPHRASE \
                            \VAR@VarsDecl \ \VAR@Stmts \
                          \RIGHTPHRASE  = \\&\quad
      \FUN@scope
        (  \SEM@declare \LEFTPHRASE \
                        \VAR{VarsDecl} \
                      \RIGHTPHRASE , 
               \SEM@exec \LEFTPHRASE \
                        \VAR{Stmts} \
                      \RIGHTPHRASE  )
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \SEMREF{exec} \LEFTPHRASE \
                            \VAR@VarsDecl \
                          \RIGHTPHRASE  = 
      \FUN@effect
        (  \SEM@declare \LEFTPHRASE \
                        \VAR{VarsDecl} \
                      \RIGHTPHRASE  )
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \SEMREF{exec} \LEFTPHRASE \
                            \VAR@Exp \ \LEX{{;}} \
                          \RIGHTPHRASE  = 
      \FUN@effect
        (  \SEM@rval \LEFTPHRASE \
                        \VAR{Exp} \
                      \RIGHTPHRASE  )
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \SEMREF{exec} \LEFTPHRASE \
                            \LEX{if} \ \LEX{{(}} \ \VAR@Exp \ \LEX{{)}} \ \VAR@Block\SUB{1} \ \LEX{else} \ \VAR@Block\SUB{2} \
                          \RIGHTPHRASE  = \\&\quad
      \FUN@if@else
        (  \SEM@rval \LEFTPHRASE \
                        \VAR{Exp} \
                      \RIGHTPHRASE , 
               \SEM@exec \LEFTPHRASE \
                        \VAR{Block}\SUB{1} \
                      \RIGHTPHRASE , 
               \SEM@exec \LEFTPHRASE \
                        \VAR{Block}\SUB{2} \
                      \RIGHTPHRASE  )
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \SEMREF{exec} \LEFTPHRASE \
                            \LEX{while} \ \LEX{{(}} \ \VAR@Exp \ \LEX{{)}} \ \VAR@Block \
                          \RIGHTPHRASE  = 
      \FUN@while
        (  \SEM@rval \LEFTPHRASE \
                        \VAR{Exp} \
                      \RIGHTPHRASE , 
               \SEM@exec \LEFTPHRASE \
                        \VAR{Block} \
                      \RIGHTPHRASE  )
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \SEMREF{exec} \LEFTPHRASE \
                            \LEX{print} \ \LEX{{(}} \ \VAR@Exps \ \LEX{{)}} \ \LEX{{;}} \
                          \RIGHTPHRASE  = 
      \FUN@print
        (  \SEM@rvals \LEFTPHRASE \
                        \VAR{Exps} \
                      \RIGHTPHRASE  )
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \SEMREF{exec} \LEFTPHRASE \
                            \LEX{return} \ \VAR@Exp \ \LEX{{;}} \
                          \RIGHTPHRASE  = 
      \FUN@return
        (  \SEM@rval \LEFTPHRASE \
                        \VAR{Exp} \
                      \RIGHTPHRASE  )
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \SEMREF{exec} \LEFTPHRASE \
                            \LEX{return} \ \LEX{{;}} \
                          \RIGHTPHRASE  = 
      \FUN@return
        (  \FUN@null )
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \SEMREF{exec} \LEFTPHRASE \
                            \LEX{try} \ \VAR@Block\SUB{1} \ \LEX{catch} \ \LEX{{(}} \ \VAR@Id \ \LEX{{)}} \ \VAR@Block\SUB{2} \
                          \RIGHTPHRASE  = \\&\quad
      \FUN@handle@thrown
        ( \\&\quad\quad \SEM@exec \LEFTPHRASE \
                        \VAR{Block}\SUB{1} \
                      \RIGHTPHRASE , \\&\quad\quad
               \FUN@scope
                ( \\&\quad\quad\quad \FUN@bind
                        (  \SEM@id \LEFTPHRASE \
                                        \VAR{Id} \
                                      \RIGHTPHRASE , 
                               \FUN@allocate@initialised@variable
                                (  \FUN@values, 
                                       \FUN@given ) ), \\&\quad\quad\quad
                       \SEM@exec \LEFTPHRASE \
                                \VAR{Block}\SUB{2} \
                              \RIGHTPHRASE  ) )
\end{align*}
\begin{align*}
  \KEY{Rule} \quad
    & \SEMREF{exec} \LEFTPHRASE \
                            \LEX{throw} \ \VAR@Exp \ \LEX{{;}} \
                          \RIGHTPHRASE  = 
      \FUN@throw
        (  \SEM@rval \LEFTPHRASE \
                        \VAR{Exp} \
                      \RIGHTPHRASE  )
\end{align*}
%