Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Declaration Time by using terminal
Declaration Time by using terminal [message #635611] Wed, 27 October 2010 13:57 Go to next message
Maria is currently offline MariaFriend
Messages: 49
Registered: October 2010
Member
How can we declare a type time by using the terminal (or without it if it is possible).
For example I want to write 23:20:59
I have this grammar:

grammar org.xtext.example.Expression with org.eclipse.xtext.common.Terminals
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
generate expression "http://www.xtext.org/example/Expression"
Model : (imports+=Import)* (elements+= (Valeur)* ;
Valeur: {NumberLiteral} value =INT | {BooleanLiteral} value=BOOLEAN | {TimeLiteral} value=TIME

terminal BOOLEAN returns ecore::EBoolean
: 'true' | 'false';
terminal DOUBLE returns ecore::EDouble
: '-'? ('0'..'9') '.' ('0'..'9')+;
terminal TIME returns ecore::ETime
(('0'..'1') ('0'..'9'))|('2'('0'|'1'|'2'|'3'))':'('0'..'5')('0'..'9') ':' ('0'..'5')('0'..'9');

In this grammar all is accepted excepted from terminal TIME returns ecore::ETime
(('0'..'1') ('0'..'9'))|('2'('0'|'1'|'2'|'3'))':'('0'..'5')('0'..'9') ':' ('0'..'5')('0'..'9');

How can I replace it to have the possiblity to write a time format?
Re: Declaration Time by using terminal [message #635620 is a reply to message #635611] Wed, 27 October 2010 14:27 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
This kind of stuff is best done using a datatype rule -that's covered in the User Guide. It saves you from getting the terminals right and non-overlapping (probably your current problem) and adds the possibility to have inject sensible conversion and validations.

Re: Declaration Time by using terminal [message #635621 is a reply to message #635611] Wed, 27 October 2010 14:28 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
(Please ignore: double post...)

[Updated on: Wed, 27 October 2010 14:29]

Report message to a moderator

Re: Declaration Time by using terminal [message #635741 is a reply to message #635620] Wed, 27 October 2010 22:28 Go to previous messageGo to next message
Maria is currently offline MariaFriend
Messages: 49
Registered: October 2010
Member

In the user guide http://www.eclipse.org/Xtext/documentation/1_0_1/xtext.pdf I don't find any section speaking about datatype-rules.
Can you precise for me where I can find it or how I can resolve my problem of Time declaration please?
Re: Declaration Time by using terminal [message #635746 is a reply to message #635741] Wed, 27 October 2010 22:46 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Maria,

http://www.eclipse.org/Xtext/documentation/1_0_1/xtext.html# datatypeRules

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 28.10.10 00:28, schrieb Maria:
>
> In the user guide
> http://www.eclipse.org/Xtext/documentation/1_0_1/xtext.pdf I don't find
> any section speaking about datatype-rules.
> Can you precise for me where I can find it or how I can resolve my
> problem of Time declaration please?
Previous Topic:Model API generation question
Next Topic:Model with EOpposite non containment references causes problems
Goto Forum:
  


Current Time: Sat Apr 20 06:42:37 GMT 2024

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

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

Back to the top