CS403: Programming Languages

Lexical Analyzer Module

Version 1

Printable Version

Introduction

This is your second module for your Designer Programming Language. You may develop your code using any of the allowed procedural languages, but you must ensure it runs correctly under Linux before submission.

Your task is to write a scanner for your programming language. A scanner picks through the source code of a program, identifying the individual tokens. To scan a file, it is necessary to understand lexical analysis. So start by reading this.

Specifics

Specifically, you are to write a scanner for your Designer Programming Language. You should implement, at a minimum, the following classes/modules:
Your implementation must be based upon one-character-at-a-time input (e.g. you may not use Java's string tokenizer if you are writing in Java). That is, your lex method reads a single character and then analyzes what to do with it as above. If you are the least bit confused about this requirement, see me.

One should be able to run the scanner on a file of source code by typing in the command:
    scanner <f>
where <f> stands for the name of the file to be scanned.

Additional requirements

You need to support comments in your source code. Comments are considered whitespace.

You are to supply a makefile that responds to the following targets:
Also provide four other tests which will run with the makefile targets test2, test3, test4, and test5. The fifth test (target test5) should report a lexing error; the error text should include the line number. For testing purposes, report the error on stdout.

Coding Standards

You must implement your scanner and supporting modules in C, C++, or Java.

Compiling standards:
Style:
Portability:
Miscellaneous:

Submitting the assignment

To submit your assignment, delete all object or class files from your working directory, leaving only source code, a makefile, a readme file, and any test cases you may have. Then, while in your working directory, type the command:
    submit proglan lusth lexer
The submit program will bundle up all the files in your current directory and ship them to me. This includes subdirectories as well since all the files in any subdirectories will also be shipped to me. You will receive a weak pass if you supply extraneous files (such as .o files or .class files), so be careful.

Make sure that I will be able to call your scanner with the command named scanner. The command scanner must take a filename as a command line argument.

You must supply a makefile that will compile your scanner when responding to the commands make and make run. The make command should build the executable, while the make run command should run your lexer on some test cases of your own devising. If you do not supply a makefile, you will receive a failing grade for this assignment.

You may submit as many times as you want before the deadline; new submissions replace old submissions.

You must sign your work and give credit where credit is due!