Click here to Skip to main content
12,556,922 members (47,431 online)
Click here to Skip to main content


65 bookmarked

Building a Programming Language: Part II (Adding Conditions, Loop and Blocks to BrainLess)

, 11 Oct 2013 LGPL3
In this article, we will discuss implementing conditional statements, loops and blocks.
Author : Shakti Misra
All are welcome to use these files, distribute, modify and release. But This notice should be included.
This software is given as is, for use and modification.
#include "VMInterface.h"
#include "TapeMachine.h"
#include "Lexer.h"
#include <map>
#include <string>
#include <stack>

using namespace std;

typedef map<string, ulong> symTable;
typedef stack<ulong> ReturnStack;
/*This class starts the interpretation of the instructions. This will find out the meaning and interprete.*/
class Interpreter
	Lex m_lex;//We will need a lexer to get the tokens from the source file
	TapeMachine<ulong, IOInterface, TAPE_SIZE> m_tapeVirtualMachine;//We will interprete the meaning of the above tokens and we will invoke the proper function in the VM
	const string m_sFileName;

	symTable m_funSymTable;

	int _ifCount;

	Interpreter(string sFileName, string sTokenFile = ""):


	  void interpreteScript();

	void ExecuteSentence();
	bool isBlankOrNull(const char*);

	void compareWithNext();
	void compareWithNextBoolean();
	void IFBlock();
	void Sentence();
	void Block();
	void DOLoop();
	void intDisplayContent();


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


About the Author
India India
I like to explore different aspects of technology. Try new things, and get delighted. My interests are programming language, and Imaging. But its not hard to work on other things also. Algorithms delight me over a coffee break.

I basically code in C++, but JAVA is not so alien for me. I know few scripting languages also. Basically I feel that knowing a programing language is just a matter of getting introduced to it.

For my other articles check my blog on homepage: - SMISRA

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161026.1 | Last Updated 11 Oct 2013
Article Copyright 2010 by
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid