Type inference in C++

The new C++0x standard provides support for type inference. The auto keyword that was doing nothing in C++ was given a new meaning: a placeholder for a type inferred by the compiler. For those familiar with C#’s var keyword, this is basically the same. Here is a comparison between auto in C++ and var in…

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….

Helper Class for Console Functions

Have you tried to print colored text in a console or put the text at a specific position? You know then that STL or CRT does not provide that functionality. Windows API however, contains a set of functions for working with console windows. The list of these functions is available in MSDN. However, to simplify…

Vista Aero’s Menus Hiding with MFC 9.0

You probably noticed that IE7 or Windows Media Player 11 don’t have the menu shown by default; it only shows up when you press the ALT key. This is one particularity of the look and feel of Windows Vista Aero.¬†You can find guidelines about designing menus here: menu guidelines menu design concepts As revealed by…

File Dialogs in MFC 9.0

Windows Vista redesigned the way the file dialogs look. MFC 9.0 (that will ship with Visual Studio 2008) was updated to support the new look and feel. If you compile your MFC application with VS 2008 you get the new file dialogs with no additional change. On the other hand if you run the application…

UNICODE support in the C++ Standard

The Oxford meeting of the ISO C++ standards committee between 15-20 April resulted in new features beeing into the draft paper of the C++0x standard. One of the features refer to Unicode support: a new header, called <cuchar>, was introduced. This header makes available new built-in types char16_t and char32_t, as well as new prefixes…

Working with the Registry in VC++

Working correctly with the Windows Registry might prove a little difficult, especially for beginners. One thing one should care about for example is using the correct access rights (not just the default ones) when creating a registry key. To ease the burden of directly using the Win32 registry API, I decided to wrap them inside…