• Keine Ergebnisse gefunden

1 Shopping list (4+2)

N/A
N/A
Protected

Academic year: 2022

Aktie "1 Shopping list (4+2)"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Prof. Dr. A. Poetzsch-Heffter Dr. Annette Bieniusa Dipl.-Inf. P. Michel

TU Kaiserslautern

Fachbereich Informatik AG Softwaretechnik

Lab 1: Compiler and Language Processing Tools (SS 2013)

Deadline: 29.04.13, 23:59

1 Shopping list (4+2)

You have to scan and parse a shopping list. Each line of the shopping list contains a shopping item. Each item consists of

• the amount (number of pieces),

• a description of the product, and

• the price per piece in Euro.

They are seperated by a comma. Example:

12, eggs , 0.20

3, parcels of spaghetti , 2.00

6, bottles 7up , 0.90

2, bottles of French wine , 12.50

1. Write a scanner and a parser specification of shopping lists for the above format using JFlex and Beaver. The resulting program should take a file name as input and process the content of the file.

2. Compute the total prize for all items on a (parsed) shopping list using the parser’s action routines. Print to the price in the correct format System.out. For the above example, the total prize is 38.80.

Generate some test cases and test your implementation.

2 Calculator (2+2+2)

Implement a small calculator for arithmetic expressions, supporting addition, subtrac- tion, and multiplication on integers. The evaluation of an expression should follow the usual rules of arithmetics regarding operator precedence and associativity.

Examples:

• The expression 2 - 4 + 5 should evaluate to 3.

• The expression 2 * 4 + 3 should evaluate to 11.

1. Define and implement an abstract syntax tree (AST) for the expression language in Java.

2. Write a scanner and a parser specification for arithmetic expressions using JFlex and Beaver that constructs the AST. The resulting program should take a file name as input and process the content of the file.

(2)

3. Implement an evaluator that calculates the value of an expression by processing the AST.

Submission

• Deadline: 29.04.13, 23:59.

• Late submissions will not be accepted.

• Don’t forget to add some documentation to your code.

• Submit your solution via your group’s repository.

Referenzen

ÄHNLICHE DOKUMENTE

The following suggestions are argued to be unhelpful: (1) that Socrates’ interlocutors provide particulars instead of universals, (2) that Socrates makes an assumption that

The only valid initialization state in our blinking light example consists of an empty message buffer and an environment actor with no attached lights.. Having defined the set

The framework presented in Section 2 can be used as the basis for a schema for flexible process specification, whose central notion is the design state space with its three

The daily updating of the information on the web pages is a result of the updating of weather data and local information, which is done entirely by the individual countries..

Payment – it is incredibly easy to see something you like, pop it in your online shopping basket, make an online payment and worry about your bill later. Th is can get you

[r]

In Chapters 1 and 2, I shall remain focused on the relationship between MK and other rabbinic texts (especially the Bavli), attempting to discover what this relationship can

The thesis focuses on financing decisions in companies. The study does not cover all aspects of financing decisions, but instead concentrates on those topics that the author of