Archive for the ‘cpsc423’ Category

Final Exam Date

Saturday, May 21st, 2005

Right you are — the date on the syllabus page was wrong, but the outline was correct. The final exam is definitely next Friday, and I’ve updated the pages to match.

Outline updated

Saturday, May 14th, 2005

I’ve updated the Class Outline to show the reading for the material that we covered last week: Sections 6.1, 6.6, and 6.7.

Parser Test Programs

Saturday, May 7th, 2005

The programs I used to test Assignment 2 have been posted here.

Windows executable for 3AC Interpreter

Monday, May 2nd, 2005

Click here for a standalone version of the 3AC interpreter.

3AC Interpreter

Monday, May 2nd, 2005

I’ve posted a virtual machine written in Python that will execute the 3AC for Assignment 3. You can download a copy fo the 3AC factorial program here. Make sure that you have Python installed, then type

$ python 3vm.py factorial.3ac

You’ll see a trace of memory accesses and the output of the program.

(Note: now that I’ve actually been able to run the program, I’ve updated the original factorial program and its corresponding 3AC code, and added a HLT instruction to the 3AC definition.)

Example Parser and another Lexical Analyzer

Sunday, May 1st, 2005

If you had trouble finishing Assignment 2, you can download example.zip to start work on Assignment 3.

The parser was generated with the Coco/R compiler generator. To add semantic actions, you can either read the documentation, edit example.atg and re-generate the compiler, or you can modify the C code directly.

I chose Coco/R instead of YACC or Bison because it generates Recursive-Descent parsers instead of LALR(1) parsers. You are, of course, limited to LL(1) languges, but the resulting code is significantly easier to read and debug.

Assignment 3

Saturday, April 30th, 2005

Click here for Assignment 3 and here for the 3AC syntax.

No class tonight

Saturday, April 30th, 2005

Class is canceled tonight. I apologize for the short notice, but at least you’ll have Friday evening free. Please start reading Chapter 6 for next week, and check back here in a few hours for Assignment 3.

Example Lexical Analyzer

Tuesday, April 19th, 2005

As you finish up working on the parser, if you’re feeling shaky about your own scanner, you can grab lexer.zip.

This is a scanner generated by Flex, the GNU Fast Lexical Analyzer generator. You need the .c and .h files to compile a working program.

The file example.l is the Flex source file; you won’t need this unless you want to change the scanner. The file lex.yy.c was generated with the command flex -l example.l.

Take a look at main.c to see how the lexical analyzer works. Call yylex() to get the next token. The value returned by yylex() will be one of the token types defined in y.tab.h. When yylex() finishes, the variable yytext will contain the corresponding lexeme.

For Windows people

Thursday, April 14th, 2005

I used py2exe to generate Windows executable that you can run without installing a Python interpreter. Download generate.zip and unzip it, then run generate.exe. If this doesn’t work (and it may not — I haven’t written a Python program for Windows in nearly five years), go over to ActiveState and download ActivePython.