Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Validate key within key-value-list
Validate key within key-value-list [message #1816705] Tue, 05 November 2019 11:26 Go to next message
Timur Ametov is currently offline Timur AmetovFriend
Messages: 1
Registered: November 2019
Junior Member
I'm very new in XText. So please forgive me, if I use wrong terminology.

In our code we have a grammar describing key-value-list.

KeyValues:
	{KeyValues}
	('version' KeyValuesVersion=VERSION ';')?
	KeyValues+=KeyValue*;

KeyValue:
	name=ID '=' value=STRING ('[' speechs+=Speech (',' speechs+=Speech)* ']')? ('short=' short=STRING)?  ';'
;

Speech:
	value=STRING
;

terminal VERSION returns ecore::EString:
	('0'..'9')+ '.' ('0'..'9')+ '.' ('0'..'9')+
;

@Override
terminal ID:
	('a'..'z'|'A'..'Z'|'_'|'-'|'.') ('a'..'z'|'A'..'Z'|'_'|'-'|'0'..'9'|'.')*	
;


Almost everything works as expected.

However there is one issue for that I have no idea how to solve it.

In case a key contains characters which are not match to regex of ID (e.g, 1key = "value") we just see "missing EOF at '1'(org.eclipse.xtext.diagnostics.Diagnostic.Syntax)".

Is there any possibility to catch the EOF-error and so to provide a message like "The key is invalid, it may only contain following characters"?

Thank you in advance.
Re: Validate key within key-value-list [message #1816724 is a reply to message #1816705] Tue, 05 November 2019 16:35 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi, the extension point for syntax error messages is ISyntaxErrorMessageProvider,
but i cannot tell you how to implement it to detect your case


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:[Beginner] Can't get Xtext examples to work
Next Topic:Unresolved Proxy to Object in Another Document
Goto Forum:
  


Current Time: Fri Apr 26 05:29:02 GMT 2024

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

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

Back to the top