SanBasic interperter is a public domain basic interpter in few hundred lines of code. I supports a decent subset of basic. Read the source code to learn how it works .
Read this article for a detailed explanation of the code http://sandeepmathew.wordpress.com/2009/03/08/system-programming-game-development-and-kernel-development/ You may use it for anything you need :) .