Click here to Skip to main content
15,887,350 members
Articles / Programming Languages / C++

MyBasic - A Custom-BASIC language interpreter written in C++

Rate me:
Please Sign up or sign in to vote.
4.75/5 (18 votes)
12 Oct 2003 227.5K   4.5K   46  
A Custom-BASIC language interpreter written in C++
// BasicTokenizer.h: interface for the CBasicTokenizer class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_BasicTokenizer_H__5D1CA606_A57E_11D2_8AB9_00002145DF63__INCLUDED_)
#define AFX_BasicTokenizer_H__5D1CA606_A57E_11D2_8AB9_00002145DF63__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "StringTokenizer.h"

#define	TT_KW_PRINT		-10
#define	TT_KW_INPUT		-11
#define	TT_KW_IF		-12
#define	TT_KW_THEN		-13
#define	TT_KW_ENDIF		-15
#define	TT_KW_FOR		-16
#define	TT_KW_NEXT		-17
#define	TT_KW_TO		-18
#define	TT_KW_GOTO		-19
#define	TT_KW_GOSUB		-20
#define	TT_KW_RETURN	-21
#define	TT_KW_END		-22

#define TT_GTE			-50
#define TT_LWE			-51
#define TT_IS			-52
#define TT_NE			-53


#define MAX_KW			100


class CBasicTokenizer : public CStringTokenizer  
{

public:
	virtual void PushBack();
	virtual CString GetStrValue(void);
	virtual	int NextToken(void);
	void InsertKeyword(CString &str, int code);
	CBasicTokenizer();
	virtual ~CBasicTokenizer();
private:
	BOOL m_bPushedBack;
	CMap<CString, LPCSTR, int, int>	m_Keywords;
	int m_tType;

};

#endif // !defined(AFX_BasicTokenizer_H__5D1CA606_A57E_11D2_8AB9_00002145DF63__INCLUDED_)

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions