diff --git a/info/exercises/Makefile b/info/exercises/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..47f52641ac6fe074292f38a574019220aa4e2a2f --- /dev/null +++ b/info/exercises/Makefile @@ -0,0 +1,26 @@ +.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 diff --git a/info/exercises/ex-01-sol.pdf b/info/exercises/ex-01-sol.pdf index b680dafd501b95c33f97f246d2683588579c01fc..e272c57ea28219fcdf5bd2b32e2dcde0057d408f 100644 Binary files a/info/exercises/ex-01-sol.pdf and b/info/exercises/ex-01-sol.pdf differ diff --git a/info/exercises/ex-01.pdf b/info/exercises/ex-01.pdf index 0f5211a454b97081ddc1819637e393e7c88e3b34..66648029c286b7711553bb60c056a1192a59fa97 100644 Binary files a/info/exercises/ex-01.pdf and b/info/exercises/ex-01.pdf differ diff --git a/info/exercises/src/ex-01/ex/dfa.tex b/info/exercises/src/ex-01/ex/dfa.tex index 38b2ca6be2907b00f1013fab01dbe046390451f9..42f5d96087f7b3c131f65881bd5e6d6de7496928 100644 --- a/info/exercises/src/ex-01/ex/dfa.tex +++ b/info/exercises/src/ex-01/ex/dfa.tex @@ -211,8 +211,9 @@ \item As generalized regular expression (with complement): \((\Sigma^* aa - \Sigma^*)^c\). Without complement: \((b^*(ab^*)^*)^*\). This is the language - of words that contain no consecutive pair of \(a\)'s. In set-notation: + \Sigma^*)^c\). Without complement: \(b^*(ab^+)^*(a \mid \epsilon)\). + This is the language of words that contain no consecutive pair of + \(a\)'s. In set-notation: \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)\} \end{equation*} diff --git a/info/exercises/src/ex-01/ex/lexer.tex b/info/exercises/src/ex-01/ex/lexer.tex index cf5ece986bf7fec1c84a400f2bbe4e959f495b04..935d80edf48120ad2199dab881d509fdf05a56dc 100644 --- a/info/exercises/src/ex-01/ex/lexer.tex +++ b/info/exercises/src/ex-01/ex/lexer.tex @@ -125,8 +125,8 @@ lexer drops any \texttt{skip} tokens. \begin{solution} \begin{enumerate} - \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"), id("x"), equal("="), number("5"), keyword("in"), id("x"), op("+"), number("3")]} + \item \texttt{[keyword("let"), number("5"), id("x2")]} \item \texttt{[id("xin")]} \item \texttt{[comp("=="), op(">")]} \item \texttt{[comp("<="), comp("=="), op(">"), comp("<="), equal("=")]} @@ -144,10 +144,9 @@ lexer drops any \texttt{skip} tokens. There are many possible solutions. The key is to notice which tokens have overlapping prefixes. - An example is \texttt{letx1in}, which would be lexed as - \texttt{[keyword("let"), id("x1"), keyword("in")]} if we check acceptance in - order of priority, but as \texttt{[id("letx1in")]} if we run them in - parallel. + An example is \texttt{letx1}, which would be lexed as + \texttt{[keyword("let"), id("x1")]} if we check acceptance in order of + priority, but as \texttt{[id("letx1")]} if we run them in parallel. \end{solution} \end{exercise} diff --git a/info/exercises/src/ex-01/main.tex b/info/exercises/src/ex-01/main.tex index cf01061a8e13b4bbb443c8b377e0645efa6161f3..91823ae273abe47003d4810271efa1caa62bf502 100644 --- a/info/exercises/src/ex-01/main.tex +++ b/info/exercises/src/ex-01/main.tex @@ -2,7 +2,11 @@ \input{../macro} -% \printanswers +\ifdefined\ANSWERS + \if\ANSWERS1 + \printanswers + \fi +\fi \title{CS 320 \\ Computer Language Processing\\Exercises: Weeks 1 and 2} \author{}