Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » disable mandatory whitespaces at certain positions
disable mandatory whitespaces at certain positions [message #1734332] Tue, 07 June 2016 09:02 Go to next message
Jonathan L. is currently offline Jonathan L.Friend
Messages: 24
Registered: May 2016
Junior Member
Hi,

I got the following rule in a grammar
WCLOCKK:
	'await' (INT 'h')? (INT 'min')? (INT 's')? (INT 'ms')? (INT 'us')?
;

which allows code like this:
await 1h 23min 5s 42ms 2us

If I delete the whitespaces between the elements errors occur.
Is it possible to make the whitespaces unnecessary without losing functionality?

Thanks in advance
Re: disable mandatory whitespaces at certain positions [message #1734334 is a reply to message #1734332] Tue, 07 June 2016 09:10 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi this is a lexer problem.
thus without solving the lexer problem - no

to solve it

(a) reduce id and introduce a datatype rule
WCLOCKK:
	'await' (INT 'h')? (INT 'min')? (INT 's')? (INT 'ms')? (INT 'us')?
;

terminal ID  		: '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_')*;

MyID : ID (INT|ID)*;



(b) use a custom lexer

(c) backtrack the lexer

parserGenerator = {
options = {
backtrackLexer = true
}
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:SimpleProjectWizardFragment
Next Topic:[SOLVED] keyword as identifier
Goto Forum:
  


Current Time: Fri Apr 26 14:04:20 GMT 2024

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

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

Back to the top