Monthly Archives: October 2012

JSON Pretty Printer

Just learning from a book and not getting anything working was starting to bother me, so I decided to throw together a quick JSON pretty printer. It’s just a tiny little C# project, thrown together in about 2-3 hours this … Continue reading

Posted in computer science, software | Leave a comment

Input Buffering and Regular Expressions (3.2 and 3.3)

The section on input buffering was pretty short. Basically, buffering input saves you time and is more convenient than jumping around an input stream a lot. Nothing groundbreaking. The chapter on regexes probably would be groundbreaking if you weren’t, you … Continue reading

Advertisement

Posted in computer science | Leave a comment

Lexical Analysis: The Role of the Lexical Analyzer Section 3.1

This chapter was mostly just a recap of things that were already covered about lexers. 3.1.1: Divide the following C++ program into appropriate lexemes. Which lexemes should get associated lexical values? What should those values be? float limitedSquare(x) float x; … Continue reading

Posted in computer science, Dragon book | Leave a comment

Ending Chapter 2

Section 2.7 is about symbol tables and has no exercises. Basically, the technique they talk about is, as you’re parsing the source, you move symbol tables around. So you start out with a null symbol table, and each time you … Continue reading

Posted in computer science, Dragon book | Leave a comment

Exercises from 2.6 are up

All of the exercises are up on my github. Here’s a few things I’ve discovered: 1) Don’t try to be too smart. I’m using C# so fuck it, I’m gonna use int.Parse() and stream.Peek() 2) I’m using inheritance over composition … Continue reading

Posted in Dragon book | Leave a comment

Lexical Analysis (2.6)

Lexers! I’ve sort of written lexers before, although not of this generality, so this material is mostly familiar to me. The chapter provides a simple lexer (below), in Java. Old Java (pre-generics, so, what, 1.4 or someting?). I’m doing the … Continue reading

Posted in computer science, Dragon book | Leave a comment

Unit tests!

Added a few unit tests for the program used in 2.4.1. Check it out here! I’m using the new Visual Studio 2012 Express, which is nice so far – allows me to do unit testing, at least, and I have … Continue reading

Posted in Dragon book | Leave a comment

Syntax-Directed Translation, Parsing (2.3, 2.4)

So I skipped the section 2.3 exercises. They were asking for a bunch of translation schemes that were almost identical to the ones given in the chapter, which is boring. I was thinking about just writing code for them, but … Continue reading

Posted in Dragon book | Leave a comment