程序代写代做代考 flex Tutorial Week 3

Tutorial Week 3

Introduction. In this week’s tutorial we continue with lexical analysis. If you have not finished last week’s tutorial exercises, I suggest you try and finish them too. In particular I recommend that you understand last week’s Task 3 really well, since ASTs play a key role in compilation.
Task 1. Give a complete lexical specification of (simple) email addresses such as martin@sussex.ac.uk or barak@whitehouse.gov.us. Note that the notion of syntactically valid email address on the real internet is quite complicated. No need to be perfectly faithful to reality here. Just specify something reasonable.
Task 2. Implement a lexer that accepts the language [a-z][a-zA-Z]* (where the alphabet is all ASCII characters) using the table-driven approach from the lectures. You should implement a method scan that takes as input a string and returns a boolean. The returned boolean should be true exactly when the input string is in the language [a-z][a-zA-Z]*.
Task 3. Modify your code from Task 2 so it accepts the language [a-z][a-zA-Z]* | Hello | Heavy | hello4.
Task 4. Install the JFlex and CUPS tool on your machine if they are not already installed. JFlex is a lexer generator, and CUPS a parser generator. We will use them in later tutorials.