/var/spool/weblog | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Geek News del.icio.us bookmarks RSS |
Sat, May 21, 2005
Final Exam Date
/var/spool/courses/csuf/2005/spring/cpsc423 # Fri, May 13, 2005
Outline updated
/var/spool/courses/csuf/2005/spring/cpsc423 # Sat, May 07, 2005
Parser Test Programs
/var/spool/courses/csuf/2005/spring/cpsc423 # Mon, May 02, 2005
Windows executable for 3AC Interpreter
/var/spool/courses/csuf/2005/spring/cpsc423 # Sun, May 01, 2005
3AC Interpreter
$ python 3vm.py factorial.3acYou'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.) /var/spool/courses/csuf/2005/spring/cpsc423 #
Example Parser and another Lexical Analyzer
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. /var/spool/courses/csuf/2005/spring/cpsc423 # Fri, Apr 29, 2005
Assignment 3
/var/spool/courses/csuf/2005/spring/cpsc423 #
No class tonight
/var/spool/courses/csuf/2005/spring/cpsc423 # Tue, Apr 19, 2005
Example Lexical Analyzer
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. /var/spool/courses/csuf/2005/spring/cpsc423 # Wed, Apr 13, 2005
For Windows people
/var/spool/courses/csuf/2005/spring/cpsc423 #
Test Generator
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. /var/spool/courses/csuf/2005/spring/cpsc423 #
I give up
/var/spool/courses/csuf/2005/spring/cpsc423 #
Yet another syntax error
should beWHILE 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.WHILE (i < 9) OR (i = 9) DO /var/spool/courses/csuf/2005/spring/cpsc423 # Tue, Apr 12, 2005
Using Context-Free Grammars for Evil
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. /var/spool/courses/csuf/2005/spring/cpsc423 # Fri, Apr 08, 2005
Syntax Error
/var/spool/courses/csuf/2005/spring/cpsc423 # Fri, Mar 18, 2005
Assignment 2
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. /var/spool/courses/csuf/2005/spring/cpsc423 # Wed, Mar 16, 2005
Speaking of Donald Knuth...
/var/spool/courses/csuf/2005/spring/cpsc423 # Fri, Mar 11, 2005
Class Outline Update
/var/spool/courses/csuf/2005/spring/cpsc423 #
Programming Assignment Submission
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. /var/spool/courses/csuf/2005/spring/cpsc423 # Mon, Feb 28, 2005
Missing Course Notes
/var/spool/courses/csuf/2005/spring/cpsc423 # Mon, Feb 21, 2005
A clarification
Well, err... yes, isn't everything these days case-sensitive? (Whaddaya mean "not Visual Basic?") Yes, Pascal was case-insensitive, but subsequent languages in the Wirth family (e.g., Modula-2, Modula-3, Oberon, Component Pascal) have all been case-sensitive. I've updated the assignment to reflect that. /var/spool/courses/csuf/2005/spring/cpsc423 # Sun, Feb 20, 2005
Compiler Construction using Flex and Bison
/var/spool/courses/csuf/2005/spring/cpsc423 # Tue, Feb 15, 2005
Assignment 1
/var/spool/courses/csuf/2005/spring/cpsc423 # Fri, Feb 11, 2005
Grammar and Examples
/var/spool/courses/csuf/2005/spring/cpsc423 # Sat, Feb 05, 2005
CpSc 423, Language Processor Techniques
/var/spool/courses/csuf/2005/spring/cpsc423 # |
Topics
Archives
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||