Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How can I override STRING?
How can I override STRING? [message #1831536] Sat, 22 August 2020 06:13 Go to next message
David Sun is currently offline David SunFriend
Messages: 12
Registered: July 2020
Junior Member
In my project,I need override STRING. I'm going to replace double quotes with single quotes.(eg: 'helloworld')
I tried to write a rule, but I failed!
index.php/fa/38803/0/

Can anyone help me ??

Thanks a lot!

  • Attachment: 1.png
    (Size: 43.96KB, Downloaded 54 times)
  • Attachment: 1.png
    (Size: 43.96KB, Downloaded 13 times)
Re: How can I override STRING? [message #1831539 is a reply to message #1831536] Sat, 22 August 2020 08:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13721
Registered: July 2009
Senior Member
the .? makes no sense. its just one char.
is there any reason you don use -> as in the comment rule or just copy the one half of the overriden STRING rule from terminals?

"'" ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|"'") )* "'


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How can I override STRING? [message #1831543 is a reply to message #1831539] Sat, 22 August 2020 10:29 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6993
Registered: July 2009
Senior Member
Hi

You partially override builtins by deleting the grammar 'inheritance' from org.eclipse.xtext.common.Terminals.

You can then duplicate as much of org.eclipse.xtext.common.Terminals as you want in your own grammar with whatever changes you feel appropriate.

However this is only a partial override since beware that certain terminal such as ID have built-in functionality.

Regards

Ed Willink
Re: How can I override STRING? [message #1831544 is a reply to message #1831539] Sat, 22 August 2020 10:35 Go to previous message
David Sun is currently offline David SunFriend
Messages: 12
Registered: July 2020
Junior Member
Thanks for your advice!
I resovled this problem.
Previous Topic:Maven build fails when using my own XtextGenerator
Next Topic:Extend xbase with a more expressive range
Goto Forum:
  


Current Time: Sat Jan 23 04:32:26 GMT 2021

Powered by FUDForum. Page generated in 0.02525 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top