Click here to Skip to main content
12,691,777 members (28,847 online)
Click here to Skip to main content

Stats

33.2K views
1.5K downloads
65 bookmarked
Posted

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.
#ifndef __BRAINLESS_CONSTS_DEFINES__
#define __BRAINLESS_CONSTS_DEFINES__
/*
Author : Shakti Misra
Copy Right: 2011
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.
*/

//Data types
typedef unsigned long ulong;

#ifndef DIM
#define DIM( a ) ( sizeof(a)/sizeof(a[0]) )
#endif

#define BCHAR( a ) #a
#define WBCHAR( a ) L ## #a

#define VM_VERSION v0.4

const ulong REGISTER_FILE = 4;

const ulong TAPE_SIZE = 64;
const ulong ARR_SIZE_128 = 128;
const ulong BUFFER_SIZE = 256;

const unsigned int BLOCK_NAME_SIZE = 256;

typedef int BOOL;
#define TRUE 1
#define FALSE 0

//Hex constants
const ulong HEX_0 = 0x00000000;
const ulong HEX_1 = 0x00000001;
const ulong HEX_2 = 0x00000002;
const ulong HEX_3 = 0x00000003;
const ulong HEX_4 = 0x00000004;

const ulong COMPARE_FLAG_MASK = 0x00000003;

#endif //__BRAINLESS_CONSTS_DEFINES__

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.

License

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

Share

About the Author

BrainlessLabs.com
Engineer
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:

http://brainlesslabs.com/

https://github.com/BrainlessLabsInc
https://github.com/sp-mishra

http://www.luxrender.net/en_GB/authors_contributors - SMISRA

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170117.1 | Last Updated 11 Oct 2013
Article Copyright 2010 by BrainlessLabs.com
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid