Home » Modeling » TMF (Xtext) » Problem with whitespace and terminals
Problem with whitespace and terminals [message #882792] |
Thu, 07 June 2012 08:03 |
Axel Guckelsberger Messages: 354 Registered: July 2009 |
Senior Member |
|
|
Hi all,
I am working on a grammar which has just been imported from an existing
ecore file.
When generating the language infrastructure I receive dozens of these
warnings:
warning(209): ../mydsl/src-
gen/mydsl/parser/antlr/internal/InternalMyDsl.g:16194:1: Multiple token
rules can match input such as "'D'": T__94, T__123, T__127, T__187, T__189,
T__194, T__206, T__221, T__229, T__230, T__265, T__283, T__284, RULE_ID
As a result, token(s)
T__123,T__127,T__187,T__189,T__194,T__206,T__221,T__229,T__230,T__265,T__283,T__284,RULE_ID
were disabled for that input
So as soon as multiple keywords start with the same letter they seem to
become competitors. Probably a lexer problem?
When I removed the Terminals grammar and just used some needed rules of it,
like ID and STRING, suddenly everything worked fine. Except that I had no
comments functionality anymore. If I copy the whitespace declarations
(hidden()) as well the problems occur again.
Any idea how to prevent the whitespace rules breaking my grammar?
TIA,
Axel
|
|
| |
Re: Problem with whitespace and terminals [message #883256 is a reply to message #882792] |
Fri, 08 June 2012 06:42 |
|
It usually is a sign that your grammar became ambigious. This can partially be solved by semantic predicates, or by enabling backtracking. Backtracking should be avoided when possible, since it can result in unpredictable results.
~Karsten
Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
|
|
| |
Re: Problem with whitespace and terminals [message #884674 is a reply to message #884663] |
Mon, 11 June 2012 15:33 |
Henrik Lindberg Messages: 2509 Registered: July 2009 |
Senior Member |
|
|
On 2012-11-06 17:20, Axel Guckelsberger wrote:
> Karsten,
>
> thanks for the pointer. Indeed the warning messages do sometimes appear and
> sometimes not, it seems like a random choice.
>
> Any idea how to examine the grammar for finding the ambigious parts? I tried
> opening and checking the .g file with antlrworks, but the grammar validated
> fine there.
>
> Greetings,
> Axel
>
> Karsten Thoms wrote:
>
>> It usually is a sign that your grammar became ambigious. This can
>> partially be solved by semantic predicates, or by enabling backtracking.
>> Backtracking should be avoided when possible, since it can result in
>> unpredictable results.
>>
>> ~Karsten
>
Do you have backtracking turned on? That can mask lots of grammar problems.
I had similar issues with a complex (backtracking) grammar, and I had to
do two things - make sure the grammar generator had plenty of memory,
and that it did not time out (a parameter can be set in the workflow for
that). I also had to make sure nothing heavy was running on my machine
at the same time.
Later I reduced the complexity (moving things to an external lexer)
which had several positive effects, one being that a lot less resources
were required due to big reduction in tokens/rules.
Regards
- henrik
|
|
| |
Goto Forum:
Current Time: Thu Apr 25 17:43:14 GMT 2024
Powered by FUDForum. Page generated in 0.03233 seconds
|