Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext strange parsing error
Xtext strange parsing error [message #1778983] Wed, 27 December 2017 15:12 Go to next message
kozhaev Vladimir is currently offline kozhaev VladimirFriend
Messages: 64
Registered: July 2009
Member
Hi all, I have following grammar

grammar com.idc.xtext.Net with org.eclipse.xtext.common.Terminals

generate net "http://www.idc.com/xtext/Net"

Model:
	netDescription+=DescriptionPair+;

DescriptionPair:
	IPaddr
	| Netmask | Speed | MTU | TSO | Gateway | Router | Subnet | NoVlans | Vlan;

IntExpression:
{IntConstant} value=INT |
{ItWithQuotes} value=INT_WITH_QUOTES;

IntListExpression:
{IntListConstant} value=INT_LIST |
{IntListConstantWithQuotes} value=INT_LIST_WITH_QUOTES|
IntExpression
;

IPAddrExpression:
	{IpAddrConst}value=IP_ADDR_TERMINAL|
	{IpAddrWithQuotes}value=IP_ADDR_WITH_QUOTES_TERMINAL;




Vlan:
	name=VLAN_NAME '='
	value=IntListExpression;

NoVlans:
	name=NO_VLANS_NAME '=' value=IntListExpression;

Subnet:
	name=SUBNET_NAME '=' list=IPAddrExpression;

Router:
	name=ROUTER_NAME '=' list=IPAddrExpression;

Gateway:
	name=GATEWAY_NAME '=' list=IPAddrExpression;

MTU:
	name=MTU_NAME '=' value=IntListExpression;

TSO:
	name=TSO_NAME '=' value=BOOLEAN;

Netmask:
	name=NETMASK_NAME '=' list=IPAddrExpression;

Speed:
	name=SPEED_NAME '=' value=IntListExpression;

IPaddr:
	name=IP_ADDR '=' list=IPAddrExpression;

terminal IP_ADDR_TERMINAL:
	INT ('.' INT)+;
	
terminal IP_ADDR_WITH_QUOTES_TERMINAL:
	'"' INT ('.' INT)+ '"';

terminal BOOLEAN:
	'on' | 'off'|'"on"'|'"off"';

terminal INT_WITH_QUOTES:
	'"' INT '"';

terminal INT_LIST:INT (('\t'|' ')+ INT)+;

terminal INT_LIST_WITH_QUOTES:'"' INT (('\t'|' ')+ INT)+ '"';


terminal NO_VLANS_NAME:
	'NO_VLANS_' ID;

terminal SUBNET_NAME:
	'SUBNET_' ID;

terminal ROUTER_NAME:
	'ROUTER_' ID;

terminal GATEWAY_NAME:
	'GATEWAY_' ID;

terminal MTU_NAME:
	'MTU_' ID;

terminal TSO_NAME:
	'TSO_' ID;

terminal IP_ADDR:
	'IPADDR_' ID;

terminal SPEED_NAME:
	'SPEED_' ID;

terminal NETMASK_NAME:
	'NETMASK_' ID;

terminal VLAN_NAME:
	'VLAN_' ID;


@Override 
terminal SL_COMMENT:
    ('#') !('\n'|'\r')* ('\r'? '\n')?
;


And when I try parse following text
Quote:
SPEED_eth0=10000 IPADDR_eth0=10.183.0.26 MTU_eth0=9000

I have following problem

Quote:
XtextSyntaxDiagnostic: null:1 required (...)+ loop did not match anything at character 'I'
XtextSyntaxDiagnostic: null:1 no viable alternative at input 'IPADDR_eth0'


But when I remove part of the text like following

Quote:
SPEED_eth0=10000


I haven't any problems. Where I'm wrong and what happends?
Regards,
Vladimir
Re: Xtext strange parsing error [message #1779033 is a reply to message #1778983] Fri, 29 December 2017 11:56 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12104
Registered: July 2009
Senior Member
having the space explicit in that terminal rule and have stuff like
INT INT INT
is a generally bad idea.

- you may have a look at backtracking lexer,
- datatype rules instead of terminal rules.


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Code generator testing strategies
Next Topic:TypeReference for nested annotations class
Goto Forum:
  


Current Time: Tue Jul 17 03:59:01 GMT 2018

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

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

Back to the top