first and last character truncated in STRING terminals [message #943160] |
Sun, 14 October 2012 07:51 |
|
I have redefined the STRING terminal this way
terminal STRING : ('.'|'+'|'('|')'|'a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
because I have to recognize STRING not delimited by " or '
the problem is that, though the generated parser works, it truncates the first and the last character of the recognized string. What am I missing?
|
|
|
|
|
|
|
|
|
Re: first and last character truncated in STRING terminals [message #943196 is a reply to message #943192] |
Sun, 14 October 2012 08:34 |
|
OK now I have a class extending DefaultTerminalConverters and overriding its public IValueConverter<String> STRING() method.
Such method returns an instance of another self made class extending AbstractLexerBasedConverter<String> which basically does the same things of STRINGValueCoverter but it does not substring the original string.
No What do I have to do in the runtime module to make xtext using my own TerminalConverter?
Follow me on Twitter @andreasindico
|
|
|
|
|
|
|
|
Re: first and last character truncated in STRING terminals [message #960514 is a reply to message #959384] |
Sat, 27 October 2012 14:50 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Please refer to the section on terminal rules in the documentation. Your
STRING rule will basicly consume everything like ID and INTs since it is
defined with a higher priority (because the others are inherited).
Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 26.10.12 19:24, schrieb Kokongi Nei:
> Andrea,
>
> I am attempting to do the same thing--have a grammar that supports
> unquoted STRINGs. As the first step, I am overriding the terminal
> STRING as you did:
>
> terminal STRING : ('.'|'+'|'('|')'|'a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
>
> But, when I run the MWE2 Workflow, I get this error:
>
> error(208):
> ../org.xtext.example.definitions/src-gen/org/xtext/example/definitions/parser/antlr/internal/InternalDefinitions.g:243:1:
> The following token definitions can never be matched because prior
> tokens match the same input: RULE_INT
>
> I assume you had the same problem, and if so, what did you do?
>
> Thanks!
|
|
|
Powered by
FUDForum. Page generated in 0.04811 seconds