Skip to content
Snippets Groups Projects
Commit 0d08634f authored by Samuel Chassot's avatar Samuel Chassot
Browse files

Merge branch 'main' of gitlab.epfl.ch:lara/cs320

parents 7cb38ecd 8fe807e5
No related branches found
No related tags found
No related merge requests found
.PHONY = all clean
OUT_DIR ?= $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
DIRS := $(wildcard src/ex-??)
EXPDFS := $(patsubst src/ex-%,ex-%.pdf,$(DIRS))
SOLPDFS := $(patsubst src/ex-%,ex-%-sol.pdf,$(DIRS))
all: $(EXPDFS) $(SOLPDFS)
ex-%.pdf: src/ex-%/main.tex
cd src/ex-$* && \
lualatex -jobname=ex-$* "\def\ANSWERS{0}\input{main.tex}" && \
cp ex-$*.pdf $(OUT_DIR)/ex-$*.pdf
ex-%-sol.pdf: src/ex-%/main.tex
cd src/ex-$* && \
lualatex -jobname=ex-$*-sol "\def\ANSWERS{1}\input{main.tex}" && \
cp ex-$*-sol.pdf $(OUT_DIR)/ex-$*-sol.pdf
clean:
rm -f $(EXPDFS) $(SOLPDFS)
for d in $(DIRS); do \
cd $$d && rm -f *.aux *.log *.out main.pdf; \
done
No preview for this file type
No preview for this file type
...@@ -211,8 +211,9 @@ ...@@ -211,8 +211,9 @@
\item \item
As generalized regular expression (with complement): \((\Sigma^* aa As generalized regular expression (with complement): \((\Sigma^* aa
\Sigma^*)^c\). Without complement: \((b^*(ab^*)^*)^*\). This is the language \Sigma^*)^c\). Without complement: \(b^*(ab^+)^*(a \mid \epsilon)\).
of words that contain no consecutive pair of \(a\)'s. In set-notation: This is the language of words that contain no consecutive pair of
\(a\)'s. In set-notation:
\begin{equation*} \begin{equation*}
\{w \mid \forall i.\; 0 \leq i < |w| \land w_{(i)} = a \implies (i + 1 \geq |w| \lor w_{(i + 1)} \neq a)\} \{w \mid \forall i.\; 0 \leq i < |w| \land w_{(i)} = a \implies (i + 1 \geq |w| \lor w_{(i + 1)} \neq a)\}
\end{equation*} \end{equation*}
......
...@@ -125,8 +125,8 @@ lexer drops any \texttt{skip} tokens. ...@@ -125,8 +125,8 @@ lexer drops any \texttt{skip} tokens.
\begin{solution} \begin{solution}
\begin{enumerate} \begin{enumerate}
\item \texttt{[keyword("let"), id("x"), equal, number("5"), keyword("in"), id("x"), op("+"), number("3")]} \item \texttt{[keyword("let"), id("x"), equal("="), number("5"), keyword("in"), id("x"), op("+"), number("3")]}
\item \texttt{[id("let"), number("5"), id("x2")]} \item \texttt{[keyword("let"), number("5"), id("x2")]}
\item \texttt{[id("xin")]} \item \texttt{[id("xin")]}
\item \texttt{[comp("=="), op(">")]} \item \texttt{[comp("=="), op(">")]}
\item \texttt{[comp("<="), comp("=="), op(">"), comp("<="), equal("=")]} \item \texttt{[comp("<="), comp("=="), op(">"), comp("<="), equal("=")]}
...@@ -144,10 +144,9 @@ lexer drops any \texttt{skip} tokens. ...@@ -144,10 +144,9 @@ lexer drops any \texttt{skip} tokens.
There are many possible solutions. The key is to notice which tokens have There are many possible solutions. The key is to notice which tokens have
overlapping prefixes. overlapping prefixes.
An example is \texttt{letx1in}, which would be lexed as An example is \texttt{letx1}, which would be lexed as
\texttt{[keyword("let"), id("x1"), keyword("in")]} if we check acceptance in \texttt{[keyword("let"), id("x1")]} if we check acceptance in order of
order of priority, but as \texttt{[id("letx1in")]} if we run them in priority, but as \texttt{[id("letx1")]} if we run them in parallel.
parallel.
\end{solution} \end{solution}
\end{exercise} \end{exercise}
...@@ -2,7 +2,11 @@ ...@@ -2,7 +2,11 @@
\input{../macro} \input{../macro}
% \printanswers \ifdefined\ANSWERS
\if\ANSWERS1
\printanswers
\fi
\fi
\title{CS 320 \\ Computer Language Processing\\Exercises: Weeks 1 and 2} \title{CS 320 \\ Computer Language Processing\\Exercises: Weeks 1 and 2}
\author{} \author{}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment