1 / 9

Programming Exercise #2: Syntax Analysis

Programming Exercise #2: Syntax Analysis. J. H. Wang May 10, 2011. Syntax Analysis with Yacc. Goal: Using Yacc to generate a parser for your target language Input: a Yacc source program Output: a parser for your target language. Input: Yacc Program.

xylia
Download Presentation

Programming Exercise #2: Syntax Analysis

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 #2:Syntax Analysis J. H. Wang May 10, 2011

  2. Syntax Analysis with Yacc • Goal: Using Yacc to generate a parser for your target language • Input: a Yacc source program • Output: a parser for your target language

  3. Input: Yacc 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, … • Then, write the Yacc program for the target language

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

  5. Some Parser Generators • Yacc: on UNIX/Linux(http://dinosaur.compilertools.net/) • Bison: GNU (http://www.gnu.org/software/bison/) • Bison for Windows: on GnuWin32(http://gnuwin32.sourceforge.net/packages/bison.htm) • CUP: LALR parser generator for Java(http://www2.cs.tum.edu/projects/cup/) • Antlr: recursive-descent parser generator(http://www.antlr.org/) • LLGen: an LL(1)-based parser generator(http://www.cs.vu.nl/~ceriel/LLgen.html) • …

  6. Submission • Your submission *must* include • The source code (and optionally your executable file) • Your Yacc 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 syntactical structure) • Special requirements for compilation or execution environments (ex: Yacc 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 4 persons per team) • Due: three weeks (May 31, 2011)

  8. Evaluation • Demo: You have to demo on May 31, 2011 for your test examples • Minimum requirement: your Yacc program will be used as input to Yacc, and the generated parser will be checked using your example test cases for correctness • Optional bonus depends on the complexity and originality of your target language

  9. Questions?

More Related