Purchase Solution

Compiler Construct Projects

Not what you're looking for?

Ask Custom Question

Compiler Construct
In the first part of the project, you need implement a simple lexical analyzer using C++

1. Input is a text file with source code in it.
2. Space, tab, new line and comment (/* .... */) should be ignored by the lexical analyzer
3. The lexical analyzer should be able to identify
a) Integer literals, e.g. 34
b) Following keywords: for, while, do, if, else, public, private
c) Any user defined name, e.g. balance, a, b
d) Other single character punctuation, symbols, e.g. %, +, =, ; and so on
e) Special multi-character symbols, including ==, <=, >= (only these three)

4. In the program, tokens for all the key words and user defined names need to be stored in a simple table. No matter how many times one key word or user defined name appear in the code, its token should appear only once in the table

5. Token object structure and display format
Integer Literal Keywords User defined Name Single character symbol Multi-character symbol
Object Contents
tag (integer) 256 257 258 ASCII 259, 260, 261 for ==, <=, >= respectively
v (integer) Numeric value N/A NA NA NA
s (String) NA Keyword string Name string NA NA
Display Format
Display format <num,34> <keyword, "if"> <id, "balance"> <+> <==>

5. Output to screen:
a) List the tokens in the table
b) Display the token sequence derived from the input file on the screen following the format in the table above.

Purchase this Solution

Solution Summary

The expert examines compiler construct projects.

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

C# variables and classes

This quiz contains questions about C# classes and variables.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.