Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forumsfirst and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/943160/#msg_943160
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?]]>Andrea Sindico2012-10-14T07:51:34-00:00Re: first and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/943165/#msg_943165
Christian Dietrich2012-10-14T07:58:53-00:00Re: first and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/943172/#msg_943172
thank you for your answer.
What is the easiest way to do that, considering that I just need to turn that into an EString?
]]>Andrea Sindico2012-10-14T08:07:11-00:00Re: first and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/943179/#msg_943179
then simply do a one to one mapping in the valueconverter. http://www.eclipse.org/Xtext/documentation.html#valueconverter
(ovveride org.eclipse.xtext.common.services.DefaultTerminalConverters.STRING())
~Christian]]>Christian Dietrich2012-10-14T08:15:17-00:00Re: first and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/943187/#msg_943187
]]>Andrea Sindico2012-10-14T08:27:03-00:00Re: first and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/943188/#msg_943188
for the StringValueConverter Class
I guess I also need the AbstractLexerBasedConverter ?]]>Andrea Sindico2012-10-14T08:28:47-00:00Re: first and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/943192/#msg_943192
Christian Dietrich2012-10-14T08:31:22-00:00Re: first and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/943196/#msg_943196
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?]]>Andrea Sindico2012-10-14T08:34:53-00:00Re: first and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/943201/#msg_943201
@Override
public Class<? extends IValueConverterService>
bindIValueConverterService() {
return MyStringValueConverter.class;
}
in the RuntimeModule and it works perfectly]]>Andrea Sindico2012-10-14T08:42:39-00:00Re: first and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/943202/#msg_943202
have a look at the existing binding and you will know what to do
public Class<? extends org.eclipse.xtext.conversion.IValueConverterService> bindIValueConverterService() {
return DefaultTerminalConverters.class;
}
~Christian]]>Christian Dietrich2012-10-14T08:42:53-00:00Re: first and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/943203/#msg_943203
Andrea Sindico2012-10-14T08:43:06-00:00Re: first and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/943392/#msg_943392
> I am diving into the DefaultTerminalConverters in order to see how the
> STRING conversion was made and properly ovverride it. However I see the
> string conversion is delegated to an injected object
> (stringValueConverter). Where is that defined ? Xtext's architecture is
> so well made and so loose coupled that I can't find where things are
> actually done :)
Tip,
If injection is made via interface, look at the source for the interface
- see if it has a ImplementedBy annotation. That is the class that is
used unless there is a binding in the module(s) used to setup your langague.
Secondly, look the module for your language, open type hierarchy and
include all inherited methods. See if you find the class there.
Typically, I find it easier to just debug, set a breakpoint at look at
the class of the injected thing.
Regards
- henrik]]>Henrik Lindberg2012-10-14T12:43:18-00:00Re: first and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/959384/#msg_959384
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:
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!]]>Kokongi Nei2012-10-26T17:24:11-00:00Re: first and last character truncated in STRING terminals
https://www.eclipse.org/forums/index.php/mv/msg/401701/960514/#msg_960514
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!]]>Sebastian Zarnekow2012-10-27T14:50:47-00:00