But I got the error message as following
Multiple markers at this line
- missing EOF at 'ut'
- mismatched character 'p' expecting 'c'

I tried to find the reason. And, I found that the lexer using an DFA to predict which terminal rule should be used. When it find the letter '#' followed by the 'i', it decide to use the terminal rule "INCLUDE". But it fail to recognize the token, because the input is "#input" not "#include".

Beside using backtrack of Lexer, what can I do to solve this problem?
By the way, I need the terminal rule "INCLUDE" in that form. Because I want to treat the string "#include someName" as a token.]]>Kevin Sun2012-08-03T05:53:44-00:00Re: Terminal Rule Errorhttps://www.eclipse.org/forums/index.php/mv/msg/368947/899939/#msg_899939
your grammar is ambigous. you may want to use a datatype rule instead

INCLUDE hidden():
'#' ('include'|'INCLUDE') WS ID;
]]>Christian Dietrich2012-08-03T06:03:43-00:00Re: Terminal Rule Errorhttps://www.eclipse.org/forums/index.php/mv/msg/368947/899940/#msg_899940
I forget to mention that I do need the terminal rule "INCLUDE" in that form. Because I want to treat the string "#include someName" as a token.]]>Kevin Sun2012-08-03T06:07:47-00:00Re: Terminal Rule Errorhttps://www.eclipse.org/forums/index.php/mv/msg/368947/899941/#msg_899941
Quote:

I want to treat the string "#include someName" as a token.

]]>Christian Dietrich2012-08-03T06:08:34-00:00Re: Terminal Rule Errorhttps://www.eclipse.org/forums/index.php/mv/msg/368947/899942/#msg_899942
If there is no easy way to solve this problem, I'll change it to a datatype rule. But I hope I can remain it as a terminal rule.]]>Kevin Sun2012-08-03T06:12:40-00:00Re: Terminal Rule Errorhttps://www.eclipse.org/forums/index.php/mv/msg/368947/899943/#msg_899943
Christian Dietrich2012-08-03T06:14:54-00:00Re: Terminal Rule Errorhttps://www.eclipse.org/forums/index.php/mv/msg/368947/899944/#msg_899944
http://www.eclipse.org/forums/index.php/m/893934/#msg_893934
]]>Kevin Sun2012-08-03T06:23:15-00:00Re: Terminal Rule Errorhttps://www.eclipse.org/forums/index.php/mv/msg/368947/899971/#msg_899971

The difference is that the NUMBER_SIGN is listed after the INCLUDE. So If INCLUDE does not match it still can match NUMBER_SIGN. I have not tested it, and still often get confused with TERMINAL rules. I just have recognized that such things can make huge difference.
It has some ugly side effects as you can not use a greeting like this:

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 03.08.12 07:54, schrieb Kevin Sun:
> I meet a problem about the terminal rule. The grammar I used is following
>
> grammar org.xtext.example.mydsl.MyDsl with
> org.eclipse.xtext.common.Terminals hidden(CONDITIONAL_COMPILE_BEGIN)
>
> generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
>
> Model:
> greetings+=Greeting*;
>
> Greeting:
> '#' name=ID '!' ;
>
> terminal INCLUDE:
> '#' ('include'|'INCLUDE') WS ID;
>
>
> And the following case should be accepted by the grammer
> #input!
>
> But I got the error message as following
> Multiple markers at this line
> - missing EOF at 'ut'
> - mismatched character 'p' expecting 'c'
>
> I tried to find the reason. And, I found that the lexer using an DFA to
> predict which terminal rule should be used. When it find the letter '#'
> followed by the 'i', it decide to use the terminal rule "INCLUDE". But
> it fail to recognize the token, because the input is "#input" not
> "#include".
>
> Beside using backtrack of Lexer, what can I do to solve this problem?]]>Sebastian Zarnekow2012-08-03T09:44:50-00:00