Archive for the ‘cpsc423’ Category

Test Generator

Thursday, April 14th, 2005

If you want to torture-test your parser, download this Test Generator written in Python.

While the code is a little complicated by the need to keep track of declared variables and indentation, really all it does is use the grammar the way Chomsky intended, in “reverse”, to generate new programs.

Note too that while the programs are syntactically correct and obey the rules that I set down in the assignment for the use of identifiers, they’re completely meaningless.

I give up

Thursday, April 14th, 2005

I’ve updated the examples yet again. Sigh.

Yet another syntax error

Wednesday, April 13th, 2005

Turns out that the WHILE loop in the factorial example program is missing parentheses:

WHILE i < 9 OR i = 9 DO

should be

WHILE (i < 9) OR (i = 9) DO

You’re only allowed to leave off the parentheses if there’s a single expression (as in the fibonacci program). What can I can say? Writing programs without a parser to check them isn’t easy.

Using Context-Free Grammars for Evil

Tuesday, April 12th, 2005

Oh dear. You realize that you can use CFGs to generate text, and not just to parse it, right?

Behold SCIgen - An Automatic CS Paper Generator

Disclaimer: if you try submitting one of these to a class and you get caught, don’t blame me.

Syntax Error

Friday, April 8th, 2005

Ok, so how long were you going to wait before telling me that one of the example programs had a syntax error?!?

Assignment 2

Saturday, March 19th, 2005

The official version of Assignment 2 is available. Surprise: it’s a parser.

There are also some minor semantic checks, preparatory to generating intermediate code in Assignment 3. Note that if we define the relational operators to return type INTEGER instead of a Boolean type (regarding 0 as false and non-zero as true the same way that C and C++ do), we obviate the need for type checking. You can thank me later.

Speaking of Donald Knuth…

Wednesday, March 16th, 2005

NPR’s Morning Edition ran an interview with him on Monday.

Class Outline Update

Saturday, March 12th, 2005

I’m making a slight change to the Course Outline. Skip Section 4.2 of the book. Operator-Precedence parsing is a waste of time — we’re not going to use it, and it doesn’t make make it any easier to understand LR Parsing. For that matter, skip directly to Section 4.3. Once you feel comfortable with LR Parsing, come back to Section 4.1 — at that point it should make sense.

Programming Assignment Submission

Friday, March 11th, 2005

When you submit your assignment, I want both electronic and hard copies. To submit an electronic copy, either give me a floppy disk with the source code, or e-mail it to me. I will give you your diskette back. Do not include executable files, especially in e-mail.

The deadline for assignments is the end of class on the due date. By that time, you should have submitted either a printed or electronic copy. I would prefer that you submit both prior to the deadline, but as long as I have one by that time, you’ll be ok. If you have not submitted at least one copy of your program to me by the deadline, you will not receive credit for the assignment. I do not accept late assignments.

Missing Course Notes

Tuesday, March 1st, 2005

If you picked up my course notes after class Friday night, please e-mail me or drop them off in the Department office.