Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Variable/String Substitution Grammar with ${var} Style
Variable/String Substitution Grammar with ${var} Style [message #1749072] Thu, 01 December 2016 15:12 Go to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 252
Registered: May 2012
Senior Member
My team uses several languages that make use of variable/string substitution in a style like this:

(shell script)
i = 1
echo ${i} -- prints 0

<#assign i = 0/>
${i} -- would print 0
<#assign j = "jThing${i}"/>
${j} -- would print jThing0

foreach i { 0 1 2 3 } {
} -- prints someString0, someString1,someString2, someString3

I would like to provide this grammar/syntax to customers, but I'm unsure where to start. The main use case would be in constructing name IDs and then using them in references later. The for loop construct would be something to address in the future.

Where would I start? I've not been able to find any hits on this topic in Google regarding string or variable substitution or variable referencing so far. And since this isn't a style that many Java programmers use (except in Eclipse String Substitution), it seems most users of Xtext aren't really concerned about it and hence there are very few (none?) articles about it.

Is this something pretty basic to do in a grammar?

Re: Variable/String Substitution Grammar with ${var} Style [message #1749079 is a reply to message #1749072] Thu, 01 December 2016 16:00 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14502
Registered: July 2009
Senior Member
The term to search for is cross references and scoping

Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Previous Topic:Substitute for xtext-utils unittesting?
Next Topic:Enumeration Element Cross Reference
Goto Forum:

Current Time: Sat Jun 10 18:12:47 GMT 2023

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

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

Back to the top