SymbolicAI — Update 1

I have now built a skeleton (well, perhaps the skeleton of a skeleton) of SymbolicAI’s symbol-manipulation code. Here is the program, Version 0.1:

/*
SymbolicAI V0.1 by Asymptote
August 2007

Fiddle about with this as much as you want, but I make no promises as to its stability
or usefulness. If you do fiddle with it anyway, you must leave this header intact.
*/

//The Symbol object. These objects will represent bits of code.
class Symbol
{
public:
int getIndex(); //returns the index of the symbol. The index is a way of identifying a symbol in a specific position.
int getCode(); //returns the code of the symbol. The symbol’s code identifies what kind of symbol it is. That is, what it does.
void setIndex(int newIndex); //changes the symbol’s index. This is akin to moving it.
private:
int myIndex;
int myCode;
};

int Symbol::getIndex()
{
return myIndex;
}

int Symbol::getCode()
{
return myCode;
}

void Symbol::setIndex(int newIndex)
{
myIndex = newIndex;
}
//End of the symbol object block.

//The Word object. These objects will represent groups of symbols that form functional procedures.
class Word
{
public:
int getIndex(); //The index of the word. See the comment on the Symbol object’s getIndex() method.
unsigned int getSize();
void setIndex(int newIndex);
void setSize(unsigned int wSize);
private:
int myIndex;
unsigned int mySize;
};

int Word::getIndex()
{
return myIndex;
}

void Word::setSize(unsigned int wSize)
{
mySize = wSize;
}

void Word::setIndex(int newIndex)
{
myIndex = newIndex;
}

unsigned int Word::getSize()
{
return mySize;
}
//End of the Word object block.

#include <iostream>
using namespace std;

int main ()
{
Symbol S1;
S1.setIndex(0);
cout << S1.getIndex();

Word W1;
W1.setIndex(1);
W1.setSize(5);
cout << endl;
cout << W1.getIndex() << “,” << W1.getSize();
return 0;
}

So far, all it does is allow the initialization of “Symbol” objects and “Word” objects, and the assignment of indexes and sizes to them. All the main() function does is initialize some test objects and print off their properties to the console.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: