diff -r 201c2c6d8696 -r 7ed2a25dd115 handouts/ho05.tex --- a/handouts/ho05.tex Tue Oct 28 06:01:00 2014 +0000 +++ b/handouts/ho05.tex Tue Oct 28 12:24:11 2014 +0000 @@ -1,59 +1,25 @@ \documentclass{article} -\usepackage{hyperref} -\usepackage{amssymb} -\usepackage{amsmath} -\usepackage[T1]{fontenc} -\usepackage{tikz} -\usetikzlibrary{arrows} -\usetikzlibrary{automata} -\usetikzlibrary{shapes} -\usetikzlibrary{shadows} -\usetikzlibrary{positioning} -\usetikzlibrary{calc} -\usetikzlibrary{fit} -\usetikzlibrary{backgrounds} +\usepackage{../style} \usepackage{../langs} - -\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% +\usepackage{../graphics} - -\newcommand\grid[1]{% -\begin{tikzpicture}[baseline=(char.base)] - \path[use as bounding box] - (0,0) rectangle (1em,1em); - \draw[red!50, fill=red!20] - (0,0) rectangle (1em,1em); - \node[inner sep=1pt,anchor=base west] - (char) at (0em,\gridraiseamount) {#1}; -\end{tikzpicture}} -\newcommand\gridraiseamount{0.12em} - -\makeatletter -\newcommand\Grid[1]{% - \@tfor\z:=#1\do{\grid{\z}}} -\makeatother - -\newcommand\Vspace[1][.3em]{% - \mbox{\kern.06em\vrule height.3ex}% - \vbox{\hrule width#1}% - \hbox{\vrule height.3ex}} - -\def\VS{\Vspace[0.6em]} - \begin{document} -\section*{Handout 5} +\section*{Handout 5 (Lexing)} -Whenever you want to design a new programming language or implement a compiler for an -existing language, the first task is to fix the basic ``words'' of the language. For example what are the -keywords, or reserved words, of the language, what are permitted identifiers, numbers, expressions and so -on. One convenient way to do this is, of -course, by using regular expressions. +Whenever you want to design a new programming language or +implement a compiler for an existing language, the first task +is to fix the basic ``words'' of the language. For example +what are the keywords, or reserved words, of the language, +what are permitted identifiers, numbers, expressions and so +on. One convenient way to do this is, of course, by using +regular expressions. -In this course we want to take a closer look at the -WHILE programming language. This is a simple imperative programming language consisting of arithmetic -expressions, assignments, if-statements and loops. For example the Fibonacci program can be -written in this language as follows: +In this course we want to take a closer look at the WHILE +programming language. This is a simple imperative programming +language consisting of arithmetic expressions, assignments, +if-statements and loops. For example the Fibonacci program can +be written in this language as follows: \begin{center} \mbox{\lstinputlisting[language=while]{../progs/fib.while}}