|
2 | 2 | \usepackage[backend=biber,sorting=none]{biblatex} |
3 | 3 | \usepackage{tikz} |
4 | 4 | \usepackage{tikz-uml} |
| 5 | +\usetikzlibrary{automata} |
5 | 6 |
|
6 | 7 | \tikzumlset{ |
7 | 8 | fill component=yellow!0 |
@@ -98,9 +99,9 @@ \subsubsection{Representation of Numbers}\label{sec:grammar-numbers} |
98 | 99 | \subsubsection{Identifiers and Variables}\label{sec:grammar-id} |
99 | 100 |
|
100 | 101 | A preliminary grammar to represents variables' identifiers is here presented. |
101 | | -The IMP language recognizes alphanumeric identifiers that start with a lower |
102 | | -case letter. The recognized letters are the letters from ``a'' to ``z'', both |
103 | | -in upper and lower case. |
| 102 | +This implementation of the IMP language recognizes alphanumeric identifiers |
| 103 | +that start either with a lower or upper case letter. The recognized letters are |
| 104 | +the letters from ``a'' to ``z'', both in upper and lower case. |
104 | 105 |
|
105 | 106 | \begin{grammar} |
106 | 107 | <identifier> ::= <upper> <alphanum> |
@@ -201,9 +202,24 @@ \section{Additions to the Syntax Given During Lectures}\label{sec:additions} |
201 | 202 | code. Comments start with an hash (``\texttt{\#}'') and span for the |
202 | 203 | entire lines. This is a behaviour inspired by commonly used programming |
203 | 204 | languages like the POSIX Shell Command Language \cite{shell-syntax} or |
204 | | - Python \cite{python-syntax}. |
| 205 | + Python \cite{python-syntax}.The finite state automaton used to |
| 206 | + recognized the comments is shown in \autoref{fig:comment-automaton}. |
205 | 207 | \end{itemize} |
206 | 208 |
|
| 209 | +\begin{figure}[H] |
| 210 | + \centering |
| 211 | + \begin{tikzpicture}[node distance=3cm,->,>=stealth'] |
| 212 | + \node[state, initial] (q0) {$q_0$}; |
| 213 | + \node[state, accepting, right of=q0] (q1) {$q_1$}; |
| 214 | +
|
| 215 | + \draw (q0) edge[loop above] node{$\ast - \texttt{"a"}$} (q0) |
| 216 | + (q0) edge[above] node{\texttt{\#}} (q1) |
| 217 | + (q1) edge[loop above] node{$\ast$} (q1); |
| 218 | + \end{tikzpicture} |
| 219 | + \caption[Finite state automaton to recognize comments]{Finite state automaton to recognize comments. The $\ast$ symbol denotes all characters. The notation $\ast - \texttt{"a"}$ denotes all characters except ``a''.} |
| 220 | + \label{fig:comment-automaton} |
| 221 | +\end{figure} |
| 222 | +
|
207 | 223 | \chapter{Design} |
208 | 224 |
|
209 | 225 | The SIMPLI interpreter was defined by following a strategy that is similar to |
|
0 commit comments