April 2009 Entries

Slides and Code for Lexical Analysis Talk
Last evening, I presented my “Inside Lexical Analysis” talk to the Twin Cities Languages User Group (TCLUG). I have posted both the slide deck and code samples that used during the talk; feel free to grab a copy if you wish. If you have any questions or comments about the material, feel free to get in touch with me and let me know (you can find me on Twitter here, or leave a comment on this blog post). Many thanks to TCLUG coordinator (and friend and colleague) Jason Bock for arranging the event ......

Posted On Friday, April 10, 2009 7:42 AM | Comments (5)

Expression Evaluation Coming to MGrammar?
Consider the following simple calculator authored in yacc: %{ #include <stdio.h> int yylex(void); void yyerror(char *); %} %token INTEGER %% program: program expr '\n' { printf("%d\n", $2); } | ; expr: INTEGER | expr '+' expr { $$ = $1 + $3; } | expr '-' expr { $$ = $1 - $3; } ; %% void yyerror(char *s) { fprintf(stderr, "%s\n", s); } int main(void) { yyparse(); return 0; } A notable feature of this grammar is that the syntax definitions are augmented with C code statements that are executed ......

Posted On Wednesday, April 1, 2009 7:47 AM | Comments (3)