Terminal Rule Error [message #899938] |
Fri, 03 August 2012 05:53 |
|
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 06:04] Report message to a moderator
|
|
|
|
Re: Terminal Rule Error [message #899940 is a reply to message #899939] |
Fri, 03 August 2012 06:07 |
|
thank you for your reply.
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.
|
|
|
|
Re: Terminal Rule Error [message #899942 is a reply to message #899941] |
Fri, 03 August 2012 06:12 |
|
I need the Lexer recognize "#include someName" as a token.
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.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04557 seconds