Skip to main content



      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 10:12 Go to next message
Eclipse UserFriend
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 11:00 Go to previous message
Eclipse UserFriend
The term to search for is cross references and scoping
Previous Topic:Substitute for xtext-utils unittesting?
Next Topic:Enumeration Element Cross Reference
Goto Forum:
  


Current Time: Wed Jul 02 20:45:29 EDT 2025

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

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

Back to the top