Edit this page Backlinks This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Lab ====== ===== Lab-01 - Expresii regulate ===== Key insights: * more languages than regular expressions * we do not know how to write regular expressions for some languages (as a direct consequence of the above) * reg.exps. are unambiguous and FINITE language representations Objectives: * Understand what is a language and a regular expression is, and the relation between them; * Write several regular expressions for designated languages * Identify languages described by some regular expressions (e.g. ?!) Resources (tentative): * http://www.idt.mdh.se/kurser/cd5560/10_01/examination/KOMPENDIER/Regular/kompendium_eng.pdf === Exercises === **I. What is the regular expression for the following languages:** * $math[\Sigma=\{0, 1\}], $math[L=\{011\}] //Solution:// $math[E=011] \\ //Obs:// By definition the correct expression is $math[E=((01)1)], but we won't write them when not needed and we use a precedence rule to reduce the number of parantheses in regular expressions as much as possible (Kleene Star > Concatenation > Union). * $math[\Sigma=\{a, b\}], $math[L=\{a, b\}] //Solution:// $math[E=a \cup b] \\ //Obs:// By definition the correct expression is $math[E=(a \cup b)], but we can remove parentheses for the same reason as above. * $math[\Sigma=\{0, 1\}], $math[L=\{e, 0, 1, 00, 01, 10, 11, 000, ...\}] //Solution:// $math[E=(0 \cup 1)^{*}] \\ * $math[\Sigma=\{0, 1\}], $math[L=\{010010101000010, 010010101000011\}] //Solution:// $math[E=01001010100001(0 \cup 1)] \\ * $math[\Sigma=\{0, 1\}], $math[L=\{w \in \Sigma^{*} \mid w \text{ ends with } 0\}] \\ //Solution:// $math[E=(0 \cup 1)^{*}0] \\ * $math[\Sigma=\{0, 1\}], $math[L=\{w \in \Sigma^{*} \mid w=w_101 \lor w=1w_1, w_1 \in \Sigma^{*}\}] \\ //Solution:// $math[E=(0 \cup 1)^{*}01 \cup 1(0 \cup 1)] \\ * $math[\Sigma=\{x, y\}], $math[L=\{w \in \Sigma^{*} \mid \#_x(w) = 2\}] \\ //Solution:// $math[E=y^{*}xy^{*}xy^{*}] \\ //Obs:// $math[\#_x(w)] denotes number of $math[x] in $math[w]. * $math[\Sigma=\{a, b\}], $math[L=\{w \in \Sigma^{*} \mid \#_a(w) \,\vdots\, 2\}] \\ //Solution:// $math[E=(b^{*}ab^{*}ab^{*})^{*}] \\ * $math[\Sigma=\{x, y\}], $math[L=\{w \in \Sigma^{*} \mid \#_x(w) \ge 1\}] \\ //Solution:// $math[E=(x \cup y)^{*}x(x \cup y)^{*}] \\ * $math[\Sigma=\{a, b, c\}], $math[L=\{w \in \Sigma^{*} \mid \#_a(w) \ge 1 \land \#_c(w) \ge 1\}] \\ //Solution:// $math[E=((a \cup b \cup c)^{*}a(a \cup b \cup c)^{*}b(a \cup b \cup c)^{*}) \cup ((a \cup b \cup c)^{*}b(a \cup b \cup c)^{*}a(a \cup b \cup c)^{*})] \\ * $math[\Sigma=\{a, b\}], $math[L=\{w \in \Sigma^{*} \mid w \text{ does not contain } ba\}] \\ //Solution:// $math[E=a^{*}b^{*}] \\ * $math[\Sigma=\{a, b\}], $math[L=\{w \in \Sigma^{*} \mid \#_a(w) + \#_b(w) = 0\}] \\ //Solution:// $math[E=\epsilon] \\ * $math[\Sigma=\{a, b\}], $math[L=\{w \in \Sigma^{*} \mid \#_a(w) + \#_b(w) < 0\}] \\ //Solution:// $math[E=\emptyset] \\ ===== Lab x - JFlex ===== ==== Installing JFlex ==== A complete, platform-dependent set of installation instructions can be found [[http://jflex.de/installing.html| here]] ==== The structure of a flex file ==== ==== Writing a Hello World project ==== ==== Application - parsing lists ====