Home » Modeling » TMF (Xtext) » Content assist and caracter encoding
| | |
Re: Content assist and caracter encoding [message #513802 is a reply to message #513612] |
Thu, 11 February 2010 11:17 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Michael,
the value converter will automatically delegate to the EcoreFactory for
datatypes without an explicit conversion rule. Floats, Doubles, Dates
etc should work out of the box this way.
We decided to limit the default terminal rules to a reasonable set of
commonly used tokens. That's why there is no floating point number and
no signed integer rule. However, if you create your own data type or
terminal rule and do not create a converter for it, the default emf
based conversion will be used, e.g.
SignedInt return EInt:
('+'|'-')? INT;
should work. Note that this functionality has been added in the latest
milestone of the 0.8.0 stream.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 10.02.10 18:09, schrieb Michel Simeon:
> I have created my own value converter ( i needed one anyway). I actually
> copied the STRING conversion from DefaultTerminalConverters, and called
> a modified version of convertToJavaString, where the default switch case
> does not recreate the \uxxxx notation as in the original.
>
> So my question is: what is the rationale for doing it that way ? Also,
> why are Default Terminals so limited, would not it be usefull to include
> floating point numbers or negative integers ?
>
> Regards
> MS
|
|
|
Re: Content assist and caracter encoding [message #513929 is a reply to message #513802] |
Thu, 11 February 2010 17:13 |
Michel Simeon Messages: 130 Registered: December 2009 |
Senior Member |
|
|
[quote title=Sebastian Zarnekow wrote on Thu, 11 February 2010 06:17]Hi Michael,
the value converter will automatically delegate to the EcoreFactory for
datatypes without an explicit conversion rule. Floats, Doubles, Dates
etc should work out of the box this way.
We decided to limit the default terminal rules to a reasonable set of
commonly used tokens. That's why there is no floating point number and
no signed integer rule. However, if you create your own data type or
terminal rule and do not create a converter for it, the default emf
based conversion will be used, e.g.
SignedInt return EInt:
('+'|'-')? INT;
should work. Note that this functionality has been added in the latest
milestone of the 0.8.0 stream.
Regards,
Sebastian
--
Thank you for the clarification. I has indeed defined my own SignedInt and Float rules together with corresponding value converters, and checked that I could do without those value converters.
Regards
MS
|
|
| | | |
Re: Content assist and caracter encoding [message #514136 is a reply to message #514127] |
Fri, 12 February 2010 14:48 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Hallvard,
you wouldn't like the error message "IllegalArgumentException: ..." in
your editor, would you? Furthermore, RuntimeExceptions usually indicate
programming errors and that's why we should not catch those.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 12.02.10 15:08, schrieb Hallvard Trætteberg:
> Sven Efftinge wrote:
>> Hallvard Trætteberg schrieb:
>>> Follow-up question:
>>>
>>> I need to define a rule for URIs and believe it can be done as follows:
>>> - define URI datatype in my domain model
>>> - generate and implement the createFromString and convertToString in
>>> the factory
>>> - define a terminal rule that return the datatype
>>>
>>> Is this correct, i.e. will the parser use the factory methods?
>>
>> Yes, as long as you use 0.8.0 >= M4.
>
> :-)
>
>>> How should I signal syntax errors in the createFromString method, so
>>> it is picked up by the parser (in case the terminal rule isn't tight
>>> enough)?
>>
>> Errors which occur during value conversion can be reported by throwing
>> a org.eclipse.xtext.conversion.ValueConverterException.
>
> The URI class throws an IllegalArgumentException, so from what you write
> I need to wrap it in a ValueConverterException. It doesn't seem right to
> do this in the Factory, after all it should be independent of Xtext.
> Hence, I have to create an Xtext value converter after all? Wouldn't it
> make sense to catch all RuntimeExceptions and treat them as
> ValueConverterExceptions?
>
> Hallvard
|
|
|
Goto Forum:
Current Time: Thu Sep 19 09:51:25 GMT 2024
Powered by FUDForum. Page generated in 0.04111 seconds
|