Please Reload Every
Time You Read This Page!
CSC 124/258: Compiler Construction, Spring 2014
Dr. Chuck C. Liang
Professor of Computer Science,
Hofstra University .
201A Adams Hall
Hempstead, NY 11550
Office Phone: (516 463) 5559
(<- click to send me mail)
Official Office Hours: Monday-Thursday 3:30-4:30pm
The homepage of the previous time that I taught this course is available here
The following are the components of my "jBASIC" sample interpreter. Although
it is an interpreter as opposed to a compiler, it contains many of the
same basic components as a compiler.
- jbl.flex. The lexical scanner specification
to be processed by JFLex, for use with my own parser generator. Here's the one to use with Java Cup.
- jb.grammar. The grammar specification used
by my own LR(1) parser generator. Here is the same grammar in Java Cup syntax (version .10k). The "semantic actions" of this file builds an
abstract syntax tree, defined in
the next file:
- jbclasses.java. This file contains
classes for building abstract syntax trees for jBasic, as well as code that
will execute a jBasic program given its abstract syntax representation.
- jbrun.java. This is the top level
file that combines the lexer/parser with the interpreter defined in the
above file. If you wish to run it before having completed your own
parser generator, you should use the version
for java cup.
- factorial.jb. Here is a sample jBasic
program that computes 5!.
- README. Instructions on how to put
everything together and run the interpreter (using Java cup).
Lambdascript example: programming with pure lambda terms using Krivine's
LR(1) grammar and
Some sample grammars (in my syntax):
- simple LR(0) grammar
- slightly more interesting LR(0) grammar
- Ambiguous grammar with reduce-reduce conflict,
- Grammar for testing Nullible, First and Follow set computations
- Ambiguous grammar for online calculator.
Must read the attached comments.
- Unambiguous SLR(1) grammar for online calculator. Here is the generated parser
- LALR(1) but not SLR(1) grammar from the Dragon book
- LR(1) but not LALR(1) grammar from the Dragon book
- Hacked parser to recognize non-context free language using semantic checks. Read the comments.
- Java 1.4 grammar (converted from .cup version). This is the torture test of your parser generator.
The Truth Lab. (progressive assignment - reload for latest).
Some guidelines, code fragments, are found here.
Parser Generator Stage 1. The content of this assignment will be the subject of your next progress grade. I've added my version of the function to compute the Nuillible set. Reload for latest
Parser Generator Stage 2: Generating the State
Parser Generator Stage 3: Generating the Parser.
Parser Generator Final.
Visitor Pattern Warmup Assignment (Optional).
MiniJava+ compiler project overview
Lexer and Parser. Due Thursday 3/27
The final grade for the parser generator will be given Thursday 3/13.
Missing class cannot be used as an excuse.
Nasty grammars for testing stage 2: nasty1,
Read Chapter 2,3,4 of textbook.