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: 71
Registered: May 2012
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

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

or
(TCL)
foreach i { 0 1 2 3 } {
someString${i}
} -- 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: 10585
Registered: July 2009
Senior Member
The term to search for is cross references and scoping
Previous Topic:How to infer a method with generics?
Next Topic:Enumeration Element Cross Reference
Goto Forum:
  


Current Time: Sun May 28 20:37:09 GMT 2017

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

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