Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Unexpect abmbigious grammar(Can't understand where is a problem)
Unexpect abmbigious grammar [message #1740830] Thu, 18 August 2016 14:45 Go to next message
Eclipse UserFriend
Hi all, I have create xtext grammar and have warnings(see it bellow) I understand that XText have generated ambigious ANTLR grammar, but don't understand why.
So, what is wrong in my grammar?

Regards,
Vladimir

grammar com.idc.net.Validator with org.eclipse.xtext.common.Terminals

generate validator "http://www.idc.com/net/Validator"

Model:
	netDescriptions+=NetDescription+;

NetDescription:
	descriptionPairs+=DescriptionPair+;

DescriptionPair:
	IPADDR | NETMASK | SPEED | MTU | TSO | GATEWAY | VLAN | ROUTER | SUBNET | NO_VLANS | VLAN;
//List of numbers with 3 digit
 VLAN:
	'VLAN_' name=ID '='
	value=IntList;

IntList:
	valueList+=INT+ | '"' valueList+=INT+ '"';

IPAddrList:
	ipNum1=INT '.' ipNum2=INT '.' ipNum3=INT '.' ipNum4=INT;

//List of numbers with 3 digit
 NO_VLANS:
	'NO_VLANS_' name=ID '=' list+=IntList;

SUBNET:
	'SUBNET_' name=ID '=' list+=IPWithQuotes;

ROUTER:
	'ROUTER_' name=ID '=' list+=IPWithQuotes;

GATEWAY:
	'GATEWAY_' name=ID '=' list+=IPWithQuotes;

MTU:
	'MTU_' name=ID '=' val=IntWithQuotes;

TSO:
	'TSO_' name=ID '=' '"' value=ON_OFF '"';

ON_OFF:
	'on' | 'off';

NETMASK:
	'NETMASK_' name=ID '=' list+=IPWithQuotes;

SPEED:
	'SPEED_' name=ID '=' value=IntWithQuotes;

IPADDR:
	'IPADDR_' name=ID '=' list+=IPWithQuotes;

IPWithQuotes:
	IPAddrList | '"' IPAddrList '"';

IntWithQuotes:
	value=INT | '"' value=INT '"';



warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:132:2: Decision can match input such as "'SPEED_'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:132:2: Decision can match input such as "'GATEWAY_'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:132:2: Decision can match input such as "'VLAN_'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:132:2: Decision can match input such as "'IPADDR_'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:132:2: Decision can match input such as "'MTU_'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:132:2: Decision can match input such as "'TSO_'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:132:2: Decision can match input such as "'NO_VLANS_'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:132:2: Decision can match input such as "'NETMASK_'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:132:2: Decision can match input such as "'ROUTER_'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:132:2: Decision can match input such as "'SUBNET_'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:150:2: Decision can match input such as "'VLAN_' RULE_ID '=' RULE_INT" using multiple alternatives: 7, 11
As a result, alternative(s) 11 were disabled for that input
warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:150:2: Decision can match input such as "'VLAN_' RULE_ID '=' '"' RULE_INT '"'" using multiple alternatives: 7, 11
As a result, alternative(s) 11 were disabled for that input
error(201): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:150:2: The following alternatives can never be matched: 11
Re: Unexpect abmbigious grammar [message #1740831 is a reply to message #1740830] Thu, 18 August 2016 14:50 Go to previous messageGo to next message
Eclipse UserFriend
If you have a model with

Speed_ s1 = "1"
Speed_ s2 = "2"

Should that give one model with two net descriptions with one pair each
Or should that give one model with one description with two pairs?
Re: Unexpect abmbigious grammar [message #1740843 is a reply to message #1740831] Thu, 18 August 2016 17:23 Go to previous messageGo to next message
Eclipse UserFriend
Oh, look like I'm wrong in my grammar. Actually I don't need NetDescription rule, jast pairs.
So, now my grammar is following with other(but look like with the same sence) How to fix it?

Regards,
Vladimir
grammar com.idc.net.Validator with org.eclipse.xtext.common.Terminals

generate validator "http://www.idc.com/net/Validator"

Model:
	netDescription+=DescriptionPair+;

DescriptionPair:
	IPADDR | NETMASK | SPEED | MTU | TSO | GATEWAY | VLAN | ROUTER | SUBNET | NO_VLANS | VLAN;
//List of numbers with 3 digit
 VLAN:
	'VLAN_' name=ID '='
	value=IntList;

IntList:
	valueList+=INT+ | '"' valueList+=INT+ '"';

IPAddrList:
	ipNum1=INT '.' ipNum2=INT '.' ipNum3=INT '.' ipNum4=INT;

//List of numbers with 3 digit
 NO_VLANS:
	'NO_VLANS_' name=ID '=' list+=IntList;

SUBNET:
	'SUBNET_' name=ID '=' list+=IPWithQuotes;

ROUTER:
	'ROUTER_' name=ID '=' list+=IPWithQuotes;

GATEWAY:
	'GATEWAY_' name=ID '=' list+=IPWithQuotes;

MTU:
	'MTU_' name=ID '=' val=IntWithQuotes;

TSO:
	'TSO_' name=ID '=' '"' value=ON_OFF '"';

ON_OFF:
	'on' | 'off';

NETMASK:
	'NETMASK_' name=ID '=' list+=IPWithQuotes;

SPEED:
	'SPEED_' name=ID '=' value=IntWithQuotes;

IPADDR:
	'IPADDR_' name=ID '=' list+=IPWithQuotes;

IPWithQuotes:
	IPAddrList | '"' IPAddrList '"';

IntWithQuotes:
	value=INT | '"' value=INT '"';


warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:114:2: Decision can match input such as "'VLAN_' RULE_ID '=' RULE_INT" using multiple alternatives: 7, 11
As a result, alternative(s) 11 were disabled for that input
warning(200): ../com.idc.net.validator/src-gen/com/idc/net/parser/antlr/internal/InternalValidator.g:114:2: Decision can match input such as "'VLAN_' RULE_ID '=' '"' RULE_INT '"'" using multiple alternatives: 7, 11
As a result, alternative(s) 11 were disabled for that input
Re: Unexpect abmbigious grammar [message #1740849 is a reply to message #1740843] Fri, 19 August 2016 00:46 Go to previous message
Eclipse UserFriend
you have VLAN twice in the list

DescriptionPair:
IPADDR | NETMASK | SPEED | MTU | TSO | GATEWAY | VLAN | ROUTER | SUBNET | NO_VLANS;
Previous Topic:Import Resolution - XBase
Next Topic:invoking MWE2 workflows from a central MWE2 workflow
Goto Forum:
  


Current Time: Wed Jul 23 22:34:03 EDT 2025

Powered by FUDForum. Page generated in 0.25516 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top