|
|
|
|
|
|
|
Re: problem with lexing terminal rules [message #720934 is a reply to message #720508] |
Wed, 31 August 2011 13:49 |
Kai Kreuzer Messages: 42 Registered: July 2009 |
Member |
|
|
Hi Henrik,
Thanks for the hint, I actually had already read your post some when
last year :-)
In general, I am well aware of how to use data rules and value
converters. Unfortunately, my current problem is a bit trickier as it
deals with overridden and hidden terminals.
Imagine for example you wanted to write your timestamps not as a STRING,
but as something like 2011-08-31 15:50:30 and this without any quotes.
My idea was to define a terminal rule for this, which would end up as a
single "chunk" in the parse tree.
~Kai
Am 8/30/2011 8:05 PM, schrieb Henrik Lindberg:
> Take a look at:
> http://henrik-eclipse.blogspot.com/2010/05/implementing-date-support-with-quickfix.html
>
>
> It shows:
> - Using an ecore data type in the grammar
> - A Date value converter
> - Overriding the SyntaxErrorMessageProvider
> - Providing a quick fix for a ValueConverterException
>
> - henrik
>
> On 8/30/11 12:42 PM, Kai Kreuzer wrote:
>> Hi,
>>
>> I have a very simple grammar, where I do not know how to solve lexing
>> problems for:
>>
>> Model:
>> entries+=Entry*;
>>
>> Entry:
>> Difference | DATE;
>>
>> Difference :
>> INT '-' INT;
>>
>> terminal DATE:
>> ('0'..'9')('0'..'9')'-'('0'..'9')('0'..'9')'-'('0'..'9')('0'..'9');
>>
>>
>> My model simply consists out of lines which are either dates (in format
>> dd-mm-yyyy) or differences between integers (x-y).
>>
>> The result of the parser is now:
>> 30-08-11 -> correctly parsed as a DATE
>> 5-3 -> correctly parsed as a Difference
>> 12-5 -> Error: mismatched character '<EOF>' expecting set '0'..'9'
>>
>> How can I make the third case working?
>>
>> Thanks in advance for any hints!
>> Kai
>
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04827 seconds