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
Hi,
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 "http://www.xtext.org/example/mydsl/MyDsl"

Model:
greetings+=Greeting*|LgInstruction;

Greeting:
'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: 14665
Registered: July 2009
Senior Member
maybe you can do something like org.eclipse.xtext.serializer.sequencer.HiddenTokenSequencer.getHiddenNodesBetween(INode, INode)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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: 177
Registered: July 2009
Location: Canada
Senior Member
As an alternative, you could write a formatter to remove the extra spaces.

Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
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: Sat Apr 20 02:44:40 GMT 2024

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

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

Back to the top