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 and it’s really ugly and I wish I had chosen a better way to do this. But, you know, this is a ‘school’ project so maintainability isn’t actually a big deal.

3) I got all these problems done, but I don’t feel like I’ve come any closer to a solution to the general problem of building a lexer. I think they will talk about general solutions later, but it seems like I should have gained some sort of interesting insight by working the examples. That’s probably more my fault than the book’s, though.

Anyway. The problems were extending the lexer to allow a) comments, b) some operators, and c) floats. That’s up with some unit tests and all. Take a look if you’re interested.

Next up: a lot of reading for me – there aren’t any exercises for two sections, so it may be a little while.

This entry was posted in Dragon book. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s