Posted 15 years ago
		by David
	

Hi, I'm trying to solve a ambiguity issue with 2 non-terminals... 'VariableDeclaration' and 'FunctionDeclaration'
VariableDeclaration >>> 'Var' 'Identifier' 'SemiColon'
FunctionDeclaration >>> 'Var' 'Identifier' 'OpenParenthesis' 'CloseParenthesis' 'SemiColon'
As you can see they both start with the same tokens. How do I handle this?
I've tried......but it only wants to accept one or the other and can't differentiate between the two.
Is this the right way?
Thanks.
[Modified at 08/27/2010 04:19 AM]
VariableDeclaration >>> 'Var' 'Identifier' 'SemiColon'
FunctionDeclaration >>> 'Var' 'Identifier' 'OpenParenthesis' 'CloseParenthesis' 'SemiColon'
As you can see they both start with the same tokens. How do I handle this?
I've tried...
<% 
if (IsNonTerminal("FunctionDeclaration")) 
{
%>
{ "FunctionDeclaration" }
<% 
}
else if (IsNonTerminal("VariableDeclaration")) 
{
%>
{ "VariableDeclaration" }
<% 
}
else { // error! }
%>
Is this the right way?
Thanks.
[Modified at 08/27/2010 04:19 AM]
