1 / 9

Programming Exercise #1: Using Scanner Generator Lex

Programming Exercise #1: Using Scanner Generator Lex. J. H. Wang Oct. 18, 2011. Lexical Analysis with Lex. Goal: Using Lex to generate a scanner for your target language Input: a Lex program Output: a scanner for your target language. Input: Lex Program.

nerice
Download Presentation

Programming Exercise #1: Using Scanner Generator Lex

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Exercise #1:Using Scanner Generator Lex J. H. Wang Oct. 18, 2011

  2. Lexical Analysis with Lex • Goal: Using Lex to generate a scanner for your target language • Input: a Lex program • Output: a scanner for your target language

  3. Input: Lex Program • First, you have to decide a target language to be analyzed • Ex: Simple programming languages such as: Decaf, Espresso, Cool, … • http://www.stanford.edu/class/cs143/ • You can design your own language for any purpose • Music scores, games, computer graphics, matrix operations, calculators, homepages, XML subset, JSON, … • Then, write the Lex program for the target language • Define the tokens!

  4. Output: Scanner • Run Lex to generate the scanner • You are allowed to use Lex or other scanner generators • Test your scanner with some example test files written in your target language • At least one test file should be submitted

  5. Some Scanner Generators • Lex: on UNIX/Linux(http://dinosaur.compilertools.net/) • Flex: GNU (http://flex.sourceforge.net/) • JLex: for Java (http://www.cs.princeton.edu/~appel/modern/java/JLex/) • JFlex: for Java (http://jflex.de/) • Quex: for C++ (http://quex.sourceforge.net/) • …

  6. Submission • Your submission *must* include • The source code (and optionally your executable file) • Your Lex program • At least one example test files in the target language • A README file that includes • A description of your target language (at least the lexical structure) • Special requirements for compilation or execution environments (ex: Lex version, compilation instructions, …) • The names and the responsible parts for each individual member should be clearly identified

  7. How to Submit • Team-based (at most 2 persons per team) • You have to submit the programs by e-mails • Due: three weeks (Nov. 1, 2011)

  8. Evaluation • Minimum requirement: your Lex program will be used as input to Lex, and the generated scanner will be checked using your example test cases for correctness • Optional bonus depends on the complexity and originality of your target language • You might be required to demo if the program submitted was unable to run

  9. Questions or Comments?

More Related