Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Space validation(Xtext white Space)
Space validation [message #1804314] Fri, 22 March 2019 06:36 Go to next message
Eclipse UserFriend
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 07:12 Go to previous messageGo to next message
Eclipse UserFriend
maybe you can do something like org.eclipse.xtext.serializer.sequencer.HiddenTokenSequencer.getHiddenNodesBetween(INode, INode)
Re: Space validation [message #1804412 is a reply to message #1804317] Mon, 25 March 2019 13:47 Go to previous message
Eclipse UserFriend
As an alternative, you could write a formatter to remove the extra spaces.
Previous Topic:Security Exception when building Projects with Xtend
Next Topic:Validation (warning) when object is not used
Goto Forum:
  


Current Time: Wed Apr 30 16:34:10 EDT 2025

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

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

Back to the top