\documentstyle[11pt]{article}
\batchmode
\input{use-full-page}
\input{obey}
\input{grammar}
\renewcommand{\nonterm}[1]{{\mbox{{\sl #1}}}}
\input{math-notations}

\begin{document}
\bibliographystyle{alpha-nolc}
\noindent
~
\hfill Com S 541 --- Programming Languages 1
\hfill \today \\

\begin{center}
{\huge Grammar for Little Smalltalk}
\end{center}

The following grammar for Little Smalltalk
is adapted from the railroad charts at the back of \cite{Goldberg-Robson83}
and in Appendix 2 of \cite{Budd87}.
It uses the notation of \cite[Chapter 2]{Watt91}.

\section{Macrosyntax}

The interpreter evaluates \nonterm{Statements} from the grammar below.

\begin{grammar}
\nonterm{Method} \: \nonterm{MessagePattern}
\> \| \> \nonterm{MessagePattern} \nonterm{Statements}
\> \| \> \nonterm{MessagePattern} \nonterm{Temporaries} \nonterm{Statements}
\nonterm{MessagePattern} \: \nonterm{UnarySelector} \| \nonterm{BinarySelector} \nonterm{VariableName} \| \nonterm{KeywordVarList}
\nonterm{KeywordVarList} \: \nonterm{Keyword} \nonterm{VariableName} \| \nonterm{Keyword} \nonterm{VariableName} \nonterm{KeywordVarList}
\nonterm{Temporaries} \: | \nonterm{VariableNameList} |
\nonterm{VariableNameList} \: $\varepsilon$ \| \nonterm{VariableName} \nonterm{VariableNameList}
\nonterm{Block} \: \verb|[| \nonterm{BlockFormals} \nonterm{Statements} \verb|]|
\nonterm{BlockFormals} \: $\varepsilon$ \| \nonterm{FormalList} |
\nonterm{FormalList} \: \nonterm{Formal} \| \nonterm{Formal} \nonterm{FormalList}
\nonterm{Statements} \: $\varepsilon$ \| \verb|^| \nonterm{Expression} \| \nonterm{Expression} \| \nonterm{Expression} . \nonterm{Statements}
\nonterm{Expression} \: \nonterm{ValueExpression} \| \nonterm{AssignmentTargetList} \nonterm{ValueExpression}
\nonterm{AssignmentTargetList} \: \nonterm{VariableName} <-  \| \nonterm{AssignmentTargetList} \nonterm{VariableName} <-
\nonterm{ValueExpression} \: \nonterm{Primary} \| \nonterm{MessageExpression} \| \nonterm{CascadedMessageExpression}
\nonterm{CascadedMessageExpression} \: \nonterm{MessageExpression} ; \nonterm{CascadeContinuation}
\> \| \> \nonterm{CascadedMessageExpression} ; \nonterm{CascadeContinuation}
\nonterm{CascadeContinuation} \: \nonterm{UnarySelector}
\> \| \> \nonterm{BinarySelector} \nonterm{UnaryObjectDescription}
\> \| \> \nonterm{KeywordArguments}
\nonterm{KeywordArguments} \: \nonterm{Keyword} \nonterm{BinaryObjectDescription}
\> \| \> \nonterm{Keyword} \nonterm{BinaryObjectDescription} \nonterm{KeywordArguments}
\nonterm{MessageExpression} \: \nonterm{UnaryObjectDescription} \| \nonterm{BinaryObjectDescription} \| \nonterm{KeywordExpression}
\nonterm{KeywordExpression} \: \nonterm{BinaryObjectDescription} \nonterm{KeywordArguments}
\nonterm{BinaryObjectDescription} \: \nonterm{UnaryObjectDescription}
\> \| \> \nonterm{BinaryObjectDescription} \nonterm{BinarySelector} \nonterm{UnaryObjectDescription}
\nonterm{UnaryExpression} \: \nonterm{UnaryObjectDescription}
\> \| \> \nonterm{UnaryObjectDescription} \nonterm{UnarySelector}
\nonterm{UnaryObjectDescription} \: \nonterm{Primary} \| \nonterm{UnaryExpression}
\nonterm{Primary} \: \nonterm{VariableName} \| \nonterm{Literal} \| \nonterm{Block} \| ( \nonterm{Expression} )
\nonterm{Literal} \: \nonterm{SimpleLiteral} \| \nonterm{ArrayConstant}
\nonterm{ArrayConstant} \: \verb|#(| \nonterm{Array} )
\nonterm{Array} \: $\varepsilon$ \| \nonterm{SimpleLiteral} \| \nonterm{SimpleLiteral} \nonterm{Array} \| ( \nonterm{Array} ) \| ( \nonterm{Array} ) \nonterm{Array}
\end{grammar}

\newpage
\section{Microsyntax}

The microsyntax tells how tokens are formed, and explicitly treats
each character (i.e., the tokens of the grammar below are characters
\cite{Watt91}).

\begin{grammar}
\nonterm{Method} \: {\rm (}\nonterm{Token} \| \nonterm{Comment} \| \nonterm{Blank}{\rm )}{\rm *}
\nonterm{Token} \: \nonterm{VariableName} \| \nonterm{Literal} \| \nonterm{UnarySelector} \| \nonterm{BinarySelector} \| \nonterm{Keyword} \| \nonterm{Formal}
\> \| \> ; \| <- \| . \| \verb|^| \| \verb|#(| \| \verb|[| \| \verb|]| \| ( \| ) \| \verb+|+
\nonterm{Formal} \: :~\nonterm{VariableName}
\nonterm{Keyword} \: \nonterm{Identifier} :
\nonterm{BinarySelector} \: - \| \nonterm{SpecialCharacter} \| \nonterm{SpecialCharacter} \nonterm{SpecialCharacter}
\nonterm{UnarySelector} \: \nonterm{Identifier}
\nonterm{VariableName} \: \nonterm{Identifier}
\nonterm{SimpleLiteral} \: \nonterm{Number} \| \nonterm{SymbolConstant} \| \nonterm{CharacterConstant} \| \nonterm{String}
\nonterm{String} \: ' {\rm (}\nonterm{Character} \| ' ' \| "{\rm )}{\rm *} '
\nonterm{SymbolConstant} \: \verb|#| \nonterm{Symbol}
\nonterm{Symbol} \: \nonterm{Identifier} \| \nonterm{BinarySelector} \| \nonterm{Keyword}{\rm *}
\nonterm{Identifier} \: \nonterm{Letter} {\rm (}\nonterm{Letter} \| \nonterm{Digit}{\rm )}{\rm *}
\nonterm{CharacterConstant} \: \verb|$| \nonterm{Character}
\nonterm{Character} \:  \verb|[| \| \verb|]| \| \verb|{| \| \verb|}| \| ( \| ) \| \verb|^| \| , \| ; \| \verb|$| \| \verb!#! \| :
\> \| \nonterm{Digit} \| \nonterm{Letter} \| \nonterm{SpecialCharacter}
\nonterm{SpecialCharacter} \: + \| / \| \verb|\| \| * \| . \| \verb|~| \| \verb|<| \| \verb|>| \| = \| \verb|@| \| \verb|%| \| \verb!|! \| \verb|&| \| ? \| !
\nonterm{Letter} \: a \| b \| $\ldots$ \| z \| A \| B \| $\ldots$ \| Z
\nonterm{Number} \: \nonterm{Sign} \nonterm{Digits} \nonterm{DotDigits} \nonterm{Exponent}
\nonterm{Digits} \: \nonterm{Digit} \nonterm{Digit}{\rm *}
\nonterm{Digit} \: 0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9
\nonterm{Sign} \:  $\varepsilon$ \| -
\nonterm{DotDigits} \:  $\varepsilon$ \| . \nonterm{Digits}
\nonterm{Exponent} \:  $\varepsilon$ \| e \nonterm{Sign} \nonterm{Digits}
\nonterm{Comment} \: " {\rm (}\nonterm{Character} \| " " \| '{\rm )}{\rm *} "
\nonterm{Blank} \: {\rm ``a blank or tab character''}
\end{grammar}

\bibliography{journal-abbrevs,distrib,datatypes,languages,se,old-datatypes,etc}

\end{document}
