Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Space validation(Xtext white Space)
Space validation [message #1804314] Fri, 22 March 2019 10:36 Go to next message
Santhiveeran S is currently offline Santhiveeran SFriend
Messages: 7
Registered: November 2018
Junior Member
I want to validate the white space character between two elements and raise warning if more than one space.

Please find my grammar,
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl ""


'Hello' name=ID '!';

AutoNetArg: tag=ID ('=' value=ID)?

LgInstruction :
{LgInstruction} 'lg'(args+=(AutoNetArg))*

my language code is
Hello world
lg name=wip value=auto

in LG command, after LG keyword, more than one space is allowed, if it is more than one space, raise warnings.

In validator, I am able to get only the String tokens, how to do space validation between lg keyword and next elements.

Tanks for your kind help
Re: Space validation [message #1804317 is a reply to message #1804314] Fri, 22 March 2019 11:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13615
Registered: July 2009
Senior Member
maybe you can do something like org.eclipse.xtext.serializer.sequencer.HiddenTokenSequencer.getHiddenNodesBetween(INode, INode)

Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Re: Space validation [message #1804412 is a reply to message #1804317] Mon, 25 March 2019 17:47 Go to previous message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 163
Registered: July 2009
Location: Canada
Senior Member
As an alternative, you could write a formatter to remove the extra spaces.

Twitter : @NeerajBhusare
Blog :
Best regards, Neeraj
Previous Topic:Security Exception when building Projects with Xtend
Next Topic:Validation (warning) when object is not used
Goto Forum:

Current Time: Wed Sep 30 07:25:32 GMT 2020

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

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

Back to the top