//parsing (a,d,n)


#include <iostream>


using namespace std;

char  getsym();
void L(char sym);
void C(char sym);
void c(char sym);

int main()
{
	char nextsym;
	
	nextsym = getsym();
	cout << nextsym;

	return 0;
}

char getsym()
{
	static char array[20] = "(a,d,n)";
	static int i = -1;
	++i;

return array[i];
	
}

void L(char sym)
{
	if (sym == '(')
	{
		sym = getsym();
		C(sym);
	}
}

void C(char sym)
{
	if(sym == 'a')
	{
		sym=getsym();
		c(sym);
	}
	else
		cout << "Error parsing" << endl;

}

void c(char sym)
{
	if(sym == ',')
	{
		sym=getsym();
		if(sym==id)
		{
			sym=getsym);
			c(sym);
		}
	}
	else
		cout << "ID expected" << endl;

}

Hello guys, I've got a problem , I'm trying to parse the input however a,d,n are ID's therfore how can I tell or program that they are ID's ?

Member Avatar for iamthwee
//parsing (a,d,n)


#include <iostream>


using namespace std;

char  getsym();
void L(char sym);
void C(char sym);
void c(char sym);

int main()
{
	char nextsym;
	
	nextsym = getsym();
	cout << nextsym;

	return 0;
}

char getsym()
{
	static char array[20] = "(a,d,n)";
	static int i = -1;
	++i;

return array[i];
	
}

void L(char sym)
{
	if (sym == '(')
	{
		sym = getsym();
		C(sym);
	}
}

void C(char sym)
{
	if(sym == 'a')
	{
		sym=getsym();
		c(sym);
	}
	else
		cout << "Error parsing" << endl;

}

void c(char sym)
{
	if(sym == ',')
	{
		sym=getsym();
		if(sym==id)
		{
			sym=getsym);
			c(sym);
		}
	}
	else
		cout << "ID expected" << endl;

}

Hello guys, I've got a problem , I'm trying to parse the input however a,d,n are ID's therfore how can I tell or program that they are ID's ?

What do u think? Your ID's should have unique characteristics for example, they might be all numbers, or always begin with a letter.

All you have to do is ensure each input matches what you expect. Simple as pie.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.