_____________________________________________________________________________________


Practical exercise

In this guided practical exercise, we will approach the design of an Interpreter with basic resources to review the main concepts of a Recursive Descent Parser. To avoid dealing with a large and complicated grammar, we will restrict the domain to the typical arithmetic expression calculator. This way, we can obtain results with a reduced number of production rules. The practical exercise consists of four main exercises:
  1. A parser for very simple operations.
  2. A calculator for very simple operations (Parser + Semantic Routines).
  3. Inclusion of expressions with parentheses.
  4. Inclusion of operator precedence, and unary signs.

PR 1. Practical exercise (PDF)


Recommended programs


PR 1.1. Developing Lexical Analizers with JFLEX. (URL)

PR 1.2. Developing LALR pasers in Java (CUP). (URL)

PR 1.3. Yacc: Yet Another Compiler-Compiler. (URL)

PR 1.4. A Compact Guide to LEX and YACC. (URL)


Proposed solutions


Exercise 1

Exercise 2

Exercise 3

Exercise 4

Última modificación: lunes, 16 de mayo de 2022, 15:22