Evaluate Expressions – Part 4: Evaluate the Abstract Syntax Tree

Evaluate Expressions – Part 1: The Approaches Evaluate Expressions – Part 2: Parse the Expression Evaluate Expressions – Part 3: Building the Abstract Syntax Tree Evaluate Expressions – Part 4: Evaluate the Abstract Syntax Tree So far we have managed to parse the text representing an expression and build an abstract syntax tree. The only…

Evaluating Expressions – Part 3: Building the AST

In my previous post we’ve parsed an exception verifying whether it’s correct or not syntactically. But we still have to evaluate it. To be able to do that we’ll have to build an abstract syntax tree. This can be done by modifying the previous code and inserting semantic action. That means we do something more…

Evaluating Expressions – Part 2: Parse the Expression

In my previous post I have provided some background theory for evaluating expressions with abstract syntax trees. As I was mentioning, the first step towards this goal is to parse the expression, make sure it is correct syntactically. This is what I’ll show you in this post. Having the grammar defined, we’ll make one function…

Evaluating Expressions – Part 1: The Approaches

I was discussing a few days ago about evaluating expressions and I decided to explain how you can build an evaluator. I will do this in a series of posts, getting one step more in each post. I will use C++, but the approaches are the same regardless the language. Let’s consider this expression: 1+2*3….

Arrays in F#

Yesterday I wrote about list in F#. Today I’ll write about arrays, which unlike lists are a mutable flat storage and cannot be resized. That means you have to create a new array if you want to remove or add elements. Advantages include constant look-up time and the fact that they can store a large…

Lists in F#

In this post I will talk about the lists in F#, one of the fundamental concepts of the language. What should be said from the very beginning is that list are imutable single linked list. That means whenever you change a list, a new list is created. You can declare a list in the following…

Customize autoexp.dat for own types in VS2005

Suppose you have a class foo like this:

And you have a variable f(1, 2, 3) what you watch in your Watch window. The window looks like this: The field Value shows a default expansion of the object, {X=1 Y=2 Z=3}. However, this can be changed by modifying a file called autpexp.dat, located in…

Make Your Code Readable!

One of the most important qualities of code is, or at least should be, readability. The simple fact that it works is not enough. If it’s not readable, it definitelly ain’t maintainable. Thus, our mission, as programmers, is to right code, that above being correct, is also readable and understandable. When a new programmer joins a team…