multimapping

Hey guys I have a problem with my program, I am trying to read in a grammar putting multiple right hand rules to a left hand rule using multimapping. The thing is that let's say the rule is:
a -> al pha bet
it maps [a, al] and ignores the rest.
Was wondering if you guys could spot an error that I cannot.
Thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
void righthandside(){		// get rhs of grammar rule

	char c;
	skipSpace();
	c = getchar();
	if(isalpha(c)){
		checkforE = false;	// rule not epsilon
		while(isalnum(c)){
			righths += c;
			c = getchar();
		}
		righths += '\0';
		/*for(int i = 0; i < MAX_LENGTH; i ++){  //do check for Terminals being used on lhs

		}*/
		rule.insert(pair<string, string>(LHS[lhs], righths)); 
		righths.clear();
		righthandside();
	}
	else if(c == '#'){
		if(checkforE == true)
			rule.insert(pair<string, string>(LHS[lhs], epsilon));  // rule states NT goes to epsilon
		skipSpace();
		c = getchar();
		if(c == '#'){			//end of file
			quit = false;
		}
		else{					// end of rule 
			ungetc(c, stdin);
			lhs++;
			readGR();
		}
	}
	else{ 
		errorcode(0); 
	}
}
Last edited on
Topic archived. No new replies allowed.