Terminal Rule Error [message #899938] |
Fri, 03 August 2012 01:53  |
Kevin Sun Messages: 32 Registered: August 2010 Location: China |
Member |

|
|
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
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.
[Updated on: Fri, 03 August 2012 02:04] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
| Re: Terminal Rule Error [message #899973 is a reply to message #899938] |
Fri, 03 August 2012 05:44  |
Sebastian Zarnekow Messages: 2788 Registered: July 2009 |
Senior Member |
|
|
Did you try to use something like
terminal IdWithHash: '#' ID;
and a value converter that strips the # from that token?
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?
|
|
|
Powered by
FUDForum. Page generated in 0.01723 seconds