CS152: Labs
Sun Microsystems NetBeans programming environment, online manuals and help will be installed in Engineering II Building computer labs.
Essential software includes:
The /bin directory for JDK needs to be added to the PATH, and the share needs to be added to the CLASSPATH. Since the systems people intend on moving to mandatory profiles, this will be included in the profile for all CS majors.
The tools are used with the command line. The commands:
java java_cup/Main < [input]
java JLex/Main [input]
are used to access the corresponding tools.
Lab 1
Topics:
- Introduction
- Know your tools (JDK, NetBeans, CUP, JFlex)
This class will require plenty of programming in Java; I hope most of you worked in Java before. For those who have never encountered Java, Norman Matloff's A Quick, Painless Introduction to the Java Programming Language is not a bad place to start. If need be, I can dedicate a lab and/or some extra out-of-lab time to bring everyone to the same page. Java is not a difficult language to learn, and the subset of Java that is necessary to do well in this class is largely similar to C++, albeit easier to comprehend at first and more intuitive. In my oppinion, of course.
Try out NetBeans, the IDE of choice for this class. Open the Sample Project, the Anagram Game. Examine the classes, fields, methods, etc. Build the project and run it. To check out how to start a new project, click on the Quick Start Quide, and follow instructions for the General Application.
Two other tools that will be used in this class are JFlex, a lexical analyzer (aka lexer, aka scanner) generator written in Java, and CUP, a parser generator written in Java. At this point it is too early to give elaborate demonstrations of the two progrmas, but do browse through their home pages and their manuals.
Java Documentation:
Very useful link to have in your bookmarks is Sun's Java Documentation web page. If you are using it very often (and I predict that you will), you might find it convenient to download it localy onto the machine you will be working on. A work of caution though: last time I downloaded it, once uncompressed it was about 200Mb big.
Reading:
Downloads:
All packages needed for the labs will be installed in the computer labs; however, if you wish to install it on your home machines or laptops, here are the links to the downloads:
Lab 2
Topics:
News:
The software has been installed under Linux. Paths are provided below
because there are now two versions of java on the systems (the older one
can't be removed as there are dependencies on it).
Java compiler (javac) and other executables are in the following directory:
/usr/csshare/pkgs/jdk1.5.0_05/bin
NetBeans IDE is in the following directory:
/usr/csshare/pkgs/netbeans-4.1/bin
The .jar file for CUP is in:
/usr/csshare/pkgs/jdk1.5.0_05/jre/lib/ext/java-cup-v11a.jar
The package directory for jflex is:
/usr/csshare/pkgs/jflex-1.4.1
Java Documentation has been installed to:
/usr/csshare/pkgs/jdk-1.5.0-doc/docs/index.html
Lab 3
Topics:
- Regular Expressions
- JFlex
- In depth discussion of Assignment 2.
Exercises:
- Replace the identifier definition inside the
MiniJava.fjlex skeleton file from
Assignment 2 with regular expressions
according to the identifier specification in the textbook.
- Modify the action of the identifier-reg-exp to return the actual identifier
name.
- Modify the action of the integer_literal to return the actual
integer_literal value
- Compile everything and make sure it runs correctly.
Lab 4
Topics:
Exercises:
- Download the skeleton file and the scripts off from the
Assignment 3 web page.
- Edit the skeleton file to support the grammar for MiniJava
expressions. For the in-lab assignment, your rules
should be in the lines of:
program ::= exp;
exp ::= ... | ... | ... ;
(When you write the parser for the assignment, your compiler
should be written for the whole MiniJava language, not just the
expressions).
- Generate the parser using CUP, compile it, and run it on
simple MiniJava programs, consisting only of expressions.
Lab 5
Topics:
Exercises:
- Code and test the report_error( ... )
method, which is called by the CUP generated parser to print error
messages about syntax errors.
Lab 6
Topics:
Exercises:
- No in-lab exercise this week.
Lab 7
Topics:
Exercises:
- No in-lab exercise this week. Continue to work on your projects. Your attendance is marked as your
in-lab exercise grade.
Lab 8
Topics:
Exercises:
- Code BuildSymbolTableVisitor's visit methods for any four of the Decl's
of MiniJava (i.e. MainClass, ClassDeclSimple, ClassDeclExtends, MethodDecl,
VarDecl, etc.)
Lab 9
Topics:
Exercises:
- Code TypeCheckVisitor's visit method for CallExp.
Lab 10
Topics:
Exercises:
- Code and compile visit(NewArray n)
- Code and compile visit(NewObject n)
- Code as much of the visit(Call n) as possible